Skip to content

Commit

Permalink
Merge pull request #295 from WindowsAzure/release
Browse files Browse the repository at this point in the history
Merge release to mater
  • Loading branch information
Albert Cheng committed Mar 14, 2013
2 parents a809d3c + e92621b commit fb2b701
Show file tree
Hide file tree
Showing 124 changed files with 2,473 additions and 645 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.project
target
node_modules
.idea
*.iml
20 changes: 17 additions & 3 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
2013.1.18 Version 0.4.0
2013.03.12 Version 0.4.1
* Added "Azure-SDK-For-Java/<version>" To User-Agent HTTP header
* Added connection string support for Service Bus
* Added new methods to break lease for Storage Blob which doesn't require a lease id and returns the result as an object. Deprecated the old breakLease() methods.
* Added a new method to get the historical events for Media Services
* Fixed Storage Table encoding issue for special characters
* BlobOutputStream now commits block list using LATEST instead of UNCOMMITTED
* Added RequestResult to StorageEvents
* Fixed issue when accessing OperationContext RequestResults
* Fixed the return value of BlobInputStream.read
* Fixed CloudPageBlob.downloadPageRanges to retrieve the blob length
* Fixed MD5 validation in BlobInputStream
* Return ETag in TableResult not only for Insert but also for other operations

