Permalink
Browse files

Merge pull request #7 from loudej/tables

Tables implementation work by rpaquay
  • Loading branch information...
2 parents 8d2258b + 87ebda2 commit 2c2ca7e65a1fdbd6707f43595f20afa8d90c8e75 @joostdenijs joostdenijs committed Feb 21, 2012
Showing with 5,031 additions and 133 deletions.
  1. +5 −0 microsoft-azure-api/pom.xml
  2. +10 −8 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/Exports.java
  3. +5 −5 ...zure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java
  4. +2 −2 ...rc/main/java/com/microsoft/windowsazure/services/blob/implementation/ContainerACLDateAdapter.java
  5. +0 −53 .../main/java/com/microsoft/windowsazure/services/blob/implementation/ContainerACLDateConverter.java
  6. +59 −0 ...i/src/main/java/com/microsoft/windowsazure/services/blob/implementation/ISO8601DateConverter.java
  7. +23 −14 ...re-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java
  8. +9 −8 ...pi/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyLiteFilter.java
  9. +47 −0 ...ft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/CommaStringBuilder.java
  10. +12 −8 ...soft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java
  11. +2 −2 .../java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClientHandler.java
  12. +9 −32 ...re-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/PipelineHelpers.java
  13. +7 −0 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/EdmValueConverter.java
  14. +43 −0 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/Exports.java
  15. +21 −0 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/TableConfiguration.java
  16. +104 −0 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/TableContract.java
  17. +38 −0 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/TableService.java
  18. +307 −0 ...-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/AtomReaderWriter.java
  19. +65 −0 .../main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConterter.java
  20. +40 −0 ...c/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultXMLStreamFactory.java
  21. +168 −0 ...-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/HttpReaderWriter.java
  22. +38 −0 ...src/main/java/com/microsoft/windowsazure/services/table/implementation/InputStreamDataSource.java
  23. +147 −0 ...-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/MimeReaderWriter.java
  24. +90 −0 ...e-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/SharedKeyFilter.java
  25. +26 −0 ...i/src/main/java/com/microsoft/windowsazure/services/table/implementation/SharedKeyLiteFilter.java
  26. +491 −0 ...c/main/java/com/microsoft/windowsazure/services/table/implementation/TableExceptionProcessor.java
  27. +767 −0 ...re-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableRestProxy.java
  28. +13 −0 ...-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/XMLStreamFactory.java
  29. +208 −0 ...oft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/BatchOperations.java
  30. +65 −0 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/BatchResult.java
  31. +34 −0 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/BinaryFilter.java
  32. +14 −0 ...soft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/ConstantFilter.java
  33. +21 −0 ...azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/DeleteEntityOptions.java
  34. +12 −0 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/EdmType.java
  35. +77 −0 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/Entity.java
  36. +51 −0 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/Filter.java
  37. +13 −0 ...oft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/GetEntityResult.java
  38. +27 −0 ...pi/src/main/java/com/microsoft/windowsazure/services/table/models/GetServicePropertiesResult.java
  39. +13 −0 ...soft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/GetTableResult.java
  40. +13 −0 ...-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/InsertEntityResult.java
  41. +20 −0 ...t-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/ListTablesOptions.java
  42. +14 −0 ...soft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/LitteralFilter.java
  43. +24 −0 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/Property.java
  44. +67 −0 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/Query.java
  45. +40 −0 ...zure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryEntitiesOptions.java
  46. +34 −0 ...azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryEntitiesResult.java
  47. +30 −0 ...-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryTablesOptions.java
  48. +24 −0 ...t-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryTablesResult.java
  49. +14 −0 ...oft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/RawStringFilter.java
  50. +161 −0 ...t-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/ServiceProperties.java
  51. +13 −0 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/TableEntry.java
  52. +29 −0 ...azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/TableServiceOptions.java
  53. +24 −0 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/UnaryFilter.java
  54. +13 −0 ...-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/UpdateEntityResult.java
  55. +1 −0 ...api/src/main/resources/META-INF/services/com.microsoft.windowsazure.services.core.Builder$Exports
  56. +51 −0 .../test/java/com/microsoft/windowsazure/services/blob/implementation/ISO8601DateConverterTests.java
  57. +43 −0 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/IntegrationTestBase.java
  58. +913 −0 ...zure-api/src/test/java/com/microsoft/windowsazure/services/table/TableServiceIntegrationTest.java
  59. +80 −0 ...src/test/java/com/microsoft/windowsazure/services/table/implementation/AtomReaderWriterTests.java
  60. +336 −0 ...pi/src/test/java/com/microsoft/windowsazure/services/table/implementation/MimeMultipartTests.java
  61. +4 −1 microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties
