Skip to content

Commit

Permalink
Merge pull request Azure#151 from WindowsAzure/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
joostdenijs committed Sep 19, 2012
2 parents 815058a + be59df0 commit da5d538
Show file tree
Hide file tree
Showing 40 changed files with 1,242 additions and 407 deletions.
11 changes: 11 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2012.09.11 Version 0.3.1
* Added Javadocs to 1.7 Storage Support from 0.3.0 release
* Fixed bug where getqueue for an invalid queue returns 200 and the exception is not wrapped in a ServiceException
* Fixed the error when deleting a blob snapshot in the Service Layer
* Changed the PageBlob length parameter from an int to a long
* Return an Etag for create and copy Blob in Service Layer
* Updated the BlobRestProxy.copyBlob to correctly honor source access conditions
* Updated the BlobRestProxy.getBlob to correctly honor setComputeRangeMD5 option
* Added international support for ServiceBus URIs
* Added encoding for special characters when serializing entity to XML in Table Service Layer

2012.06.02 Version 0.3.0
* Added 1.7 Storage Support
* Added Javadocs for com.microsoft.windowsazure.services.table
Expand Down
107 changes: 52 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ To get the source code of the SDK via git just type:
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.

```xml
<dependency>
<groupId>com.microsoft.windowsazure</groupId>
<artifactId>microsoft-windowsazure-api</artifactId>
<version>0.3.0</version>
</dependency>
```
<dependency>
<groupId>com.microsoft.windowsazure</groupId>
<artifactId>microsoft-windowsazure-api</artifactId>
<version>0.3.1</version>
</dependency>

##Minimum Requirements

Expand All @@ -64,63 +62,62 @@ deployment tools.
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](http://www.windowsazure.com/en-us/develop/java/).

```java
import com.microsoft.windowsazure.services.core.storage.*;
import com.microsoft.windowsazure.services.blob.client.*;

public class BlobSample {
import com.microsoft.windowsazure.services.core.storage.*;
import com.microsoft.windowsazure.services.blob.client.*;

public static final String storageConnectionString =
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;
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();
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);
}
// 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?

Expand Down
12 changes: 11 additions & 1 deletion 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.3.0</version>
<version>0.3.1</version>
<packaging>jar</packaging>

<name>Microsoft Windows Azure Client API</name>
Expand Down Expand Up @@ -236,6 +236,16 @@
</lifecycleMappingMetadata>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
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.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;
Expand Down Expand Up @@ -429,7 +431,7 @@ void setContainerMetadata(String container, HashMap<String, String> metadata, Se
* @throws ServiceException
* if an error occurs accessing the storage service.
*/
void createPageBlob(String container, String blob, int length) throws ServiceException;
CreateBlobResult createPageBlob(String container, String blob, long length) throws ServiceException;

/**
* Creates a page blob of the specified maximum length, using the specified options.
Expand Down Expand Up @@ -457,7 +459,8 @@ void setContainerMetadata(String container, HashMap<String, String> metadata, Se
* @throws ServiceException
* if an error occurs accessing the storage service.
*/
void createPageBlob(String container, String blob, int length, CreateBlobOptions options) throws ServiceException;
CreateBlobResult createPageBlob(String container, String blob, long length, CreateBlobOptions options)
throws ServiceException;

/**
* Creates a block blob from a content stream.
Expand All @@ -473,7 +476,7 @@ void setContainerMetadata(String container, HashMap<String, String> metadata, Se
* @throws ServiceException
* if an error occurs accessing the storage service.
*/
void createBlockBlob(String container, String blob, InputStream contentStream) throws ServiceException;
CreateBlobResult createBlockBlob(String container, String blob, InputStream contentStream) throws ServiceException;

/**
* Creates a block blob from a content stream, using the specified options.
Expand All @@ -495,7 +498,7 @@ void setContainerMetadata(String container, HashMap<String, String> metadata, Se
* @throws ServiceException
* if an error occurs accessing the storage service.
*/
void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options)
CreateBlobResult createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options)
throws ServiceException;

/**
Expand Down Expand Up @@ -1214,8 +1217,8 @@ CreateBlobSnapshotResult createBlobSnapshot(String container, String blob, Creat
* @throws ServiceException
* if an error occurs accessing the storage service.
*/
void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob)
throws ServiceException;
CopyBlobResult copyBlob(String destinationContainer, String destinationBlob, String sourceContainer,
String sourceBlob) throws ServiceException;

/**
* Copies a source blob to a destination within the storage account, using the specified options.
Expand Down Expand Up @@ -1293,8 +1296,8 @@ void copyBlob(String destinationContainer, String destinationBlob, String source
* @throws ServiceException
* if an error occurs accessing the storage service.
*/
void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob,
CopyBlobOptions options) throws ServiceException;
CopyBlobResult copyBlob(String destinationContainer, String destinationBlob, String sourceContainer,
String sourceBlob, CopyBlobOptions options) throws ServiceException;

/**
* Gets a new lease on a blob.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,38 +44,74 @@ final class BlobAttributes {
public String snapshotID;

/**
* Holds the URI of the blob, Setting this is RESERVED for internal use.
* Holds the URI of the blob. RESERVED for internal use.
*/
protected URI uri;

/**
* Initializes a new instance of the BlobAttributes class
/**
* Initializes a new instance of the BlobAttributes class. RESERVED FOR INTERNAL USE.
*
* @param type
* The type of blob to set.
*/
public BlobAttributes(final BlobType type) {
this.setMetadata(new HashMap<String, String>());
this.setProperties(new BlobProperties(type));
}

/**
* Gets the metadata for the blob. RESERVED FOR INTERNAL USE.
*
* @return A <code>HashMap</code> object containing the metadata for the blob.
*/
public HashMap<String, String> getMetadata() {
return this.metadata;
}

/**
* Gets the copy state of the blob. RESERVED FOR INTERNAL USE.
*
* @return A <code>CopyState</code> object representing the copy state.
*/
public CopyState getCopyState() {
return this.copyState;
}

/**
* Gets the properties for the blob. RESERVED FOR INTERNAL USE.
*
* @return A <code>BlobProperties</code> object that represents the blob properties.
*/
public BlobProperties getProperties() {
return this.properties;
}

/**
* Sets the metadata for a blob. RESERVED FOR INTERNAL USE.
*
* @param metadata
* The blob meta data to set.
*/
protected void setMetadata(final HashMap<String, String> metadata) {
this.metadata = metadata;
}

/**
* Sets the properties for a blob. RESERVED FOR INTERNAL USE.
*
* @param properties
* The blob properties to set.
*/
protected void setProperties(final BlobProperties properties) {
this.properties = properties;
}

/**
* Sets the copy state for a blob. RESERVED FOR INTERNAL USE.
*
* @param copyState
* The blob copy state to set.
*/
public void setCopyState(final CopyState copyState) {
this.copyState = copyState;
}
Expand Down

0 comments on commit da5d538

Please sign in to comment.