diff --git a/ChangeLog.txt b/ChangeLog.txt index 8e6701c156567..17345e70ce1af 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -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 diff --git a/README.md b/README.md index 07c59ee7dee66..8bed4e62a948b 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ within your project you can also have them installed by the Java package manager com.microsoft.windowsazure microsoft-windowsazure-api - 0.3.0 + 0.3.1 ##Minimum Requirements @@ -62,61 +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/). - 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); - } + + 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? diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index dbc6cd094ba18..3a87dc3b06b65 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -17,7 +17,7 @@ 4.0.0 com.microsoft.windowsazure microsoft-windowsazure-api - 0.3.0 + 0.3.1 jar Microsoft Windows Azure Client API 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 f0f782200ab70..64f83ee08e53a 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 @@ -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()); this.setProperties(new BlobProperties(type)); } + /** + * Gets the metadata for the blob. RESERVED FOR INTERNAL USE. + * + * @return A HashMap object containing the metadata for the blob. + */ public HashMap getMetadata() { return this.metadata; } + /** + * Gets the copy state of the blob. RESERVED FOR INTERNAL USE. + * + * @return A CopyState object representing the copy state. + */ public CopyState getCopyState() { return this.copyState; } + /** + * Gets the properties for the blob. RESERVED FOR INTERNAL USE. + * + * @return A BlobProperties 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 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; } 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 4b34574466fd8..599687b285d76 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 @@ -72,67 +72,77 @@ public Date getLastModified() { } /** - * @return the leaseStatus + * Gets the lease status of the container. + * + * @return The lease status as a LeaseStatus object. */ public LeaseStatus getLeaseStatus() { return this.leaseStatus; } /** - * @return the leaseState + * Gets the lease state of the container. + * + * @return The lease state as a LeaseState object. */ public LeaseState getLeaseState() { return this.leaseState; } /** - * @return the leaseDuration + * Gets the lease duration of the container. + * + * @return The lease duration as a LeaseDuration object. */ public LeaseDuration getLeaseDuration() { return this.leaseDuration; } /** + * Sets the ETag value on the container. + * * @param etag - * the etag to set + * The ETag value to set, as a string. */ public void setEtag(final String etag) { this.etag = etag; } /** + * Sets the last modified time on the container. + * * @param lastModified - * the lastModified to set + * The last modified time to set, as a Date object. */ public void setLastModified(final Date lastModified) { this.lastModified = lastModified; } /** - * Reserved for internal use. + * Sets the lease status on the container. Reserved for internal use. * * @param leaseStatus - * the leaseStatus to set + * The lease status to set, as a LeaseStatus object. */ public void setLeaseStatus(final LeaseStatus leaseStatus) { this.leaseStatus = leaseStatus; } /** - * Reserved for internal use. + * Sets the lease status on the container. Reserved for internal use. * * @param LeaseState - * the LeaseState to set + * The lease state to set, as a LeaseState object. */ public void setLeaseState(final LeaseState leaseState) { this.leaseState = leaseState; } /** - * Reserved for internal use. + * Sets the lease duration on the container. Reserved for internal use. * * @param LeaseDuration - * the LeaseDuration to set + * The lease duration to set, as a LeaseDuration object. */ public void setLeaseDuration(final LeaseDuration leaseDuration) { this.leaseDuration = leaseDuration; 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 81c3faae35c57..9bb09d0b23f64 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 @@ -141,189 +141,221 @@ public BlobType getBlobType() { } /** - * @return the cacheControl + * Returns the cache control value for the blob. + * + * @return A string that represents the cache control value for the blob. */ public String getCacheControl() { return this.cacheControl; } /** - * @return the contentEncoding + * Gets the content encoding value for the blob. + * + * @return A string containing the content encoding, or null if content encoding has not been set + * on the blob. */ public String getContentEncoding() { return this.contentEncoding; } /** - * @return the contentLanguage + * Gets the content language value for the blob. + * + * @return A string containing the content language, or null if content language has not been set on + * the blob. */ public String getContentLanguage() { return this.contentLanguage; } /** - * @return the contentMD5 + * Gets the content MD5 value for the blob. + * + * @return A string containing the content MD5 value. */ public String getContentMD5() { return this.contentMD5; } /** - * @return the contentType + * Gets the content type value for the blob. + * + * @return A string containing content type, or null if the content type has not be set for the blob. */ public String getContentType() { return this.contentType; } /** - * @return the etag + * Gets the ETag value for the blob. + * + * @return A string containing the ETag value. */ public String getEtag() { return this.etag; } /** - * @return the lastModified + * Gets the last modified time for the blob. + * + * @return A Date containing the last modified time for the blob. */ public Date getLastModified() { return this.lastModified; } /** - * Reserved for internal use. + * Gets the lease status for the blob. Reserved for internal use. * - * @return the leaseStatus + * @return A LeaseStatus object representing the lease status. */ public LeaseStatus getLeaseStatus() { return this.leaseStatus; } /** - * @return the leaseState + * Gets the lease state for the blob. + * + * @return A LeaseState object representing the lease state. */ public LeaseState getLeaseState() { return this.leaseState; } /** - * @return the leaseDuration + * Gets the lease duration for the blob. + * + * @return A LeaseDuration object representing the lease duration. */ public LeaseDuration getLeaseDuration() { return this.leaseDuration; } /** - * @return the length + * Gets the size, in bytes, of the blob. + * + * @return The length of the blob. */ public long getLength() { return this.length; } /** - * Reserved for internal use. + * Sets the blob type. Reserved for internal use. * * @param blobType - * the blobType to set + * The blob type to set, represented by a BlobType object. */ protected void setBlobType(final BlobType blobType) { this.blobType = blobType; } /** + * Sets the cache control value for the blob. + * * @param cacheControl - * the cacheControl to set + * The cache control value to set. */ public void setCacheControl(final String cacheControl) { this.cacheControl = cacheControl; } /** + * Sets the content encoding value for the blob. + * * @param contentEncoding - * the contentEncoding to set + * The content encoding value to set. */ public void setContentEncoding(final String contentEncoding) { this.contentEncoding = contentEncoding; } /** + * Sets the content language for the blob. + * * @param contentLanguage - * the contentLanguage to set + * The content language value to set. */ public void setContentLanguage(final String contentLanguage) { this.contentLanguage = contentLanguage; } /** + * Sets the content MD5 value for the blob. + * * @param contentMD5 - * the contentMD5 to set + * The content MD5 value to set. */ public void setContentMD5(final String contentMD5) { this.contentMD5 = contentMD5; } /** + * Sets the content type value for the blob. + * * @param contentType - * the contentType to set + * The content type value to set. */ public void setContentType(final String contentType) { this.contentType = contentType; } /** - * Reserved for internal use. + * Sets the ETag value for the blob. Reserved for internal use. * * @param etag - * the etag to set + * The ETag value to set. */ public void setEtag(final String etag) { this.etag = etag; } /** - * Reserved for internal use. + * Sets the last modified time for the blob. Reserved for internal use. * * @param lastModified - * the lastModified to set + * The last modified time to set. */ public void setLastModified(final Date lastModified) { this.lastModified = lastModified; } /** - * Reserved for internal use. + * Sets the lease status for the blob. Reserved for internal use. * * @param leaseStatus - * the leaseStatus to set + * The lease status to set, represented by a LeaseStatus object. */ public void setLeaseStatus(final LeaseStatus leaseStatus) { this.leaseStatus = leaseStatus; } /** - * Reserved for internal use. + * Sets the lease state for the blob. Reserved for internal use. * * @param LeaseState - * the LeaseState to set + * The lease state to set, represented by a LeaseState object. */ public void setLeaseState(final LeaseState leaseState) { this.leaseState = leaseState; } /** - * Reserved for internal use. + * Sets the lease duration for the blob. Reserved for internal use. * * @param LeaseDuration - * the LeaseDuration to set + * The lease duration value to set, represented by a LeaseDuration object. */ public void setLeaseDuration(final LeaseDuration leaseDuration) { this.leaseDuration = leaseDuration; } /** - * Reserved for internal use. + * Sets the content length, in bytes, for the blob. Reserved for internal use. * * @param length - * the length to set + * 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/CloudBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java index a434b75f3de7b..bc87cebfa32cb 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 @@ -217,11 +217,12 @@ protected CloudBlob(final CloudBlob otherBlob) { } /** - * Acquires a new lease on the blob. + * Acquires a new lease on the blob with the specified lease time and proposed lease ID. * - * @param visibilityTimeoutInSeconds - * Specifies the the span of time for which to acquire the lease, in seconds. - * If null, an infinite lease will be acquired. If not null, this must be greater than zero. + * @param leaseTimeInSeconds + * Specifies the span of time for which to acquire the lease, in seconds. + * If null, an infinite lease will be acquired. If not null, the value must be greater than + * zero. * * @param proposedLeaseId * A String that represents the proposed lease ID for the new lease, @@ -239,11 +240,13 @@ public final String acquireLease(final Integer leaseTimeInSeconds, final String } /** - * Acquires a new lease on the blob using the specified request options and operation context. + * Acquires a new lease on the blob with the specified lease time, proposed lease ID, request + * options, and operation context. * - * @param visibilityTimeoutInSeconds - * Specifies the the span of time for which to acquire the lease, in seconds. - * If null, an infinite lease will be acquired. If not null, this must be greater than zero. + * @param leaseTimeInSeconds + * Specifies the span of time for which to acquire the lease, in seconds. + * If null, an infinite lease will be acquired. If not null, the value must be greater than + * zero. * * @param proposedLeaseId * A String that represents the proposed lease ID for the new lease, @@ -251,12 +254,14 @@ public final String acquireLease(final Integer leaseTimeInSeconds, final String * * @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}). + * 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 + * An {@link OperationContext} object that represents the context for the current operation. The context * is used to track requests to the storage service, and to provide additional runtime information about * the operation. * @@ -338,11 +343,11 @@ 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. + * Breaks the lease and ensures that another client cannot acquire a new lease until the current lease period + * has expired. * * @param breakPeriodInSeconds - * Specifies the amount of time to allow the lease to remain, in seconds. + * Specifies the time to wait, in seconds, until the current lease is broken. * If null, the break period is the remainder of the current lease, or zero for infinite leases. * * @return The time, in seconds, remaining in the lease period. @@ -356,21 +361,21 @@ public final long breakLease(final Integer breakPeriodInSeconds) throws StorageE } /** - * 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. + * Breaks the existing lease, using the specified request options and operation context, and ensures that another + * client cannot acquire a new lease until the current lease period has expired. * * @param breakPeriodInSeconds - * Specifies the amount of time to allow the lease to remain, in seconds. + * Specifies the time to wait, in seconds, until the current lease is broken. * If null, the break period is the remainder of the current lease, or zero for infinite leases. * * @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}). + * 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 + * An {@link OperationContext} object that represents the context for the current operation. The context * is used to track requests to the storage service, and to provide additional runtime information about * the operation. * @@ -2000,15 +2005,15 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op } /** - * Changes an existing lease. + * Changes the existing lease ID to the proposed lease ID. * * @param proposedLeaseId * A String that represents the proposed lease ID for the new lease, * or null if no lease ID is proposed. * * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. The LeaseID is - * required to be set on the AccessCondition. + * An {@link AccessCondition} object that represents the access conditions for the blob. The lease ID is + * required to be set with an access condition. * * @throws StorageException * If a storage service error occurred. @@ -2020,21 +2025,22 @@ public final void changeLease(final String proposedLeaseId, final AccessConditio } /** - * Changes an existing lease using the specified proposedLeaseId, request options and operation context. + * Changes the existing lease ID to the proposed lease Id with the specified access conditions, request options, + * and operation context. * * @param proposedLeaseId * A String that represents the proposed lease ID for the new lease, * or null if no lease ID is proposed. * * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. The LeaseID is - * required to be set on the AccessCondition. + * An {@link AccessCondition} object that represents the access conditions for the blob. The lease ID is + * required to be set with an access condition. * @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}). + * 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 + * An {@link OperationContext} object that represents the context for the current operation. The context * is used to track requests to the storage service, and to provide additional runtime information about * the operation. * 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 ab8bd64df564b..6cd9752c046e7 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 @@ -1629,11 +1629,12 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta } /** - * Acquires a new lease on the container. + * Acquires a new lease on the container with the specified lease time and proposed lease ID. * - * @param visibilityTimeoutInSeconds - * Specifies the the span of time for which to acquire the lease, in seconds. - * If null, an infinite lease will be acquired. If not null, this must be greater than zero. + * @param leaseTimeInSeconds + * Specifies the span of time for which to acquire the lease, in seconds. + * If null, an infinite lease will be acquired. If not null, the value must be greater than + * zero. * * @param proposedLeaseId * A String that represents the proposed lease ID for the new lease, @@ -1651,25 +1652,28 @@ public final String acquireLease(final Integer leaseTimeInSeconds, final String } /** - * Acquires a new lease on the container using the specified visibilityTimeoutInSeconds, proposedLeaseId, request - * options and operation context. + * Acquires a new lease on the container with the specified lease time, proposed lease ID, request + * options, and operation context. * - * @param visibilityTimeoutInSeconds - * Specifies the the span of time for which to acquire the lease, in seconds. - * If null, an infinite lease will be acquired. If not null, this must be greater than zero. + * @param leaseTimeInSeconds + * Specifies the span of time for which to acquire the lease, in seconds. + * If null, an infinite lease will be acquired. If not null, the value must be greater than + * zero. * * @param proposedLeaseId * A String that represents the proposed lease ID for the new lease, * or null if no lease ID is proposed. * * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. + * An {@link AccessCondition} object that represents the access conditions for the container. + * * @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}). + * 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 + * An {@link OperationContext} object that represents the context for the current operation. The context * is used to track requests to the storage service, and to provide additional runtime information about * the operation. * @@ -1724,11 +1728,11 @@ public String execute(final CloudBlobClient client, final CloudBlobContainer con } /** - * Renews an existing lease. + * Renews an existing lease with the specified access conditions. * * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the container. The LeaseID - * is required to be set on the AccessCondition. + * An {@link AccessCondition} object that represents the access conditions for the container. The lease ID is + * required to be set with an access condition. * * @throws StorageException * If a storage service error occurred. @@ -1739,17 +1743,19 @@ public final void renewLease(final AccessCondition accessCondition) throws Stora } /** - * Renews an existing lease using the specified request options and operation context. + * Renews an existing lease with the specified access conditions, 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. + * An {@link AccessCondition} object that represents the access conditions for the blob. The lease ID is + * required to be set with an access condition. + * * @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}). + * 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 + * An {@link OperationContext} object that represents the context for the current operation. The context * is used to track requests to the storage service, and to provide additional runtime information about * the operation. * @@ -1806,8 +1812,8 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta * Releases the lease on the container. * * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. The LeaseID is - * required to be set on the AccessCondition. + * An {@link AccessCondition} object that represents the access conditions for the blob. The lease ID is + * required to be set with an access condition. * * @throws StorageException * If a storage service error occurred. @@ -1818,17 +1824,19 @@ public final void releaseLease(final AccessCondition accessCondition) throws Sto } /** - * Releases the lease on the container using the specified request options and operation context. + * Releases the lease on the container using the specified access conditions, 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. + * An {@link AccessCondition} object that represents the access conditions for the blob. The lease ID is + * required to be set with an access condition. + * * @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}). + * 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 + * An {@link OperationContext} object that represents the context for the current operation. The context * is used to track requests to the storage service, and to provide additional runtime information about * the operation. * @@ -1882,11 +1890,11 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta } /** - * Breaks the lease but ensures that another client cannot acquire a new lease until the current lease period has - * expired. + * Breaks the lease and ensures that another client cannot acquire a new lease until the current lease + * period has expired. * * @param breakPeriodInSeconds - * Specifies the amount of time to allow the lease to remain, in seconds. + * Specifies the time to wait, in seconds, until the current lease is broken. * If null, the break period is the remainder of the current lease, or zero for infinite leases. * * @return The time, in seconds, remaining in the lease period. @@ -1900,21 +1908,21 @@ public final long breakLease(final Integer breakPeriodInSeconds) throws StorageE } /** - * 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. + * Breaks the existing lease, using the specified request options and operation context, and ensures that + * another client cannot acquire a new lease until the current lease period has expired. * * @param breakPeriodInSeconds - * Specifies the amount of time to allow the lease to remain, in seconds. + * Specifies the time to wait, in seconds, until the current lease is broken. * If null, the break period is the remainder of the current lease, or zero for infinite leases. * * @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}). + * 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 + * An {@link OperationContext} object that represents the context for the current operation. The context * is used to track requests to the storage service, and to provide additional runtime information about * the operation. * @@ -1968,15 +1976,15 @@ public Long execute(final CloudBlobClient client, final CloudBlobContainer conta } /** - * Changes an existing lease. + * Changes the existing lease ID to the proposed lease ID. * * @param proposedLeaseId * A String that represents the proposed lease ID for the new lease, * or null if no lease ID is proposed. * * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. The LeaseID is - * required to be set on the AccessCondition. + * An {@link AccessCondition} object that represents the access conditions for the blob. The lease ID is + * required to be set with an access condition. * * @throws StorageException * If a storage service error occurred. @@ -1988,21 +1996,24 @@ public final void changeLease(final String proposedLeaseId, final AccessConditio } /** - * Changes an existing lease using the specified proposedLeaseId, request options and operation context. + * Changes the existing lease ID to the proposed lease Id with the specified access conditions, request options, + * and operation context. * * @param proposedLeaseId * A String that represents the proposed lease ID for the new lease, * or null if no lease ID is proposed. * * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. The LeaseID is - * required to be set on the AccessCondition. + * An {@link AccessCondition} object that represents the access conditions for the blob. The lease ID is + * required to be set with an access condition. + * * @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}). + * 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 + * An {@link OperationContext} object that represents the context for the current operation. The context * is used to track requests to the storage service, and to provide additional runtime information about * the operation. * 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 6c1a9e921afe0..a8d60323e9fe6 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 @@ -23,7 +23,7 @@ */ public final class CopyState { /** - * Holds the Name of the Container + * Holds the name of the container. */ private String copyId; @@ -59,27 +59,52 @@ public final class CopyState { private String statusDescription; /** - * Initializes a new instance of the CopyState class + * Initializes a new instance of the CopyState class. */ public CopyState() { } + /** + * Gets the copy ID of the container. + * + * @return A string containing the copy ID of the container. + */ public String getCopyId() { return this.copyId; } + /** + * Gets the time that the copy operation completed. + * + * @return The time that the copy operation completed. + */ public Date getCompletionTime() { return this.completionTime; } + /** + * Gets the status of the copy operation. + * + * @return A CopyStatus object representing the status of the copy operation. + */ public CopyStatus getStatus() { return this.status; } + /** + * Gets the source URI of the copy operation. + * + * @return The source URI of the copy operation in a string. + */ public URI getSource() { return this.source; } + /** + * Gets the number of bytes copied in the operation so far. + * + * @return The number of bytes copied so far. + */ public Long getBytesCopied() { return this.bytesCopied; } @@ -88,34 +113,82 @@ public Long getTotalBytes() { return this.totalBytes; } + /** + * Gets the status description of the copy operation. + * + * @return A string containing the status description. + */ public String getStatusDescription() { return this.statusDescription; } + /** + * Sets the copy ID of the container. + * + * @param copyId + * The copy ID of the container to set. + * + */ public void setCopyId(final String copyId) { this.copyId = copyId; } + /** + * Sets the time that the copy operation completed. + * + * @param completionTime + * The completion time to set. + */ public void setCompletionTime(final Date completionTime) { this.completionTime = completionTime; } + /** + * Sets the status of the copy operation. + * + * @param status + * The copy operation status to set, as a CopyStatus object. + */ public void setStatus(final CopyStatus status) { this.status = status; } + /** + * Sets the source URI of the copy operation. + * + * @param source + * The source URI to set. + */ public void setSource(final URI source) { this.source = source; } + /** + * Sets the number of bytes copied so far. + * + * @param bytesCopied + * The number of bytes copied to set. + */ public void setBytesCopied(final Long bytesCopied) { this.bytesCopied = bytesCopied; } + /** + * Sets the total number of bytes in the source to copy. + * + * @param totalBytes + * The number of bytes to set. + */ public void setTotalBytes(final Long totalBytes) { this.totalBytes = totalBytes; } + /** + * Sets the current status of the copy operation. + * + * @param statusDescription + * The current status to set. + */ public void setStatusDescription(final String statusDescription) { this.statusDescription = statusDescription; } 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 9e4d13c91dab5..33809c15c10c8 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 @@ -23,7 +23,7 @@ */ public enum CopyStatus { /** - * The copy status is not specified.. + * The copy status is not specified. */ UNSPECIFIED, 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 c8dc1c17dff8e..5475705a29fd6 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 @@ -45,7 +45,7 @@ public enum SharedAccessBlobPermissions { * * @param value * The byte value to convert to the corresponding enum set. - * @return A java.util.EnumSet object that contains the SharedAccessPermissions values + * @return A java.util.EnumSet object that contains the SharedAccessBlobPermissions values * corresponding to the specified byte value. */ protected static EnumSet fromByte(final byte value) { 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 937b558ab4c6b..8d9c708aa56c9 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 @@ -120,52 +120,66 @@ public static String permissionsToString(final EnumSetSharedAccessPolicy class. + * Creates an instance of the SharedAccessBlobPolicy class. * */ public SharedAccessBlobPolicy() { // Empty Default Ctor } /** - * @return the permissions + * Gets the permissions for a shared access signature associated with this shared access policy. + * + * @return A java.util.EnumSet object that contains {@link SharedAccessBlobPermissions} values that + * represents the set of shared access permissions. */ public EnumSet getPermissions() { return this.permissions; } /** - * @return the sharedAccessExpiryTime + * Gets the expiry time for a shared access signature associated with this shared access policy. + * + * @return A Date object that contains the shared access signature expiry time. */ public Date getSharedAccessExpiryTime() { return this.sharedAccessExpiryTime; } /** - * @return the sharedAccessStartTime + * Gets the start time for a shared access signature associated with this shared access policy. + * + * @return A Date object that contains the shared access signature start time. */ public Date getSharedAccessStartTime() { return this.sharedAccessStartTime; } /** + * Sets the permissions for a shared access signature associated with this shared access policy. + * * @param permissions - * the permissions to set + * The permissions, represented by a java.util.EnumSet object that contains + * {@link SharedAccessBlobPermissions} values, to set for the shared access signature. */ public void setPermissions(final EnumSet permissions) { this.permissions = permissions; } /** + * Sets the expiry time for a shared access signature associated with this shared access policy. + * * @param sharedAccessExpiryTime - * the sharedAccessExpiryTime to set + * The expiry time to set for the shared access signature. */ public void setSharedAccessExpiryTime(final Date sharedAccessExpiryTime) { this.sharedAccessExpiryTime = sharedAccessExpiryTime; } /** + * Sets the start time for a shared access signature associated with this shared access policy. + * * @param sharedAccessStartTime - * the sharedAccessStartTime to set + * The start time to set for the shared access signature. */ public void setSharedAccessStartTime(final Date sharedAccessStartTime) { this.sharedAccessStartTime = sharedAccessStartTime; 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 1664dec987818..e5afff9047a29 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 @@ -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.core; @@ -23,10 +23,18 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.sun.jersey.api.client.config.ClientConfig; - public class Configuration { + /** + * Property name for socket connection timeout used by services created with this configuration. + */ + public static final String PROPERTY_CONNECT_TIMEOUT = "com.microsoft.windowsazure.services.core.Configuration.connectTimeout"; + + /** + * Property name for socket read timeout used by services created with this configuration. + */ + public static final String PROPERTY_READ_TIMEOUT = "com.microsoft.windowsazure.services.core.Configuration.readTimeout"; + private static Configuration instance; Map properties; Builder builder; @@ -36,17 +44,11 @@ public class Configuration { 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() { @@ -102,4 +104,7 @@ public void setProperty(String name, Object value) { properties.put(name, value); } + public Map getProperties() { + return properties; + } } 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 new file mode 100644 index 0000000000000..9c3c5f7fcd134 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceTimeoutException.java @@ -0,0 +1,63 @@ +/** + * 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; + +/** + * Exception indicating a service operation has timed out. + */ +public class ServiceTimeoutException extends ServiceException { + + private static final long serialVersionUID = 6612846403178749361L; + + /** + * Construct a ServiceTimeoutException instance with default parameters. + */ + public ServiceTimeoutException() { + } + + /** + * Construct a ServiceTimeoutException instance with the specified message. + * + * @param message + * Exception message + */ + public ServiceTimeoutException(String message) { + super(message); + } + + /** + * Construct a ServiceTimeoutException instance with specified + * message and cause + * + * @param message + * Exception message + * @param cause + * Exception that caused this exception to occur + */ + public ServiceTimeoutException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Construct a ServiceTimeoutException instance with the specified cause. + * + * @param cause + * Exception that caused this exception to occur + */ + public ServiceTimeoutException(Throwable cause) { + super(cause); + } +} 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 2c807c8dd57ff..8e795b831374f 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 @@ -38,10 +38,10 @@ public enum LeaseDuration { INFINITE; /** - * Parses a lease duration from the given string. + * Parses a lease duration from the specified string. * * @param typeString - * A String that represents the string to parse. + * The string to parse. * * @return A LeaseStatus value that represents the lease status. */ 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 c2c7f9a79e3ff..9bbd28f83ecd3 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 @@ -19,7 +19,7 @@ import com.microsoft.windowsazure.services.core.storage.utils.Utility; /** - * he lease state of a resource. + * The lease state of a resource. */ public enum LeaseState { /** @@ -56,7 +56,7 @@ public enum LeaseState { * Parses a lease status from the given string. * * @param typeString - * A String that represents the string to parse. + * The string to parse. * * @return A LeaseStatus value that represents the lease status. */ 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..ee00445cf6b61 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateConverter.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.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/core/utils/ServiceExceptionFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java index 90210ac0e6254..d11feceb6d20b 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 @@ -2,19 +2,22 @@ * Copyright 2011 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this 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.core.utils; +import java.net.SocketTimeoutException; + import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceTimeoutException; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.ClientResponse.Status; import com.sun.jersey.api.client.UniformInterfaceException; @@ -25,12 +28,16 @@ public static ServiceException process(String serviceName, ServiceException exce Throwable cause = exception.getCause(); for (Throwable scan = cause; scan != null; scan = scan.getCause()) { - if (ServiceException.class.isAssignableFrom(scan.getClass())) { + Class scanClass = scan.getClass(); + if (ServiceException.class.isAssignableFrom(scanClass)) { return populate(exception, serviceName, (ServiceException) scan); } - else if (UniformInterfaceException.class.isAssignableFrom(scan.getClass())) { + else if (UniformInterfaceException.class.isAssignableFrom(scanClass)) { return populate(exception, serviceName, (UniformInterfaceException) scan); } + else if (SocketTimeoutException.class.isAssignableFrom(scanClass)) { + return populate(exception, serviceName, (SocketTimeoutException) scan); + } } exception.setServiceName(serviceName); @@ -83,4 +90,9 @@ static ServiceException populate(ServiceException exception, String serviceName, return exception; } + static ServiceException populate(ServiceException exception, String serviceName, SocketTimeoutException cause) { + ServiceTimeoutException newException = new ServiceTimeoutException(cause.getMessage(), cause); + newException.setServiceName(serviceName); + return newException; + } } 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 234581b023fb8..d5b9ddc05ce9f 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 @@ -19,6 +19,7 @@ import com.microsoft.windowsazure.services.core.Builder; import com.microsoft.windowsazure.services.core.Builder.Registry; +import com.microsoft.windowsazure.services.core.Configuration; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; @@ -31,8 +32,37 @@ public void register(Registry registry) { @Override public ClientConfig create(String profile, Builder builder, Map properties) { ClientConfig clientConfig = new DefaultClientConfig(); + profile = normalizeProfile(profile); + + // 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 + + clientConfig.getProperties().put(ClientConfig.PROPERTY_CONNECT_TIMEOUT, new Integer(90 * 1000)); + clientConfig.getProperties().put(ClientConfig.PROPERTY_READ_TIMEOUT, new Integer(90 * 1000)); + for (Entry entry : properties.entrySet()) { - clientConfig.getProperties().put(entry.getKey(), entry.getValue()); + Object propertyValue = entry.getValue(); + String propertyKey = entry.getKey(); + + if (propertyKey.equals(profile + Configuration.PROPERTY_CONNECT_TIMEOUT)) { + propertyKey = ClientConfig.PROPERTY_CONNECT_TIMEOUT; + } + 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); + } + } + clientConfig.getProperties().put(propertyKey, propertyValue); } return clientConfig; } @@ -41,7 +71,7 @@ public ClientConfig create(String profile, Builder builder, Map registry.add(new Builder.Factory() { @Override public Client create(String profile, Builder builder, Map properties) { - ClientConfig clientConfig = (ClientConfig) properties.get("ClientConfig"); + ClientConfig clientConfig = builder.build(profile, ClientConfig.class, properties); Client client = Client.create(clientConfig); return client; } @@ -50,11 +80,23 @@ public Client create(String profile, Builder builder, Map proper registry.add(new Builder.Factory() { @Override public HttpURLConnectionClient create(String profile, Builder builder, Map properties) { - ClientConfig clientConfig = (ClientConfig) properties.get("ClientConfig"); + ClientConfig clientConfig = builder.build(profile, ClientConfig.class, properties); HttpURLConnectionClient client = HttpURLConnectionClient.create(clientConfig); //client.addFilter(new LoggingFilter()); return client; } }); } + + private static String normalizeProfile(String profile) { + if (profile == null) { + return ""; + } + + if (profile.endsWith(".")) { + return profile; + } + + return profile + "."; + } } 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 9b7ca1dd32482..f996e5edc6421 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 @@ -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.core.utils.pipeline; @@ -26,7 +26,7 @@ public HttpURLConnectionClient(HttpURLConnectionClientHandler handler, ClientCon } public static HttpURLConnectionClient create(ClientConfig config) { - return new HttpURLConnectionClient(new HttpURLConnectionClientHandler(), config); + return new HttpURLConnectionClient(new HttpURLConnectionClientHandler(config), config); } public HttpURLConnectionClientHandler getRootHandler() { 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 20d9046c5358c..83e0822264e45 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 @@ -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.core.utils.pipeline; @@ -37,10 +37,28 @@ import com.sun.jersey.core.header.InBoundHeaders; public class HttpURLConnectionClientHandler extends TerminatingClientHandler { + + private final int connectionTimeoutMillis; + private final int readTimeoutMillis; + + public HttpURLConnectionClientHandler(ClientConfig clientConfig) { + connectionTimeoutMillis = readTimeoutFromConfig(clientConfig, ClientConfig.PROPERTY_CONNECT_TIMEOUT); + readTimeoutMillis = readTimeoutFromConfig(clientConfig, ClientConfig.PROPERTY_READ_TIMEOUT); + } + + private static int readTimeoutFromConfig(ClientConfig config, String propertyName) { + Integer property = (Integer) config.getProperty(propertyName); + if (property != null) { + return property.intValue(); + } + throw new IllegalArgumentException(propertyName); + } + /** * Empty "no-op" listener if none registered */ private static final EntityStreamingListener EMPTY_STREAMING_LISTENER = new EntityStreamingListener() { + @Override public void onBeforeStreamingEntity(ClientRequest clientRequest) { } }; @@ -164,6 +182,7 @@ public String toString() { } } + @Override public ClientResponse handle(final ClientRequest ro) throws ClientHandlerException { try { return doHandle(ro); @@ -176,6 +195,9 @@ public ClientResponse handle(final ClientRequest ro) throws ClientHandlerExcepti private ClientResponse doHandle(final ClientRequest clientRequest) throws IOException, MalformedURLException, ProtocolException { final HttpURLConnection urlConnection = (HttpURLConnection) clientRequest.getURI().toURL().openConnection(); + urlConnection.setReadTimeout(readTimeoutMillis); + urlConnection.setConnectTimeout(connectionTimeoutMillis); + final EntityStreamingListener entityStreamingListener = getEntityStreamingListener(clientRequest); urlConnection.setRequestMethod(clientRequest.getMethod()); @@ -202,6 +224,7 @@ private ClientResponse doHandle(final ClientRequest clientRequest) throws IOExce writeRequestEntity(clientRequest, new RequestEntityWriterListener() { private boolean inStreamingMode; + @Override public void onRequestEntitySize(long size) { if (size != -1 && size < Integer.MAX_VALUE) { inStreamingMode = true; @@ -222,6 +245,7 @@ public void onRequestEntitySize(long size) { } } + @Override public OutputStream onGetOutputStream() throws IOException { if (inStreamingMode) return new StreamingOutputStream(urlConnection, clientRequest); 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..2487fd162e08a 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. @@ -14,20 +14,31 @@ */ package com.microsoft.windowsazure.services.media; +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.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; 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; +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 { /** - * register the OAUTH service. + * register the Media services. */ @Override public void register(Builder.Registry registry) { @@ -39,6 +50,31 @@ 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() { + @Override + public ClientConfig alter(ClientConfig instance, Builder builder, Map properties) { + instance.getProperties().put(JSONConfiguration.FEATURE_POJO_MAPPING, true); + + // Turn off auto-follow redirects, because Media Services rest calls break if it's on + instance.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, false); + + try { + instance.getSingletons().add(new ODataEntityProvider()); + instance.getSingletons().add(new ODataEntityCollectionProvider()); + instance.getSingletons().add(new MediaContentProvider()); + } + catch (JAXBException e) { + throw new RuntimeException(e); + } + catch (ParserConfigurationException e) { + throw new RuntimeException(e); + } + + return instance; + } + }); + } } 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 3e92ac300dae0..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 @@ -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. @@ -14,15 +14,155 @@ */ 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.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; /** - * - * Defines the methods available for Windows Azure Media Services - * + * 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 + /** + * 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; + + /** + * Delete asset. + * + * @param assetId + * the asset id + * @throws ServiceException + */ + public void deleteAsset(String assetId) throws ServiceException; + + /** + * Gets the asset. + * + * @param assetId + * the asset id + * @return the asset + * @throws ServiceException + */ + public AssetInfo getAsset(String assetId) throws ServiceException; + + /** + * List assets. + * + * @return the list + * @throws ServiceException + */ + public List listAssets() throws ServiceException; + + /** + * List assets. + * + * @param listAssetsOptions + * the list assets options + * @return the list + * @throws ServiceException + */ + public List 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 name + * name of access policy + * @param durationInMinutes + * Duration in minutes that blob access will be granted when using this access policy + * @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 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 + */ + 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 listAccessPolicies() throws ServiceException; + /** + * List access policies + * + * @param options + * the list access policy options + * @return the list + * @throws ServiceException + */ + List listAccessPolicies(ListAccessPolicyOptions options) throws ServiceException; } 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/MediaContentProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaContentProvider.java new file mode 100644 index 0000000000000..4ad8c880c6d4f --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaContentProvider.java @@ -0,0 +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; + +/** + * Class to plug into Jersey to properly serialize + * raw Media Services DTO types. + * + */ +public class MediaContentProvider extends AbstractMessageReaderWriterProvider { + 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 type, Type genericType, Annotation[] annotations, MediaType mediaType, + MultivaluedMap 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 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/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index d9c3141d52064..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 @@ -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,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,15 @@ 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; +import com.sun.jersey.api.client.UniformInterfaceException; /** * Wrapper implementation of MediaServicesContract that @@ -32,26 +43,258 @@ */ public class MediaExceptionProcessor implements MediaContract { - private final MediaContract next; + /** The service. */ + private final MediaContract service; + + /** The log. */ static Log log = LogFactory.getLog(MediaContract.class); - public MediaExceptionProcessor(MediaContract next) { - this.next = next; + /** + * 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 next) { - this.next = next; + 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(next.withFilter(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 { + 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 { + try { + return service.createAsset(assetName, 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 List 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 List 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 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 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 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 9b1dfc25e5a60..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 @@ -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,39 +15,90 @@ package com.microsoft.windowsazure.services.media.implementation; +import java.io.UnsupportedEncodingException; +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; 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.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; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.GenericType; import com.sun.jersey.api.client.WebResource; +/** + * The Class MediaRestProxy. + */ public class MediaRestProxy implements MediaContract { + /** The channel. */ private Client channel; - static Log log = LogFactory.getLog(MediaContract.class); + /** 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 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); } + /** + * 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); @@ -55,14 +106,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) { @@ -71,4 +140,185 @@ 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 mergeRequest(String path, java.lang.Class 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) + */ + @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) { + WebResource resource = getResource("Assets"); + 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, 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 List listAssets(ListAssetsOptions listAssetsOptions) { + WebResource resource = getResource("Assets"); + return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) + .get(new GenericType>() { + }); + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listAssets() + */ + @Override + public List 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 { + 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()); + 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) throws ServiceException { + getResource("Assets", assetId).delete(); + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#createAccessPolicy(double) + */ + @Override + public AccessPolicyInfo createAccessPolicy(String name, double durationInMinutes) throws ServiceException { + return createAccessPolicy(name, 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 { + + if (options == null) { + options = new CreateAccessPolicyOptions().addPermissions(EnumSet.of(AccessPolicyPermission.WRITE)); + } + + 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); + } + + /* (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 listAccessPolicies() throws ServiceException { + return listAccessPolicies(null); + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listAccessPolicies() + */ + @Override + public List listAccessPolicies(ListAccessPolicyOptions options) throws ServiceException { + WebResource resource = getResource("AccessPolicies"); + + return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) + .get(new GenericType>() { + }); + } } 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 473bd9d60bb60..7e5df57b529ca 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. @@ -51,24 +51,25 @@ public class OAuthTokenManager { * @param dateFactory * A DateFactory object instance that represents the date factory. * - * @param acsBaseUri - * A URI object instance that represents the ACS base URI. + * @param oAuthUri + * A String 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. + * @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/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/ODataAtomMarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java new file mode 100644 index 0000000000000..13edb3b00de50 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.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.media.implementation; + +import java.io.OutputStream; +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.AccessPolicyType; +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(); + } + + /** + * 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 marshallable + */ + public Document marshalEntry(Object content) throws JAXBException { + JAXBElement 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 createEntry(Object content) { + 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 entryElement = new JAXBElement(new QName(Constants.ATOM_NS, "entry"), + EntryType.class, atomEntry); + + return entryElement; + } + + private static Class[] getMarshalledClasses() { + List> classes = new ArrayList>(); + 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/ODataAtomUnmarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java new file mode 100644 index 0000000000000..66cecfd0a542d --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.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.implementation; + +import java.io.InputStream; +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; +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.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; +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; + +/** + * 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(); + mediaContentContext = JAXBContext.newInstance(AssetType.class.getPackage().getName()); + mediaContentUnmarshaller = mediaContentContext.createUnmarshaller(); + } + + /** + * 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 + * + * @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 List unmarshalFeed(InputStream stream, Class contentType) + throws JAXBException, ServiceException { + validateNotNull(stream, "stream"); + validateNotNull(contentType, "contentType"); + + List entries = new ArrayList(); + FeedType feed = unmarshalFeed(stream); + Class marshallingContentType = getMarshallingContentType(contentType); + + for (Object feedChild : feed.getFeedChildren()) { + EntryType entry = asEntry(feedChild); + if (entry != null) { + entries.add(contentFromEntry(contentType, marshallingContentType, entry)); + } + } + return entries; + } + + /** + * 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 T unmarshalEntry(InputStream stream, Class contentType) throws JAXBException, + ServiceException { + validateNotNull(stream, "stream"); + validateNotNull(contentType, "contentType"); + + Class marshallingContentType = getMarshallingContentType(contentType); + + EntryType entry = unmarshalEntry(stream); + return contentFromEntry(contentType, marshallingContentType, entry); + } + + private T contentFromEntry(Class contentType, Class marshallingContentType, + EntryType entry) throws JAXBException, ServiceException { + 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 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 actionElement = mediaContentUnmarshaller.unmarshal(e, + ODataActionType.class); + children.set(i, actionElement); + } + } + } + } + + private void unmarshalEntryContent(EntryType entry, Class contentType) throws JAXBException { + Class marshallingContentType = getMarshallingContentType(contentType); + ContentType contentElement = getFirstOfType(ContentType.class, entry.getEntryChildren()); + List 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); + } + } + } + } + + private T getFirstOfType(Class targetType, List 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 constructResultObject(Class contentType, EntryType entry, Object contentObject) + throws ServiceException { + Class marshallingType = getMarshallingContentType(contentType); + try { + Constructor resultCtor = contentType.getConstructor(EntryType.class, marshallingType); + return resultCtor.newInstance(entry, contentObject); + } + catch (IllegalArgumentException e) { + throw new ServiceException(e); + } + catch (SecurityException e) { + throw new ServiceException(e); + } + catch (InstantiationException e) { + throw new ServiceException(e); + } + catch (IllegalAccessException e) { + throw new ServiceException(e); + } + catch (InvocationTargetException e) { + throw new ServiceException(e); + } + catch (NoSuchMethodException e) { + throw new ServiceException(e); + } + } + + private EntryType unmarshalEntry(InputStream stream) throws JAXBException { + JAXBElement entryElement = atomUnmarshaller.unmarshal(new StreamSource(stream), EntryType.class); + return entryElement.getValue(); + } + + private FeedType unmarshalFeed(InputStream stream) throws JAXBException { + JAXBElement feedElement = atomUnmarshaller.unmarshal(new StreamSource(stream), FeedType.class); + return feedElement.getValue(); + } + + private static QName qnameFromElement(Element e) { + return new QName(e.getLocalName(), e.getNamespaceURI()); + } + + private static Class getMarshallingContentType(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 new file mode 100644 index 0000000000000..dae9e70cd471c --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java @@ -0,0 +1,119 @@ +/** + * 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.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; + +/** + * Class wrapping deserialized OData entities. Allows easy + * access to entry and content types. + * + */ +public abstract class ODataEntity { + + private final EntryType entry; + private final T content; + + protected ODataEntity(EntryType entry, T content) { + this.entry = entry; + this.content = content; + } + + protected ODataEntity(T content) { + this.content = content; + + ContentType contentElement = new ContentType(); + contentElement.getContent().add( + new JAXBElement(Constants.ODATA_PROPERTIES_ELEMENT_NAME, content.getClass(), content)); + entry = new EntryType(); + entry.getEntryChildren().add( + new JAXBElement(Constants.ATOM_CONTENT_ELEMENT_NAME, ContentType.class, contentElement)); + } + + /** + * @return the entry + */ + protected EntryType getEntry() { + return entry; + } + + /** + * @return the content + */ + 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); + } + + /** + * Reflection helper to pull out the type parameter for + * a List, where T is a ODataEntity derived type. + * + * @param genericType + * type object for collection + * @return The class object for the type parameter. + */ + 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..b6b6eac581503 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java @@ -0,0 +1,84 @@ +/** + * + */ +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>> { + 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> readFrom(Class>> type, Type genericType, Annotation[] annotations, + MediaType mediaType, MultivaluedMap 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.getCollectedType(genericType)); + } + else { + throw new RuntimeException(); + } + } + catch (JAXBException e) { + throw new RuntimeException(e); + } + catch (ServiceException e) { + 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> t, Class type, Type genericType, Annotation[] annotations, + MediaType mediaType, MultivaluedMap 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 new file mode 100644 index 0000000000000..704e0885db0e2 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.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.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 javax.xml.parsers.ParserConfigurationException; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider; + +/** + * An implementation of {@link AbstractMessageReaderWriterProvider } that + * is used to marshal and unmarshal instances of the ODataEntity type. + * + */ +public class ODataEntityProvider extends AbstractMessageReaderWriterProvider> { + private final ODataAtomUnmarshaller unmarshaller; + + public ODataEntityProvider() throws JAXBException, ParserConfigurationException { + 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.isODataEntityType(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> type, Type genericType, Annotation[] annotations, + MediaType mediaType, MultivaluedMap httpHeaders, InputStream entityStream) + throws IOException, WebApplicationException { + + ODataEntity result = null; + String responseType = mediaType.getParameters().get("type"); + try { + if (responseType == null || responseType.equals("feed")) { + List> feedContents = unmarshaller.unmarshalFeed(entityStream, type); + return feedContents.get(0); + } + else if (responseType.equals("entry")) { + result = unmarshaller.unmarshalEntry(entityStream, type); + } + else { + throw new RuntimeException(); + } + } + catch (JAXBException e) { + throw new RuntimeException(e); + } + catch (ServiceException e) { + throw new RuntimeException(e); + } + + return result; + } + + /* (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 httpHeaders, OutputStream entityStream) + throws IOException, WebApplicationException { + 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 new file mode 100644 index 0000000000000..9b69c79942969 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java @@ -0,0 +1,43 @@ +/** + * 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 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 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/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..9c5ea3df46aef --- /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.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; +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 = { + "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) + }) + @XmlAnyElement(lax = true) + protected List feedChildren; + @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 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 feedChildren property. + * + *

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

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

