Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #195 from pemari-msft/master
Browse files Browse the repository at this point in the history
Storage Client Library 6.1.0
  • Loading branch information
pemari-msft committed Oct 30, 2015
2 parents 0d3f40a + d4284ed commit 54f2a6b
Show file tree
Hide file tree
Showing 59 changed files with 2,913 additions and 354 deletions.
4 changes: 4 additions & 0 deletions AspNet_k.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.22512.0
VisualStudioVersion = 14.0.22122.0
VisualStudioVersion = 14.0.22807.0
MinimumVisualStudioVersion = 10.0.40219.1
Expand All @@ -13,6 +14,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
global.json = global.json
Nuget.config = Nuget.config
EndProjectSection
ProjectSection(FolderGlobals) = preProject
global_1json__JSONSchema = http://json.schemastore.org/global
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.WindowsAzure.Storage", "Lib\AspNet\Microsoft.WindowsAzure.Storage\Microsoft.WindowsAzure.Storage.xproj", "{10851280-F6EA-4988-80B0-4B0CAEE23196}"
EndProject
Expand Down
10 changes: 5 additions & 5 deletions BuildAspNetK.cmd
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pushd %~dp0
call Tools\nuget.exe install dnx-coreclr-win-x86 -Version 1.0.0-beta7 -Prerelease
call Tools\nuget.exe install dnx-clr-win-x86 -Version 1.0.0-beta7 -Prerelease
call dnx-coreclr-win-x86.1.0.0-beta7\bin\dnu restore
call dnx-clr-win-x86.1.0.0-beta7\bin\dnu restore
call Tools\nuget.exe install dnx-coreclr-win-x86 -Version 1.0.0-beta8 -Prerelease
call Tools\nuget.exe install dnx-clr-win-x86 -Version 1.0.0-beta8 -Prerelease
call dnx-coreclr-win-x86.1.0.0-beta8\bin\dnu restore
call dnx-clr-win-x86.1.0.0-beta8\bin\dnu restore
cd Lib\AspNet\Microsoft.WindowsAzure.Storage
call ..\..\..\dnx-coreclr-win-x86.1.0.0-beta7\bin\dnu build --configuration release
call ..\..\..\dnx-coreclr-win-x86.1.0.0-beta8\bin\dnu build --configuration release
popd
6 changes: 3 additions & 3 deletions Lib/AspNet/Microsoft.WindowsAzure.Storage/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("6.0.1.0")]
[assembly: AssemblyFileVersion("6.0.1.0")]
[assembly: AssemblyInformationalVersion("6.0.1.0-preview")]
[assembly: AssemblyVersion("6.1.1.0")]
[assembly: AssemblyFileVersion("6.1.1.0")]
[assembly: AssemblyInformationalVersion("6.1.1.0-preview")]

[assembly: InternalsVisibleTo("Microsoft.WindowsAzure.Storage.Test")]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata minClientVersion="2.8.3">
<id>WindowsAzure.Storage</id>
<version>6.0.1-preview</version>
<version>6.1.1-preview</version>
<title>Windows Azure Storage</title>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
Expand Down
2 changes: 1 addition & 1 deletion Lib/AspNet/Microsoft.WindowsAzure.Storage/project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "6.0.1.0",
"version": "6.1.1.0",
"authors": [ "Microsoft Corporation" ],
"description": "Azure Storage SDK for ASP.NET 5 Preview",
"dependencies": {
Expand Down
14 changes: 14 additions & 0 deletions Lib/ClassLibraryCommon/Blob/BlobEncryptionPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,5 +246,19 @@ internal ICryptoTransform CreateAndSetEncryptionContext(IDictionary<string, stri
return aesProvider.CreateEncryptor();
}
}