@@ -80,6 +80,11 @@
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
+ <dependency>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ <version>1.4</version>
+ </dependency>
</dependencies>
<build>
@@ -2,20 +2,21 @@
* Copyright 2011 Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this 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;
import com.microsoft.windowsazure.services.blob.implementation.BlobExceptionProcessor;
import com.microsoft.windowsazure.services.blob.implementation.BlobRestProxy;
+import com.microsoft.windowsazure.services.blob.implementation.ISO8601DateConverter;
import com.microsoft.windowsazure.services.blob.implementation.SharedKeyFilter;
import com.microsoft.windowsazure.services.blob.implementation.SharedKeyLiteFilter;
import com.microsoft.windowsazure.services.core.Builder;
@@ -28,5 +29,6 @@ public void register(Builder.Registry registry) {
registry.add(BlobRestProxy.class);
registry.add(SharedKeyLiteFilter.class);
registry.add(SharedKeyFilter.class);
+ registry.add(ISO8601DateConverter.class);
}
}
@@ -69,10 +69,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.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.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;
@@ -155,18 +155,18 @@ private Builder addOptionalSourceAccessContitionHeader(Builder builder, AccessCo
}
private WebResource addOptionalBlobListingIncludeQueryParam(ListBlobsOptions options, WebResource webResource) {
- EnumCommaStringBuilder sb = new EnumCommaStringBuilder();
+ CommaStringBuilder sb = new CommaStringBuilder();
sb.addValue(options.isIncludeSnapshots(), "snapshots");
sb.addValue(options.isIncludeUncommittedBlobs(), "uncommittedblobs");
sb.addValue(options.isIncludeMetadata(), "metadata");
- webResource = addOptionalQueryParam(webResource, "include", sb.getValue());
+ webResource = addOptionalQueryParam(webResource, "include", sb.toString());
return webResource;
}
private WebResource addOptionalContainerIncludeQueryParam(ListContainersOptions options, WebResource webResource) {
- EnumCommaStringBuilder sb = new EnumCommaStringBuilder();
+ CommaStringBuilder sb = new CommaStringBuilder();
sb.addValue(options.isIncludeMetadata(), "metadata");
- webResource = addOptionalQueryParam(webResource, "include", sb.getValue());
+ webResource = addOptionalQueryParam(webResource, "include", sb.toString());
return webResource;
}
@@ -25,11 +25,11 @@
@Override
public Date unmarshal(String arg0) throws Exception {
- return new ContainerACLDateConverter().parse(arg0);
+ return new ISO8601DateConverter().parse(arg0);
}
@Override
public String marshal(Date arg0) throws Exception {
- return new ContainerACLDateConverter().format(arg0);
+ return new ISO8601DateConverter().format(arg0);
}
}
@@ -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;
- }
-}
@@ -0,0 +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.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 ISO8601DateConverter {
+ // 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'";
+ private static final String SHORT_DATETIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'";
+
+ public String format(Date date) {
+ return getFormat().format(date);
+ }
+
+ public Date parse(String date) throws ParseException {
+ if (date == null)
+ return null;
+
+ // Sometimes, the date comes back without the ".SSSSSSS" part (presumably when the decimal value
+ // of the date is "0". Use the short format in that case.
+ if (date.indexOf('.') < 0)
+ return getShortFormat().parse(date);
+ else
+ return getFormat().parse(date);
+ }
+
+ private DateFormat getFormat() {
+ DateFormat iso8601Format = new SimpleDateFormat(DATETIME_PATTERN, Locale.US);
+ iso8601Format.setTimeZone(TimeZone.getTimeZone("GMT"));
+ return iso8601Format;
+ }
+
+ private DateFormat getShortFormat() {
+ DateFormat iso8601Format = new SimpleDateFormat(SHORT_DATETIME_PATTERN, Locale.US);
+ iso8601Format.setTimeZone(TimeZone.getTimeZone("GMT"));
+ return iso8601Format;
+ }
+}
@@ -2,15 +2,15 @@
* Copyright 2011 Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.microsoft.windowsazure.services.blob.implementation;
@@ -44,6 +44,18 @@ public SharedKeyFilter(@Named(BlobConfiguration.ACCOUNT_NAME) String accountName
this.signer = new HmacSHA256Sign(accountKey);
}
+ protected String getHeader(ClientRequest cr, String headerKey) {
+ return SharedKeyUtils.getHeader(cr, headerKey);
+ }
+
+ protected HmacSHA256Sign getSigner() {
+ return signer;
+ }
+
+ protected String getAccountName() {
+ return accountName;
+ }
+
@Override
public ClientResponse handle(ClientRequest cr) throws ClientHandlerException {
// Only sign if no other filter is handling authorization
@@ -60,6 +72,7 @@ public ClientResponse handle(ClientRequest cr) throws ClientHandlerException {
return this.getNext().handle(cr);
}
+ @Override
public void onBeforeStreamingEntity(ClientRequest clientRequest) {
// All headers should be known at this point, time to sign!
sign(clientRequest);
@@ -105,11 +118,11 @@ public void sign(ClientRequest cr) {
cr.getHeaders().putSingle("Authorization", "SharedKey " + this.accountName + ":" + signature);
}
- private void addOptionalDateHeader(ClientRequest cr) {
+ protected void addOptionalDateHeader(ClientRequest cr) {
String date = getHeader(cr, "Date");
if (date == "") {
date = new RFC1123DateConverter().format(new Date());
- cr.getHeaders().add("Date", date);
+ cr.getHeaders().putSingle("Date", date);
}
}
@@ -209,8 +222,4 @@ private String getCanonicalizedResource(ClientRequest cr) {
return result;
}
-
- private String getHeader(ClientRequest cr, String headerKey) {
- return SharedKeyUtils.getHeader(cr, headerKey);
- }
}
@@ -2,15 +2,15 @@
* Copyright 2011 Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.microsoft.windowsazure.services.blob.implementation;
@@ -59,6 +59,7 @@ public ClientResponse handle(ClientRequest cr) throws ClientHandlerException {
return this.getNext().handle(cr);
}
+ @Override
public void onBeforeStreamingEntity(ClientRequest clientRequest) {
// All headers should be known at this point, time to sign!
sign(clientRequest);
@@ -0,0 +1,47 @@
+package com.microsoft.windowsazure.services.core.utils;
+
+import java.util.List;
+
+public class CommaStringBuilder {
+ 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 static String join(List<String> values) {
+ CommaStringBuilder sb = new CommaStringBuilder();
+
+ for (String value : values) {
+ sb.add(value);
+ }
+
+ return sb.toString();
+ }
+
+ public static String join(String... values) {
+ CommaStringBuilder sb = new CommaStringBuilder();
+
+ for (String value : values) {
+ sb.add(value);
+ }
+
+ return sb.toString();
+ }
+
+ @Override
+ public String toString() {
+ if (sb.length() == 0)
+ return null;
+ return sb.toString();
+ }
+}
Oops, something went wrong.

0 comments on commit 2c2ca7e

Please sign in to comment.