+ * 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 >} + * + * + */ + public List getFeedChildren() { + if (feedChildren == null) { + feedChildren = new ArrayList(); + } + return this.feedChildren; + } + + /** + * 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; 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/AssetType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java new file mode 100644 index 0000000000000..9d48dfd71a29a --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java @@ -0,0 +1,171 @@ +/** + * 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; +import javax.xml.datatype.XMLGregorianCalendar; + +import com.microsoft.windowsazure.services.core.utils.DateConverter; +import com.microsoft.windowsazure.services.media.models.AssetInfo; + +/** + * This type maps the XML returned in the odata ATOM serialization + * for Asset entities. + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +public class AssetType implements MediaServiceDTO { + + @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; + } + + public static AssetType create(AssetInfo assetInfo) { + AssetType assetType = new AssetType(); + assetType.setAlternateId(assetInfo.getAlternateId()); + assetType.setCreated(DateConverter.DateToXMLGregorianCalendar(assetInfo.getCreated())); + assetType.setId(assetInfo.getId()); + assetType.setLastModified(DateConverter.DateToXMLGregorianCalendar(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/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..0e004668e6ac8 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/Constants.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.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/CreateAssetRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/CreateAssetRequest.java new file mode 100644 index 0000000000000..e93c2e7f6844d --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/CreateAssetRequest.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.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; + } +} 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..762cae0eed0b7 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaServiceDTO.java @@ -0,0 +1,14 @@ +package com.microsoft.windowsazure.services.media.implementation.content; + + +/** + * 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. + * + */ +public interface MediaServiceDTO { + +} 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..569cd17d4f3f9 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java @@ -0,0 +1,91 @@ +/** + * 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.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; + + /** + * 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/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..09cc9f513adba --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.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.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(); + } + + /** + * Create an instance of {@link ODataActionType } + * + * @return a new ODataActionType instance. + */ + 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..f4d608dd712a5 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java @@ -0,0 +1,88 @@ +/** + * 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 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 { + + public AccessPolicyInfo(EntryType entry, AccessPolicyType content) { + super(entry, content); + } + + 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 getPermissions() { + return AccessPolicyPermission.permissionsFromBits(getContent().getPermissions()); + } + + public AccessPolicyInfo setPermissions(EnumSet permissions) { + getContent().setPermissions(AccessPolicyPermission.bitsFromPermissions(permissions)); + return this; + } +} 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 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/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java new file mode 100644 index 0000000000000..736c2366a7d4b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.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.models; + +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; + +/** + * Data about a Media Services Asset entity. + * + */ +public class AssetInfo extends ODataEntity { + + public AssetInfo(EntryType entry, AssetType content) { + super(entry, content); + } + + public AssetInfo() { + super(new AssetType()); + } + + /** + * 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 AssetInfo 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 AssetInfo setName(String name) { + this.getContent().setName(name); + return this; + } + + /** + * Get the asset state + * + * @return the state + */ + 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 + * + * @return the date + */ + public Date getCreated() { + return DateConverter.XMLGregorianCalendarToDate(this.getContent().getCreated()); + } + + /** + * Set creation date + * + * @param created + * the date + * @return the asset info + */ + public AssetInfo setCreated(Date created) { + getContent().setCreated(DateConverter.DateToXMLGregorianCalendar(created)); + return this; + } + + /** + * Get last modified date + * + * @return the date + */ + public Date getLastModified() { + return DateConverter.XMLGregorianCalendarToDate(getContent().getLastModified()); + } + + /** + * Set last modified date + * + * @param lastModified + * the date + * @return the asset info + */ + public AssetInfo setLastModified(Date lastModified) { + getContent().setLastModified(DateConverter.DateToXMLGregorianCalendar(lastModified)); + return this; + } + + /** + * Get the alternate id + * + * @return the id + */ + 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 + * + * @return the options + */ + 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/AssetState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetState.java index 35a504b6da720..d3aeed54cef5b 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,18 +1,73 @@ +/* + * 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; + /** * 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; } + + /** + * Create an AssetState instance from the corresponding int. + * + * @param state + * state as integer + * @return new AssetState instance + */ + public static AssetState fromCode(int state) { + switch (state) { + case 0: + return AssetState.Initialized; + case 1: + return AssetState.Published; + case 2: + return AssetState.Deleted; + default: + throw new InvalidParameterException("state"); + } + } } 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/CreateAccessPolicyOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyOptions.java new file mode 100644 index 0000000000000..7c003d2e0cd02 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyOptions.java @@ -0,0 +1,84 @@ +/** + * 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 permissions = EnumSet.noneOf(AccessPolicyPermission.class); + + public CreateAccessPolicyOptions() { + } + + /** + * Returns a live pointer to the underlying permissions set. + * + * @return the permissions + */ + public EnumSet getPermissions() { + return permissions; + } + + /** + * Add the given permissions to this creation request + * + * @param permissionsToAdd + * @return the CreateAccessPolicyOptions object + */ + public CreateAccessPolicyOptions addPermissions(EnumSet 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 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/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..9905e36e8ef46 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptions.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; + +/** + * 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/EncryptionOption.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/EncryptionOption.java index 9e98aecb69aab..6b989e3aa279d 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. @@ -15,19 +15,60 @@ package com.microsoft.windowsazure.services.media.models; +import java.security.InvalidParameterException; + /** * 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; } + + /** + * Create an EncryptionOption instance based on the + * given integer. + * + * @param option + * the integer value of option + * @return The EncryptionOption + */ + public static EncryptionOption fromCode(int option) { + switch (option) { + case 0: + return EncryptionOption.None; + case 1: + return EncryptionOption.StorageEncrypted; + case 2: + return EncryptionOption.CommonEncryptionProtected; + default: + throw new InvalidParameterException("option"); + } + } } 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/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/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/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/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..dd0affeac070e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.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.models; + +/** + * 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; + } + +} 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 f77e7931062e0..1dbfd191a8e16 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 @@ -1540,10 +1540,13 @@ public QueuePermissions execute(final CloudQueueClient client, final CloudQueue * The access policy for the shared access signature. * @param groupPolicyIdentifier * A queue-level access policy. - * @return a shared access signature for the container. + * @return A shared access signature for the queue. * @throws InvalidKeyException + * If an invalid key was passed. * @throws StorageException + * If a storage service error occurred. * @throws IllegalArgumentException + * If an unexpected value is passed. */ public String generateSharedAccessSignature(final SharedAccessQueuePolicy policy, final String groupPolicyIdentifier) throws InvalidKeyException, StorageException { 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 6454f1b86fe8f..c502533633f14 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 @@ -26,30 +26,33 @@ public final class QueuePermissions { /** - * Gets the set of shared access policies for the table. + * Gets the set of shared access policies for the queue. */ private HashMap sharedAccessPolicies; /** - * Creates an instance of the TablePermissions class. + * Creates an instance of the QueuePermissions class. */ public QueuePermissions() { this.sharedAccessPolicies = new HashMap(); } /** - * Returns the set of shared access policies for the table. + * Returns the set of shared access policies for the queue. * - * @return A HashMap object of {@link SharedAccessTablePolicy} objects that represent the set of shared - * access policies for the table. + * @return A HashMap object of {@link SharedAccessQueuePolicy} objects that represent the set of shared + * access policies for the queue. */ public HashMap getSharedAccessPolicies() { return this.sharedAccessPolicies; } /** + * Sets the set of shared access policies for the queue. + * * @param sharedAccessPolicies - * the sharedAccessPolicies to set + * The set of shared access policies to set for the queue, represented by a HashMap object of + * {@link SharedAccessQueuePolicy} objects. */ public void setSharedAccessPolicies(final HashMap sharedAccessPolicies) { this.sharedAccessPolicies = sharedAccessPolicies; 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 bec37d8d33d12..10daa8af1f721 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 @@ -51,7 +51,7 @@ public enum SharedAccessQueuePermissions { * * @param value * The byte value to convert to the corresponding enum set. - * @return A java.util.EnumSet object that contains the SharedAccessPermissions values + * @return A java.util.EnumSet object that contains the SharedAccessQueuePermissions values * corresponding to the specified byte value. */ protected static EnumSet fromByte(final byte value) { 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 54bdf677ad44f..033e8d5056456 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 @@ -31,7 +31,7 @@ public final class SharedAccessQueuePolicy { * * @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 + * more of the following values. Note that they must be lower case, and the order that they are specified must * be in the order of "rwdl". *

    *
  • d: Delete access.
  • @@ -40,7 +40,7 @@ public final class SharedAccessQueuePolicy { *
  • w: Write access.
  • *
* - * @return A java.util.EnumSet object that contains {@link SharedAccessTablePermissions} values that + * @return A java.util.EnumSet object that contains {@link SharedAccessQueuePermissions} values that * represents the set of shared access permissions. */ public static EnumSet permissionsFromString(final String value) { @@ -121,52 +121,66 @@ public static String permissionsToString(final EnumSetSharedAccessTablePolicy class. + * Creates an instance of the SharedAccessQueuePolicy class. * */ public SharedAccessQueuePolicy() { // Empty Default Ctor } /** - * @return the permissions + * Gets the permissions for a shared access signature associated with this shared access policy. + * + * @return A java.util.EnumSet object that contains {@link SharedAccessQueuePermissions} values that + * represents the set of shared access permissions. */ public EnumSet getPermissions() { return this.permissions; } /** - * @return the sharedAccessExpiryTime + * Gets the expiry time for a shared access signature associated with this shared access policy. + * + * @return A Date object that contains the shared access signature expiry time. */ public Date getSharedAccessExpiryTime() { return this.sharedAccessExpiryTime; } /** - * @return the sharedAccessStartTime + * Gets the start time for a shared access signature associated with this shared access policy. + * + * @return A Date object that contains the shared access signature start time. */ public Date getSharedAccessStartTime() { return this.sharedAccessStartTime; } /** + * Sets the permissions for a shared access signature associated with this shared access policy. + * * @param permissions - * the permissions to set + * The permissions, represented by a java.util.EnumSet object that contains + * {@link SharedAccessQueuePermissions} values, to set for the shared access signature. */ public void setPermissions(final EnumSet permissions) { this.permissions = permissions; } /** + * Sets the expiry time for a shared access signature associated with this shared access policy. + * * @param sharedAccessExpiryTime - * the sharedAccessExpiryTime to set + * The expiry time to set for the shared access signature. */ public void setSharedAccessExpiryTime(final Date sharedAccessExpiryTime) { this.sharedAccessExpiryTime = sharedAccessExpiryTime; } /** + * Sets the start time for a shared access signature associated with this shared access policy. + * * @param sharedAccessStartTime - * the sharedAccessStartTime to set + * The start time to set for the shared access signature. */ public void setSharedAccessStartTime(final Date sharedAccessStartTime) { this.sharedAccessStartTime = sharedAccessStartTime; 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 2ec64eceaf53a..81f75835ae737 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 @@ -41,24 +41,24 @@ public final class CloudTable { /** - * Holds the name of the table. + * The name of the table. */ String name; /** - * Holds the URI of the table. + * The URI of the table. */ URI uri; /** - * Holds a reference to the associated service client. + * A reference to the associated service client. */ private final CloudTableClient tableServiceClient; /** - * Gets the name of the queue. + * Gets the name of the table. * - * @return A String object that represents the name of the queue. + * @return A String object that represents the name of the table. */ public String getName() { return this.name; @@ -74,9 +74,9 @@ public CloudTableClient getServiceClient() { } /** - * Gets the absolute URI for this queue. + * Gets the absolute URI for this table. * - * @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 table. */ public URI getUri() { return this.uri; @@ -85,7 +85,7 @@ public URI getUri() { /** * Creates an instance of the CloudTable class using the specified address and client. * - * @param tableAddress + * @param tableName * A String that represents the table name. * @param client * A {@link CloudTableClient} object that represents the associated service client, and that specifies @@ -148,7 +148,7 @@ public void create() throws StorageException { * safely ignore operation context. * * @throws StorageException - * if an error occurs accessing the storage service, or because the table cannot be + * If an error occurs accessing the storage service, or because the table cannot be * created, or already exists. */ @DoesServiceRequest @@ -188,7 +188,7 @@ public boolean createIfNotExist() throws StorageException { } /** - * Creates the table in the storage service with the specified request options and operation context if it does not + * Creates the table in the storage service with the specified request options and operation context, if it does not * already exist. * * @param options @@ -300,7 +300,7 @@ public void delete(TableRequestOptions options, OperationContext opContext) thro } /** - * Deletes the table from the storage service if it exists. + * Deletes the table from the storage service, if it exists. * * @return A value of true if the table existed in the storage service and has been deleted, otherwise * false. @@ -445,7 +445,7 @@ public void uploadPermissions(final TablePermissions permissions) throws Storage } /** - * Uploads the container's permissions using the specified request options and operation context. + * Uploads the table's permissions using the specified request options and operation context. * * @param permissions * A {@link TablePermissions} object that represents the permissions to upload. @@ -533,7 +533,7 @@ public TablePermissions downloadPermissions() throws StorageException { * 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. + * @return A {@link TablePermissions} object that represents the table's permissions. * * @throws StorageException * If a storage service error occurred. @@ -592,10 +592,13 @@ public TablePermissions execute(final CloudTableClient client, final CloudTable * The access policy for the shared access signature. * @param accessPolicyIdentifier * A table-level access policy. - * @return a shared access signature for the container. + * @return A String containing the shared access signature for the table. * @throws InvalidKeyException + * If an invalid key was passed. * @throws StorageException + * If a storage service error occurred. * @throws IllegalArgumentException + * If an unexpected value is passed. */ public String generateSharedAccessSignature(final SharedAccessTablePolicy policy, final String accessPolicyIdentifier, final String startPartitionKey, final String startRowKey, @@ -629,7 +632,7 @@ public String generateSharedAccessSignature(final SharedAccessTablePolicy policy /** * Returns the canonical name for shared access. * - * @return the canonical name for shared access. + * @return A String containing the canonical name for shared access. */ private String getSharedAccessCanonicalName() { if (this.tableServiceClient.isUsePathStyleUris()) { 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 3e75ac8e196c3..649f4208e6f19 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 @@ -51,7 +51,7 @@ public enum SharedAccessTablePermissions { * * @param value * The byte value to convert to the corresponding enum set. - * @return A java.util.EnumSet object that contains the SharedAccessPermissions values + * @return A java.util.EnumSet object that contains the SharedAccessTablePermissions values * corresponding to the specified byte value. */ protected static EnumSet fromByte(final byte value) { 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 adfaffb35385a..d5fc4c780104a 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 @@ -30,7 +30,7 @@ public final class SharedAccessTablePolicy { * * @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 + * more of the following values. Note that they must be lower case, and the order that they are specified must * be in the order of "rwdl". *
    *
  • d: Delete access.
  • @@ -72,7 +72,7 @@ public static EnumSet permissionsFromString(final * Converts the permissions specified for the shared access policy to a string. * * @param permissions - * A {@link SharedAccessTablePermissions} object that represents the shared access permissions. + * A set of {@link SharedAccessTablePermissions} objects that represent the shared access permissions. * * @return A String that represents the shared access permissions in the "rwdl" format, which is * described at {@link SharedAccessTablePermissions#permissionsFromString}. @@ -127,45 +127,59 @@ public SharedAccessTablePolicy() { } /** - * @return the permissions + * Gets the permissions for a shared access signature associated with this shared access policy. + * + * @return A java.util.EnumSet object that contains {@link SharedAccessTablePermissions} values that + * represents the set of shared access permissions. */ public EnumSet getPermissions() { return this.permissions; } /** - * @return the sharedAccessExpiryTime + * Gets the expiry time for a shared access signature associated with this shared access policy. + * + * @return A Date object that contains the shared access signature expiry time. */ public Date getSharedAccessExpiryTime() { return this.sharedAccessExpiryTime; } /** - * @return the sharedAccessStartTime + * Gets the start time for a shared access signature associated with this shared access policy. + * + * @return A Date object that contains the shared access signature start time. */ public Date getSharedAccessStartTime() { return this.sharedAccessStartTime; } /** + * Sets the permissions for a shared access signature associated with this shared access policy. + * * @param permissions - * the permissions to set + * The permissions, represented by a java.util.EnumSet object that contains + * {@link SharedAccessTablePermissions} values, to set for the shared access signature. */ public void setPermissions(final EnumSet permissions) { this.permissions = permissions; } /** + * Sets the expiry time for a shared access signature associated with this shared access policy. + * * @param sharedAccessExpiryTime - * the sharedAccessExpiryTime to set + * The expiry time to set for the shared access signature. */ public void setSharedAccessExpiryTime(final Date sharedAccessExpiryTime) { this.sharedAccessExpiryTime = sharedAccessExpiryTime; } /** + * Sets the start time for a shared access signature associated with this shared access policy. + * * @param sharedAccessStartTime - * the sharedAccessStartTime to set + * The start time to set for the shared access signature. */ public void setSharedAccessStartTime(final Date sharedAccessStartTime) { this.sharedAccessStartTime = sharedAccessStartTime; 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 4ba7bd8bdfa1c..d981a820d6b42 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 @@ -17,8 +17,9 @@ import java.util.HashMap; + /** - * Represents the permissions for a container. + * Represents the permissions for a table. */ public final class TablePermissions { @@ -46,8 +47,11 @@ public HashMap getSharedAccessPolicies() { } /** + * Sets the set of shared access policies for the table. + * * @param sharedAccessPolicies - * the sharedAccessPolicies to set + * The set of shared access policies to set for the table, represented by a HashMap object of + * {@link SharedAccessTablePolicy} objects. */ public void setSharedAccessPolicies(final HashMap sharedAccessPolicies) { this.sharedAccessPolicies = sharedAccessPolicies; 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 bd0671e3ece19..938db64c06d4a 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 @@ -51,7 +51,11 @@ public static void setup() throws URISyntaxException, StorageException, InvalidK httpAcc = CloudStorageAccount.getDevelopmentStorageAccount(); } else { - httpAcc = CloudStorageAccount.parse(CLOUD_ACCOUNT_HTTP); + String cloudAccount = CLOUD_ACCOUNT_HTTP; + cloudAccount = cloudAccount.replace("[ACCOUNT NAME]", System.getenv("blob.accountName")); + cloudAccount = cloudAccount.replace("[ACCOUNT KEY]", System.getenv("blob.accountKey")); + + httpAcc = CloudStorageAccount.parse(cloudAccount); } bClient = httpAcc.createCloudBlobClient(); 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..f91f09eb06b0a --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java @@ -0,0 +1,161 @@ +/** + * 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.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; + +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()); + } + + 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(testPrefix)) { + service.deleteAccessPolicy(policy.getId()); + } + } + } + + @Test + public void canCreateAccessPolicy() throws Exception { + AccessPolicyInfo policy = service.createAccessPolicy(testPrefix + "CanCreate", 5, + new CreateAccessPolicyOptions().addPermissions(EnumSet.of(AccessPolicyPermission.WRITE))); + + assertTrue(policy.getPermissions().contains(AccessPolicyPermission.WRITE)); + } + + @Test + public void canGetSinglePolicyById() throws Exception { + String expectedName = testPrefix + "GetOne"; + 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[] { testPrefix + "ListOne", testPrefix + "ListTwo" }; + for (String name : policyNames) { + service.createAccessPolicy(name, 3, new CreateAccessPolicyOptions().addPermissions(EnumSet.of( + AccessPolicyPermission.WRITE, AccessPolicyPermission.LIST))); + } + + List policies = service.listAccessPolicies(); + + assertNotNull(policies); + assertTrue(policies.size() >= 2); + + AccessPolicyInfo policy1 = null; + AccessPolicyInfo policy2 = null; + + for (AccessPolicyInfo policy : policies) { + if (policy.getName().equals(policyNames[0])) { + policy1 = policy; + } + 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() { + + @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(testPrefix + "ToDelete", 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/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..5b941aef9b446 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -0,0 +1,190 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.core.ServiceException; +import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; + +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 listAssetsResult = service.listAssets(null); + for (AssetInfo assetInfo : listAssetsResult) { + try { + service.deleteAsset(assetInfo.getId()); + } + catch (Exception e) { + e.printStackTrace(); + } + } + } + + @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 + AssetInfo expectedAsset = new AssetInfo().setName("testAssetName"); + + // Act + AssetInfo actualAsset = service.createAsset("testAssetName"); + + // Assert + assertEquals(expectedAsset.getName(), actualAsset.getName()); + } + + @Test + public void createAssetNullNameSuccess() throws ServiceException { + // Arrange + + // Act + AssetInfo actualAsset = service.createAsset(null); + + // Assert + assertNotNull(actualAsset); + } + + @Test + public void getAssetSuccess() throws Exception { + // Arrange + AssetInfo expectedAsset = new AssetInfo().setName("testGetAssetSuccess"); + AssetInfo assetInfo = service.createAsset("testGetAssetSuccess"); + + // Act + AssetInfo actualAsset = service.getAsset(assetInfo.getId()); + + // Assert + assertEquals(expectedAsset.getName(), actualAsset.getName()); + } + + @Test(expected = ServiceException.class) + public void getAssetFailedWithInvalidId() throws ServiceException { + // Arrange + AssetInfo expectedAsset = new AssetInfo().setId("IncorrectAssetId"); + + // Act + AssetInfo actualAsset = service.getAsset(expectedAsset.getId()); + + // Assert + assertTrue(false); + + } + + @Test + public void listAssetSuccess() throws ServiceException { + // Arrange + Collection listAssetResultBaseLine = service.listAssets(); + AssetInfo assetA = new AssetInfo(); + AssetInfo assetB = new AssetInfo(); + service.createAsset("assetA"); + service.createAsset("assetB"); + + // Act + Collection listAssetResult = service.listAssets(); + // Assert + + assertEquals(listAssetResultBaseLine.size() + 2, listAssetResult.size()); + } + + @Test + public void updateAssetSuccess() throws Exception { + // Arrange + + AssetInfo updatedAsset = service.createAsset("updateAssetSuccess"); + UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions().setName("updateAssetSuccessResult"); + updatedAsset.setName("updateAssetSuccessResult"); + + // Act + service.updateAsset(updatedAsset.getId(), updateAssetOptions); + AssetInfo actualAsset = service.getAsset(updatedAsset.getId()); + + // Assert + assertEquals(updatedAsset.getName(), actualAsset.getName()); + + } + + @Test(expected = ServiceException.class) + public void updateAssetFailedWithInvalidId() throws ServiceException { + // Arrange + UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions(); + + // Act + service.updateAsset("updateAssetFailedWithInvalidId", updateAssetOptions); + + // Assert + assertTrue(false); + } + + @Test + public void deleteAssetSuccess() throws Exception { + // Arrange + String assetName = "deleteAssetSuccess"; + AssetInfo assetInfo = service.createAsset(assetName); + List listAssetsResult = service.listAssets(null); + int assetCountBaseline = listAssetsResult.size(); + + // Act + service.deleteAsset(assetInfo.getId()); + + // Assert + listAssetsResult = service.listAssets(null); + assertEquals(assetCountBaseline - 1, listAssetsResult.size()); + } + + @Test(expected = ServiceException.class) + public void deleteAssetFailedWithInvalidId() throws ServiceException { + // 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() { @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 new file mode 100644 index 0000000000000..84a8d66b47d20 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java @@ -0,0 +1,105 @@ +/** + * 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 java.util.List; + +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.MediaContract; +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.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 { + + @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.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, true); + 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"); + + ODataAtomMarshaller m = new ODataAtomMarshaller(); + AssetType requestData = new AssetType(); + requestData.setName("firstTestAsset"); + requestData.setAlternateId("some external id"); + + 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() { + return new OAuthRestProxy(Client.create()); + } + + 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"); + } + + private ResourceLocationManager createLocationManager() throws URISyntaxException { + 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()); + } + + @Test + public void canRetrieveListOfAssets() throws Exception { + MediaContract client = MediaService.create(config); + List assets = client.listAssets(); + + Assert.assertNotNull(assets); + } + +} 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..80905eb549c3e --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java @@ -0,0 +1,95 @@ +/** + * 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.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; + +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; +import com.microsoft.windowsazure.services.media.implementation.content.Constants; +import com.microsoft.windowsazure.services.media.models.AssetInfo; + +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 canUnmarshallAssetFromFeed() throws Exception { + ODataAtomUnmarshaller um = new ODataAtomUnmarshaller(); + InputStream input = new ByteArrayInputStream(sampleFeedOneAsset.getBytes("UTF-8")); + 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 + 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(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(new JAXBElement(new QName(Constants.ATOM_NS, "entry"), EntryType.class, e), System.out); + + } +} 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); + } +} 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 new file mode 100644 index 0000000000000..2e974c81773c9 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java @@ -0,0 +1,119 @@ +/** + * 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; + +public class AssetInfoTest { + + @Test + public void testGetSetId() { + // Arrange + String expectedId = "expectedId"; + AssetInfo assetInfo = new AssetInfo(); + + // Act + String actualId = assetInfo.setId(expectedId).getId(); + + // Assert + assertEquals(expectedId, actualId); + + } + + @Test + public void testGetSetState() { + // Arrange + AssetState expectedState = AssetState.Published; + AssetInfo assetInfo = new AssetInfo(); + + // Act + AssetState actualState = assetInfo.setState(expectedState).getState(); + + // Assert + assertEquals(expectedState, actualState); + } + + @Test + public void testGetSetCreated() throws Exception { + // Arrange + Date expectedCreated = new Date(); + + AssetInfo assetInfo = new AssetInfo(); + + // Act + Date actualCreated = assetInfo.setCreated(expectedCreated).getCreated(); + + // Assert + assertEquals(expectedCreated, actualCreated); + + } + + @Test + public void testGetSetLastModified() throws Exception { + // Arrange + Date expectedLastModified = new Date(); + AssetInfo assetInfo = new AssetInfo(); + + // Act + Date actualLastModified = assetInfo.setLastModified(expectedLastModified).getLastModified(); + + // Assert + assertEquals(expectedLastModified, actualLastModified); + } + + @Test + public void testGetSetAlternateId() { + // Arrange + String expectedAlternateId = "testAlternateId"; + AssetInfo assetInfo = new AssetInfo(); + + // Act + String actualAlternateId = assetInfo.setAlternateId(expectedAlternateId).getAlternateId(); + + // Assert + assertEquals(expectedAlternateId, actualAlternateId); + } + + @Test + public void testGetSetName() { + // Arrange + String expectedName = "testName"; + AssetInfo assetInfo = new AssetInfo(); + + // Act + String actualName = assetInfo.setName(expectedName).getName(); + + // Assert + assertEquals(expectedName, actualName); + } + + @Test + public void testGetSetOptions() { + // Arrange + EncryptionOption expectedOptions = EncryptionOption.None; + AssetInfo assetInfo = new AssetInfo(); + + // Act + EncryptionOption actualOptions = assetInfo.setOptions(expectedOptions).getOptions(); + + // Assert + assertEquals(expectedOptions, actualOptions); + } + +} 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 deleted file mode 100644 index d622d9473bb04..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetTest.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.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<Locator> expectedLocators = new ArrayList<Locator>(); - Asset asset = new Asset(); - - // Act - Iterable<Locator> actualLocators = asset.setLocators(expectedLocators).getLocators(); - - // Assert - assertEquals(expectedLocators, actualLocators); - } - - @Test - public void testGetSetContentKeys() { - // Arrange - Iterable<ContentKey> expectedContentKeys = new ArrayList<ContentKey>(); - Asset asset = new Asset(); - - // Act - Iterable<ContentKey> actualContentKeys = asset.setContentKeys(expectedContentKeys).getContentKeys(); - - // Assert - assertEquals(expectedContentKeys, actualContentKeys); - } - - @Test - public void testGetSetFiles() { - // Arrange - Iterable<File> expectedFiles = new ArrayList<File>(); - Asset asset = new Asset(); - - // Act - Iterable<File> actualFiles = asset.setFiles(expectedFiles).getFiles(); - - // Assert - assertEquals(expectedFiles, actualFiles); - } - - @Test - public void testGetSetParentAsset() { - // Arrange - Iterable<Asset> expectedParentAssets = new ArrayList<Asset>(); - Asset asset = new Asset(); - - // Act - Iterable<Asset> 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/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); + } +} 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/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); 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); + } + +} 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 feb5b1ceb4a10..8144378d8577b 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 @@ -52,7 +52,11 @@ public static void setup() throws URISyntaxException, StorageException, InvalidK httpAcc = CloudStorageAccount.getDevelopmentStorageAccount(); } else { - httpAcc = CloudStorageAccount.parse(CLOUD_ACCOUNT_HTTP); + String cloudAccount = CLOUD_ACCOUNT_HTTP; + cloudAccount = cloudAccount.replace("[ACCOUNT NAME]", System.getenv("queue.accountName")); + cloudAccount = cloudAccount.replace("[ACCOUNT KEY]", System.getenv("queue.accountKey")); + + httpAcc = CloudStorageAccount.parse(cloudAccount); } qClient = httpAcc.createCloudQueueClient(); 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 4651f71acf0d6..74fdd4d911499 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 @@ -29,6 +29,7 @@ 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.ServiceTimeoutException; import com.microsoft.windowsazure.services.table.models.BatchOperations; import com.microsoft.windowsazure.services.table.models.BatchResult; import com.microsoft.windowsazure.services.table.models.BatchResult.DeleteEntity; @@ -1139,4 +1140,84 @@ public void batchNegativeWorks() throws Exception { assertEquals("Second result status code", 412, error.getError().getHttpStatusCode()); assertNull("Third result should be null", result.getEntries().get(2)); } + + @Test + public void settingTimeoutWorks() throws Exception { + Configuration config = createConfiguration(); + + // Set timeout to very short to force failure + config.setProperty(Configuration.PROPERTY_CONNECT_TIMEOUT, new Integer(1)); + config.setProperty(Configuration.PROPERTY_READ_TIMEOUT, new Integer(1)); + + TableContract service = TableService.create(config); + + try { + service.queryTables(); + fail("Exception should have been thrown"); + } + catch (ServiceTimeoutException ex) { + // No need to assert, test is if correct assertion type is thrown. + } + catch (Exception ex) { + fail("unexpected exception was thrown"); + } + finally { + // Clean up timeouts, they interfere with other tests otherwise + config.getProperties().remove(Configuration.PROPERTY_CONNECT_TIMEOUT); + config.getProperties().remove(Configuration.PROPERTY_READ_TIMEOUT); + } + } + + @Test + public void settingTimeoutFromStringWorks() throws Exception { + Configuration config = createConfiguration(); + + // Set timeout to very short to force failure + config.setProperty(Configuration.PROPERTY_CONNECT_TIMEOUT, "1"); + config.setProperty(Configuration.PROPERTY_READ_TIMEOUT, "1"); + + TableContract service = TableService.create(config); + + try { + service.queryTables(); + fail("Exception should have been thrown"); + } + catch (ServiceTimeoutException ex) { + // No need to assert, test is if correct assertion type is thrown. + } + catch (Exception ex) { + fail("unexpected exception was thrown"); + } + finally { + // Clean up timeouts, they interfere with other tests otherwise + config.getProperties().remove(Configuration.PROPERTY_CONNECT_TIMEOUT); + config.getProperties().remove(Configuration.PROPERTY_READ_TIMEOUT); + } + } + + @Test + public void settingTimeoutPrefixedFromConfigWorks() throws Exception { + Configuration config = createConfiguration(); + + TableContract service = TableService.create("testprefix", config); + + try { + service.queryTables(); + fail("Exception should have been thrown"); + } + catch (ServiceTimeoutException ex) { + // No need to assert, test is if correct assertion type is thrown. + } + catch (Exception ex) { + fail("unexpected exception was thrown"); + } + } + + @Test + public void prefixedTimeoutsGetLoaded() throws Exception { + Configuration config = createConfiguration(); + + assertEquals("3", config.getProperty("testprefix." + Configuration.PROPERTY_CONNECT_TIMEOUT)); + assertEquals("7", config.getProperty("testprefix." + Configuration.PROPERTY_READ_TIMEOUT)); + } } 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 d235ed326cc69..7ba57b75322c8 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 @@ -577,7 +577,11 @@ public static void setup() throws URISyntaxException, StorageException, InvalidK httpAcc = CloudStorageAccount.getDevelopmentStorageAccount(); } else { - httpAcc = CloudStorageAccount.parse(CLOUD_ACCOUNT_HTTP); + String cloudAccount = CLOUD_ACCOUNT_HTTP; + cloudAccount = cloudAccount.replace("[ACCOUNT NAME]", System.getenv("table.accountName")); + cloudAccount = cloudAccount.replace("[ACCOUNT KEY]", System.getenv("table.accountKey")); + + httpAcc = CloudStorageAccount.parse(cloudAccount); } bClient = httpAcc.createCloudBlobClient(); 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 3cc8639eb849c..54c5b84aab75a 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 @@ -2,25 +2,27 @@ * Copyright 2011 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this 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.utils; import static org.junit.Assert.*; import java.io.ByteArrayInputStream; +import java.net.SocketTimeoutException; import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceTimeoutException; import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientResponse; @@ -31,11 +33,11 @@ public class ServiceExceptionFactoryTest { public void serviceNameAndMessageAndCauseAppearInException() { // Arrange ClientResponse response = new ClientResponse(404, null, new ByteArrayInputStream(new byte[0]), null); - UniformInterfaceException cause = new UniformInterfaceException( - response); + UniformInterfaceException cause = new UniformInterfaceException(response); // Act - ServiceException exception = ServiceExceptionFactory.process("testing", new ServiceException("this is a test", cause)); + ServiceException exception = ServiceExceptionFactory.process("testing", new ServiceException("this is a test", + cause)); // Assert assertNotNull(exception); @@ -48,11 +50,11 @@ public void serviceNameAndMessageAndCauseAppearInException() { public void httpStatusCodeAndReasonPhraseAppearInException() { // Arrange ClientResponse response = new ClientResponse(404, null, new ByteArrayInputStream(new byte[0]), null); - UniformInterfaceException cause = new UniformInterfaceException( - response); + UniformInterfaceException cause = new UniformInterfaceException(response); // Act - ServiceException exception = ServiceExceptionFactory.process("testing", new ServiceException("this is a test", cause)); + ServiceException exception = ServiceExceptionFactory.process("testing", new ServiceException("this is a test", + cause)); // Assert assertNotNull(exception); @@ -65,7 +67,8 @@ public void informationWillPassUpIfServiceExceptionIsRootCauseOfClientHandlerExc // 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)); + ServiceException originalDescription = ServiceExceptionFactory.process("underlying", new ServiceException( + rootCause)); ClientHandlerException wrappingException = new ClientHandlerException(originalDescription); // Act @@ -76,4 +79,17 @@ public void informationWillPassUpIfServiceExceptionIsRootCauseOfClientHandlerExc assertEquals("underlying", exception.getServiceName()); } + @Test + public void socketTimeoutWillPassUpIfInsideClientHandlerException() { + String expectedMessage = "connect timeout"; + SocketTimeoutException rootCause = new SocketTimeoutException(expectedMessage); + ClientHandlerException wrappingException = new ClientHandlerException(rootCause); + + ServiceException exception = ServiceExceptionFactory + .process("testing", new ServiceException(wrappingException)); + + assertSame(ServiceTimeoutException.class, exception.getClass()); + assertEquals(expectedMessage, exception.getMessage()); + assertEquals("testing", 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 index 7739acd3e7333..dccc767257e8b 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,11 @@ 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 +testprefix.com.microsoft.windowsazure.services.core.Configuration.connectTimeout=3 +testprefix.com.microsoft.windowsazure.services.core.Configuration.readTimeout=7