internal long GetEncryptedLength(long unencryptedLength, bool noPadding)
{
// Note that this will only work for the AES_CBC_256 alrogithm we're currently using - if we change algorithms,
// or give the user a choice, we'll need to change this code appropriately.
if (noPadding)
{
return unencryptedLength;
}
else
{
return unencryptedLength + (16 - (unencryptedLength % 16));
}
}
}
}
358 changes: 229 additions & 129 deletions Lib/ClassLibraryCommon/Blob/CloudBlockBlob.cs

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions Lib/ClassLibraryCommon/Table/TableBatchOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,16 @@ public sealed partial class TableBatchOperation : IList<TableOperation>
/// </summary>
/// <typeparam name="TElement">The class of type for the entity to retrieve.</typeparam>
/// <param name="partitionKey">A string containing the partition key of the entity to retrieve.</param>
/// <param name="rowKey">A string containing the row key of the entity to retrieve.</param>
/// <param name="rowKey">A string containing the row key of the entity to retrieve.</param>
/// <param name="selectedColumns">List of column names for projection.</param>
[SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "Reviewed.")]
public void Retrieve<TElement>(string partitionKey, string rowKey) where TElement : ITableEntity
public void Retrieve<TElement>(string partitionKey, string rowKey, List<string> selectedColumns = null) where TElement : ITableEntity
{
CommonUtility.AssertNotNull("partitionKey", partitionKey);
CommonUtility.AssertNotNull("rowkey", rowKey);

// Add the table operation.
this.Add(new TableOperation(null /* entity */, TableOperationType.Retrieve) { RetrievePartitionKey = partitionKey, RetrieveRowKey = rowKey, RetrieveResolver = (pk, rk, ts, prop, etag) => EntityUtilities.ResolveEntityByType<TElement>(pk, rk, ts, prop, etag) });
this.Add(new TableOperation(null /* entity */, TableOperationType.Retrieve) { RetrievePartitionKey = partitionKey, RetrieveRowKey = rowKey, SelectColumns = selectedColumns, RetrieveResolver = (pk, rk, ts, prop, etag) => EntityUtilities.ResolveEntityByType<TElement>(pk, rk, ts, prop, etag) });
}

/// <summary>
Expand All @@ -58,13 +59,14 @@ public void Retrieve<TElement>(string partitionKey, string rowKey) where TElemen
/// <param name="partitionKey">A string containing the partition key of the entity to retrieve.</param>
/// <param name="rowKey">A string containing the row key of the entity to retrieve.</param>
/// <param name="resolver">The <see cref="EntityResolver{TResult}"/> implementation to project the entity to retrieve as a particular type in the result.</param>
public void Retrieve<TResult>(string partitionKey, string rowKey, EntityResolver<TResult> resolver)
/// <param name="selectedColumns">List of column names for projection.</param>
public void Retrieve<TResult>(string partitionKey, string rowKey, EntityResolver<TResult> resolver, List<string> selectedColumns = null)
{
CommonUtility.AssertNotNull("partitionKey", partitionKey);
CommonUtility.AssertNotNull("rowkey", rowKey);

// Add the table operation.
this.Add(new TableOperation(null /* entity */, TableOperationType.Retrieve) { RetrievePartitionKey = partitionKey, RetrieveRowKey = rowKey, RetrieveResolver = (pk, rk, ts, prop, etag) => resolver(pk, rk, ts, prop, etag) });
this.Add(new TableOperation(null /* entity */, TableOperationType.Retrieve) { RetrievePartitionKey = partitionKey, RetrieveRowKey = rowKey, SelectColumns = selectedColumns, RetrieveResolver = (pk, rk, ts, prop, etag) => resolver(pk, rk, ts, prop, etag) });
}