2013.01.18 Version 0.4.0
* 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
* Added a Sending Request Event to OperationContext in Storage Client code
* Fixed 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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ For documentation please see the [Windows Azure Java Developer Center](http://ww
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/microsoft-azure-api/
mvn compile

###Option 2: Via Maven
Expand All @@ -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.4.0</version>
<version>0.4.1</version>
</dependency>

##Minimum Requirements
Expand Down
4 changes: 2 additions & 2 deletions microsoft-azure-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.microsoft.windowsazure</groupId>
<artifactId>microsoft-windowsazure-api</artifactId>
<version>0.4.0</version>
<version>0.4.1</version>
<packaging>jar</packaging>

<name>Microsoft Windows Azure Client API</name>
Expand Down Expand Up @@ -171,7 +171,7 @@
<configuration>
<excludePackageNames>*.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization</excludePackageNames>
<bottom><![CDATA[<code>/**
<br/>* Copyright 2011 Microsoft Corporation
<br/>* Copyright Microsoft Corporation
<br/>*
<br/>* Licensed under the Apache License, Version 2.0 (the "License");
<br/>* you may not use this file except in compliance with the License.
Expand Down
6 changes: 5 additions & 1 deletion microsoft-azure-api/src/config/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,11 @@

<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MagicNumber"/>
<module name="MagicNumber">
<!-- Updated on 01/23/2013: -->
<!-- Added ignore list, to keep enums from triggering violations -->
<property name="ignoreNumbers" value="0, 1, 2, 3, 4, 5, 6, 7, 8"/>
</module>
<module name="MissingSwitchDefault"/>
<module name="RedundantThrows"/>
<module name="SimplifyBooleanExpression"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,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
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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.serviceruntime;

Expand Down Expand Up @@ -50,7 +50,6 @@ public final class RoleEnvironment {
JAXBContext.newInstance(RoleEnvironment.class.getPackage().getName());
}
catch (JAXBException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
clientId = UUID.randomUUID().toString();
Expand Down Expand Up @@ -93,6 +92,7 @@ private static synchronized void initialize() {
lastState = new AtomicReference<CurrentState>();

runtimeClient.addGoalStateChangedListener(new GoalStateChangedListener() {
@Override
public void goalStateChanged(GoalState newGoalState) {
switch (newGoalState.getExpectedState()) {
case STARTED:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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.BreakLeaseResult;
import com.microsoft.windowsazure.services.blob.models.CommitBlobBlocksOptions;
import com.microsoft.windowsazure.services.blob.models.ContainerACL;
import com.microsoft.windowsazure.services.blob.models.CopyBlobOptions;
Expand Down Expand Up @@ -1440,16 +1441,23 @@ void releaseLease(String container, String blob, String leaseId, BlobServiceOpti
* <p>
* A lease that has been broken but has not yet expired can also be released, in which case another client may
* immediately acquire a new lease on the blob.
*
*
* @deprecated Server ignores the leaseId parameter, replaced by {@link #breakLease(String, String)} without
* the useless parameter.
*
* @param container
* A {@link String} containing the name of the blob's container.
* @param blob
* A {@link String} containing the name of the blob to break a lease on.
* @param leaseId
* A {@link String} containing an optional lease ID.
*
* @param leaseId lease id to break. Ignored.
*
* @throws ServiceException
* if an error occurs accessing the storage service.
*
* @return result containing time remaining before a new lease can be acquired
*/
@Deprecated()
void breakLease(String container, String blob, String leaseId) throws ServiceException;

/**
Expand All @@ -1465,17 +1473,78 @@ void releaseLease(String container, String blob, String leaseId, BlobServiceOpti
* <p>
* A lease that has been broken but has not yet expired can also be released, in which case another client may
* immediately acquire a new lease on the blob.
*
*
* @deprecated Server ignores the leaseId parameter, replaced by
* {@link #breakLease(String, String, com.microsoft.windowsazure.services.blob.models.BlobServiceOptions)}
* without the useless parameter.
*
*
* @param container
* A {@link String} containing the name of the blob's container.
* @param blob
* A {@link String} containing the name of the blob to break a lease on.
* @param leaseId
* A {@link String} containing an optional lease ID.
* @param options
* A {@link BlobServiceOptions} instance containing options for the request.
* A {@link com.microsoft.windowsazure.services.blob.models.BlobServiceOptions} instance containing options for the request.
* @param leaseId lease id to break. Ignored.
*
* @throws ServiceException
* if an error occurs accessing the storage service.
* @return result containing time remaining before a new lease can be acquired
*/
@Deprecated()
void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException;

/**
* Breaks an active lease on a blob.
* <p>
* This method breaks the lease on the blob specified by the <em>blob</em> and <em>container</em> parameters. The
* <em>leaseId</em> parameter is not used by the server.
* <p>
* Once a lease is broken, it cannot be renewed. Any authorized request can break the lease; the request is not
* required to specify a matching lease ID. When a lease is broken, the remaining time on the lease is allowed to
* elapse, during which time no lease operation may be performed on the blob.
* <p>
* A lease that has been broken but has not yet expired can also be released, in which case another client may
* immediately acquire a new lease on the blob.
*
*
*
* @param container
* A {@link String} containing the name of the blob's container.
* @param blob
* A {@link String} containing the name of the blob to break a lease on.
* @throws ServiceException
* if an error occurs accessing the storage service.
*
* @return result containing time remaining before a new lease can be acquired
*/
BreakLeaseResult breakLease(String container, String blob) throws ServiceException;

/**
* Breaks an active lease on a blob, using the specified options.
* <p>
* This method breaks the lease on the blob specified by the <em>blob</em> and <em>container</em> parameters. The
* <em>leaseId</em> parameter is not used by the server. Use the {@link BlobServiceOptions options} parameter to
* specify the server timeout for the operation.
* <p>
* Once a lease is broken, it cannot be renewed. Any authorized request can break the lease; the request is not
* required to specify a matching lease ID. When a lease is broken, the remaining time on the lease is allowed to
* elapse, during which time no lease operation may be performed on the blob.
* <p>
* A lease that has been broken but has not yet expired can also be released, in which case another client may
* immediately acquire a new lease on the blob.
*
*
*
* @param container
* A {@link String} containing the name of the blob's container.
* @param blob
* A {@link String} containing the name of the blob to break a lease on.
* @param options
* A {@link com.microsoft.windowsazure.services.blob.models.BlobServiceOptions} instance containing options for the request.
* @throws ServiceException
* if an error occurs accessing the storage service.
* @return result containing time remaining before a new lease can be acquired
*/
BreakLeaseResult breakLease(String container, String blob, BlobServiceOptions options) throws ServiceException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.microsoft.windowsazure.services.blob.implementation.SharedKeyFilter;
import com.microsoft.windowsazure.services.blob.implementation.SharedKeyLiteFilter;
import com.microsoft.windowsazure.services.core.Builder;
import com.microsoft.windowsazure.services.core.UserAgentFilter;

public class Exports implements Builder.Exports {
@Override
Expand All @@ -30,5 +31,6 @@ public void register(Builder.Registry registry) {
registry.add(SharedKeyLiteFilter.class);
registry.add(SharedKeyFilter.class);
registry.add(ISO8601DateConverter.class);
registry.add(UserAgentFilter.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void setLeaseStatus(final LeaseStatus leaseStatus) {
/**
* Sets the lease status on the container. Reserved for internal use.
*
* @param LeaseState
* @param leaseState
* The lease state to set, as a <code>LeaseState</code> object.
*/
public void setLeaseState(final LeaseState leaseState) {
Expand All @@ -141,7 +141,7 @@ public void setLeaseState(final LeaseState leaseState) {
/**
* Sets the lease duration on the container. Reserved for internal use.
*
* @param LeaseDuration
* @param leaseDuration
* The lease duration to set, as a <code>LeaseDuration</code> object.
*/
public void setLeaseDuration(final LeaseDuration leaseDuration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ public final class BlobInputStream extends InputStream {
*/
private boolean validateBlobMd5;

/**
* Holds the Blob MD5.
*/
private final String retrievedContentMD5Value;

/**
* Holds the reference to the current buffered data.
*/
Expand Down Expand Up @@ -161,11 +166,11 @@ protected BlobInputStream(final CloudBlob parentBlob, final AccessCondition acce

final HttpURLConnection attributesRequest = this.opContext.getCurrentRequestObject();

final String retrievedContentMD5Value = attributesRequest.getHeaderField(Constants.HeaderConstants.CONTENT_MD5);
this.retrievedContentMD5Value = attributesRequest.getHeaderField(Constants.HeaderConstants.CONTENT_MD5);

// Will validate it if it was returned
this.validateBlobMd5 = !options.getDisableContentMD5Validation()
&& !Utility.isNullOrEmpty(retrievedContentMD5Value);
&& !Utility.isNullOrEmpty(this.retrievedContentMD5Value);

// Validates the first option, and sets future requests to use if match
// request option.
Expand Down Expand Up @@ -395,8 +400,17 @@ public boolean markSupported() {
@DoesServiceRequest
public int read() throws IOException {
final byte[] tBuff = new byte[1];
this.read(tBuff, 0, 1);
return tBuff[0];
final int numberOfBytesRead = this.read(tBuff, 0, 1);

if (numberOfBytesRead > 0) {
return tBuff[0] & 0xFF;
}
else if (numberOfBytesRead == 0) {
throw new IOException("Unexpected error. Stream returned unexpected number of bytes.");
}
else {
return -1;
}
}

/**
Expand Down Expand Up @@ -519,13 +533,13 @@ private synchronized int readInternal(final byte[] b, final int off, int len) th
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())) {
if (!calculatedMd5.equals(this.retrievedContentMD5Value)) {
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),
this.retrievedContentMD5Value, calculatedMd5),
Constants.HeaderConstants.HTTP_UNUSED_306, null, null));
this.streamFaulted = true;
throw this.lastError;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ private synchronized void dispatchWrite(final int writeLength) throws IOExceptio
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));
this.blockList.add(new BlockEntry(blockID, BlockSearchMode.LATEST));

worker = new Callable<Void>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public void setLeaseStatus(final LeaseStatus leaseStatus) {
/**
* Sets the lease state for the blob. Reserved for internal use.
*
* @param LeaseState
* @param leaseState
* The lease state to set, represented by a <code>LeaseState</code> object.
*/
public void setLeaseState(final LeaseState leaseState) {
Expand All @@ -344,7 +344,7 @@ public void setLeaseState(final LeaseState leaseState) {
/**
* Sets the lease duration for the blob. Reserved for internal use.
*
* @param LeaseDuration
* @param leaseDuration
* The lease duration value to set, represented by a <code>LeaseDuration</code> object.
*/
public void setLeaseDuration(final LeaseDuration leaseDuration) {
Expand Down
Loading

0 comments on commit fb2b701

Please sign in to comment.