Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Locator relationships added

  • Loading branch information...
commit d9dc999ca0aa94b3bb985be029a9572254227bab 1 parent a11747d
@christav christav authored
View
21 ...src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetOperation.java
@@ -15,7 +15,6 @@
package com.microsoft.windowsazure.services.media.implementation.entities;
-
/**
* Generic implementation of the get operation usable for most entities
*
@@ -23,10 +22,28 @@
public class DefaultGetOperation<T> extends EntityOperationSingleResultBase<T> implements EntityGetOperation<T> {
/**
- * @param uri
+ * Construct a new DefaultGetOperation to return the given entity id
+ *
+ * @param entityTypeUri
+ * Entity set URI
+ * @param entityId
+ * id of entity
* @param responseClass
+ * class to return from the get operation
*/
public DefaultGetOperation(String entityTypeUri, String entityId, Class<T> responseClass) {
super(new EntityOperationBase.EntityIdUriBuilder(entityTypeUri, entityId), responseClass);
}
+
+ /**
+ * Construct a new DefaultGetOperation to return the entity from the given uri
+ *
+ * @param uri
+ * Uri for entity
+ * @param responseClass
+ * class to return from the get operation
+ */
+ public DefaultGetOperation(String uri, Class<T> responseClass) {
+ super(uri, responseClass);
+ }
}
View
11 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java
@@ -91,6 +91,17 @@ public Object getRequestContents() {
}
/**
+ * Create an operation that will retrieve the access policy at the given link
+ *
+ * @param link
+ * the link
+ * @return the operation
+ */
+ public static EntityGetOperation<AccessPolicyInfo> get(LinkInfo link) {
+ return new DefaultGetOperation<AccessPolicyInfo>(link.getHref(), AccessPolicyInfo.class);
+ }
+
+ /**
* Create an operation that will retrieve all access policies
*
* @return the operation
View
11 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java
@@ -162,6 +162,17 @@ public Creator setState(AssetState state) {
}
/**
+ * Get the asset at the given link
+ *
+ * @param link
+ * the link
+ * @return the get operation
+ */
+ public static EntityGetOperation<AssetInfo> get(LinkInfo link) {
+ return new DefaultGetOperation<AssetInfo>(link.getHref(), AssetInfo.class);
+ }
+
+ /**
* Create an operation that will list all the assets.
*
* @return The list operation
View
18 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java
@@ -118,4 +118,22 @@ public String getBaseUri() {
public String getContentAccessToken() {
return this.getContent().getContentAccessComponent();
}
+
+ /**
+ * Return a link that gets this locator's access policy
+ *
+ * @return the link
+ */
+ public LinkInfo getAccessPolicyLink() {
+ return getRelationLink("AccessPolicy");
+ }
+
+ /**
+ * Return a link that gets this locator's asset
+ *
+ * @return the link
+ */
+ public LinkInfo getAssetLink() {
+ return getRelationLink("Asset");
+ }
}
View
21 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java
@@ -304,4 +304,25 @@ public void canGetLocatorBackFromAsset() throws Exception {
assertEquals(locator.getId(), locators.get(0).getId());
}
+
+ @Test
+ public void canGetAssetFromLocator() throws Exception {
+ LocatorInfo locator = service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(),
+ LocatorType.SAS));
+
+ AssetInfo asset = service.get(Asset.get(locator.getAssetLink()));
+
+ assertEquals(assetInfo.getId(), asset.getId());
+ }
+
+ @Test
+ public void canGetAccessPolicyFromLocator() throws Exception {
+ LocatorInfo locator = service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(),
+ LocatorType.SAS));
+
+ AccessPolicyInfo accessPolicy = service.get(AccessPolicy.get(locator.getAccessPolicyLink()));
+
+ assertEquals(accessPolicyInfo.getId(), accessPolicy.getId());
+
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.