#endregion
Expand Down
13 changes: 13 additions & 0 deletions Lib/ClassLibraryCommon/Table/TableOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace Microsoft.WindowsAzure.Storage.Table
using Microsoft.WindowsAzure.Storage.Core;
using Microsoft.WindowsAzure.Storage.Core.Executor;
using Microsoft.WindowsAzure.Storage.Core.Util;
using Microsoft.WindowsAzure.Storage.Shared.Protocol;
using Microsoft.WindowsAzure.Storage.Table.Protocol;
using System;
using System.IO;
Expand Down Expand Up @@ -201,6 +202,18 @@ private static RESTCommand<TableResult> RetrieveImpl(TableOperation operation, C
requestOptions.ApplyToStorageCommand(retrieveCmd);

TableResult result = new TableResult();
if (operation.SelectColumns != null && operation.SelectColumns.Count > 0)
{
// If encryption policy is set, then add the encryption metadata column to Select columns in order to be able to decrypt properties.
if (requestOptions.EncryptionPolicy != null)
{
operation.SelectColumns.Add(Constants.EncryptionConstants.TableEncryptionKeyDetails);
operation.SelectColumns.Add(Constants.EncryptionConstants.TableEncryptionPropertyDetails);
}

retrieveCmd.Builder = operation.GenerateQueryBuilder();
}

retrieveCmd.CommandLocationMode = operation.isPrimaryOnlyRetrieve ? CommandLocationMode.PrimaryOnly : CommandLocationMode.PrimaryOrSecondary;
retrieveCmd.RetrieveResponseStream = true;
retrieveCmd.SignRequest = client.AuthenticationHandler.SignRequest;
Expand Down
2 changes: 1 addition & 1 deletion Lib/ClassLibraryCommon/Table/TableQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ private static RESTCommand<TableQuerySegment<RESULT_TYPE>> QueryImpl<T, RESULT_T
requestOptions.AssertPolicyIfRequired();

// If encryption policy is set, then add the encryption metadata column to Select columns in order to be able to decrypt properties.
if (requestOptions.EncryptionPolicy != null && query.SelectColumns != null)
if (requestOptions.EncryptionPolicy != null && query.SelectColumns != null && query.SelectColumns.Count() > 0)
{
query.SelectColumns.Add(Constants.EncryptionConstants.TableEncryptionKeyDetails);
query.SelectColumns.Add(Constants.EncryptionConstants.TableEncryptionPropertyDetails);
Expand Down
4 changes: 2 additions & 2 deletions Lib/Common/Shared/Protocol/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -786,9 +786,9 @@ static HeaderConstants()
/// Specifies the value to use for UserAgent header.
/// </summary>
#if ASPNET_K || PORTABLE
public const string UserAgentProductVersion = "6.0.1-preview";
public const string UserAgentProductVersion = "6.1.1-preview";
#else
public const string UserAgentProductVersion = "6.0.0";
public const string UserAgentProductVersion = "6.1.0";
#endif

/// <summary>
Expand Down
80 changes: 74 additions & 6 deletions Lib/Common/Table/TableOperation.Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace Microsoft.WindowsAzure.Storage.Table
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Text;

/// <summary>
/// Represents a single table operation.
Expand Down Expand Up @@ -112,6 +113,11 @@ internal Func<string, string, DateTimeOffset, IDictionary<string, EntityProperty
/// </summary>
internal bool EchoContent { get; set; }

/// <summary>
/// List of columns to project with for the retrieve operation.
/// </summary>
internal List<string> SelectColumns { get; set; }

/// <summary>
/// Creates a new table operation that deletes the given entity
/// from a table.
Expand Down Expand Up @@ -240,13 +246,14 @@ public static TableOperation Replace(ITableEntity entity)
/// </summary>
/// <typeparam name="TElement">The class of type for the entity to retrieve.</typeparam>
/// <param name="partitionKey">A string containing the partition key of the entity to retrieve.</param>
/// <param name="rowkey">A string containing the row key of the entity to retrieve.</param>
/// <param name="rowkey">A string containing the row key of the entity to retrieve.</param>
/// <param name="selectColumns">List of column names for projection.</param>
/// <returns>The <see cref="TableOperation"/> object.</returns>
[SuppressMessage("Microsoft.Design",
"CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "Reviewed")]
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "rowkey",
Justification = "Reviewed : towkey is acceptable.")]
public static TableOperation Retrieve<TElement>(string partitionKey, string rowkey)
public static TableOperation Retrieve<TElement>(string partitionKey, string rowkey, List<string> selectColumns = null)
where TElement : ITableEntity
{
CommonUtility.AssertNotNull("partitionKey", partitionKey);
Expand All @@ -257,6 +264,7 @@ public static TableOperation Retrieve<TElement>(string partitionKey, string rowk
{
RetrievePartitionKey = partitionKey,
RetrieveRowKey = rowkey,
SelectColumns = selectColumns,
RetrieveResolver =
(pk, rk, ts, prop, etag) => EntityUtilities.ResolveEntityByType<TElement>(
pk,
Expand All @@ -276,15 +284,16 @@ public static TableOperation Retrieve<TElement>(string partitionKey, string rowk
/// <param name="partitionKey">A string containing the partition key of the entity to retrieve.</param>
/// <param name="rowkey">A string containing the row key of the entity to retrieve.</param>
/// <param name="resolver">The <see cref="EntityResolver{TResult}"/> implementation to project the entity to retrieve as a particular type in the result.</param>
/// <param name="selectedColumns">List of column names for projection.</param>
/// <returns>The <see cref="TableOperation"/> object.</returns>
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "rowkey", Justification = "Reviewed : rowkey is acceptable.")]
public static TableOperation Retrieve<TResult>(string partitionKey, string rowkey, EntityResolver<TResult> resolver)
public static TableOperation Retrieve<TResult>(string partitionKey, string rowkey, EntityResolver<TResult> resolver, List<string> selectedColumns = null)
{
CommonUtility.AssertNotNull("partitionKey", partitionKey);
CommonUtility.AssertNotNull("rowkey", rowkey);

// Create and return the table operation.
return new TableOperation(null /* entity */, TableOperationType.Retrieve) { RetrievePartitionKey = partitionKey, RetrieveRowKey = rowkey, RetrieveResolver = (pk, rk, ts, prop, etag) => resolver(pk, rk, ts, prop, etag) };
return new TableOperation(null /* entity */, TableOperationType.Retrieve) { RetrievePartitionKey = partitionKey, RetrieveRowKey = rowkey, RetrieveResolver = (pk, rk, ts, prop, etag) => resolver(pk, rk, ts, prop, etag), SelectColumns = selectedColumns };
}

/// <summary>
Expand All @@ -293,15 +302,16 @@ public static TableOperation Retrieve<TResult>(string partitionKey, string rowke
/// </summary>
/// <param name="partitionKey">A string containing the partition key of the entity to be retrieved.</param>
/// <param name="rowkey">A string containing the row key of the entity to be retrieved.</param>
/// <param name="selectedColumns">List of column names for projection.</param>
/// <returns>The <see cref="TableOperation"/> object.</returns>
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "rowkey", Justification = "Reviewed : rowkey is allowed.")]
public static TableOperation Retrieve(string partitionKey, string rowkey)
public static TableOperation Retrieve(string partitionKey, string rowkey, List<string> selectedColumns = null)
{
CommonUtility.AssertNotNull("partitionKey", partitionKey);
CommonUtility.AssertNotNull("rowkey", rowkey);

// Create and return the table operation.
return new TableOperation(null /* entity */, TableOperationType.Retrieve) { RetrievePartitionKey = partitionKey, RetrieveRowKey = rowkey };
return new TableOperation(null /* entity */, TableOperationType.Retrieve) { RetrievePartitionKey = partitionKey, RetrieveRowKey = rowkey, SelectColumns = selectedColumns };
}

private static object DynamicEntityResolver(string partitionKey, string rowKey, DateTimeOffset timestamp, IDictionary<string, EntityProperty> properties, string etag)
Expand Down Expand Up @@ -357,5 +367,63 @@ internal Uri GenerateRequestURI(Uri uri, string tableName)
return NavigationHelper.AppendPathToSingleUri(uri, string.Format(CultureInfo.InvariantCulture, "{0}({1})", tableName, identity));
}
}

internal UriQueryBuilder GenerateQueryBuilder()
{
UriQueryBuilder builder = new UriQueryBuilder();

// select
if (this.SelectColumns != null && this.SelectColumns.Count > 0)
{
StringBuilder colBuilder = new StringBuilder();
bool foundRk = false;
bool foundPk = false;
bool foundTs = false;

for (int m = 0; m < this.SelectColumns.Count; m++)
{
if (this.SelectColumns[m] == TableConstants.PartitionKey)
{
foundPk = true;
}
else if (this.SelectColumns[m] == TableConstants.RowKey)
{
foundRk = true;
}
else if (this.SelectColumns[m] == TableConstants.Timestamp)
{
foundTs = true;
}

colBuilder.Append(this.SelectColumns[m]);
if (m < this.SelectColumns.Count - 1)
{
colBuilder.Append(",");
}
}

if (!foundPk)
{
colBuilder.Append(",");
colBuilder.Append(TableConstants.PartitionKey);
}

if (!foundRk)
{
colBuilder.Append(",");
colBuilder.Append(TableConstants.RowKey);
}

if (!foundTs)
{
colBuilder.Append(",");
colBuilder.Append(TableConstants.Timestamp);
}

builder.Add(TableConstants.Select, colBuilder.ToString());
}

return builder;
}
}
}
5 changes: 3 additions & 2 deletions Lib/Common/Table/TableQuery.Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ private static string GenerateFilterCondition(string propertyName, string operat
}
else if (edmType == EdmType.Double)
{
bool decimalExists = givenValue.Contains(".");
valueOperand = decimalExists ? givenValue : string.Format(CultureInfo.InvariantCulture, "{0}.0", givenValue);
int parsedInt;
bool isInteger = int.TryParse(givenValue, out parsedInt);
valueOperand = isInteger ? string.Format(CultureInfo.InvariantCulture, "{0}.0", givenValue) : givenValue;
}
else if (edmType == EdmType.Int64)
{
Expand Down
6 changes: 3 additions & 3 deletions Lib/Portable/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("6.0.1.0")]
[assembly: AssemblyFileVersion("6.0.1.0")]
[assembly: AssemblyInformationalVersion("6.0.1.0-preview")]
[assembly: AssemblyVersion("6.1.1.0")]
[assembly: AssemblyFileVersion("6.1.1.0")]
[assembly: AssemblyInformationalVersion("6.1.1.0-preview")]
Loading

0 comments on commit 54f2a6b

Please sign in to comment.