Permalink
Browse files

Getting locators from assets

  • Loading branch information...
1 parent be1c86f commit 21ca170033dd65a39d54ccf3ff65bcdea8fd0d22 @christav christav committed Dec 14, 2012
@@ -119,4 +119,13 @@ public LinkInfo getAssetFilesLink() {
public LinkInfo getContentKeysLink() {
return getRelationLink("ContentKeys");
}
+
+ /**
+ * Get a link to the asset's locators
+ *
+ * @return the link
+ */
+ public LinkInfo getLocatorsLink() {
+ return getRelationLink("Locators");
+ }
}
@@ -211,6 +211,18 @@ public Creator setContentAccessComponent(String contentAccessComponent) {
}, queryParameters);
}
+ /**
+ * Create an operation that will list all the locators at the given link.
+ *
+ * @param link
+ * Link to request locators from.
+ * @return The list operation.
+ */
+ public static DefaultListOperation<LocatorInfo> list(LinkInfo link) {
+ return new DefaultListOperation<LocatorInfo>(link.getHref(), new GenericType<ListResult<LocatorInfo>>() {
+ });
+ }
+
/**
* Create an operation to update the given locator.
*
@@ -292,4 +292,16 @@ public void deleteLocatorInvalidIdFailed() throws ServiceException {
expectedException.expect(new ServiceExceptionMatcher(400));
service.delete(Locator.delete(invalidId));
}
+
+ @Test
+ public void canGetLocatorBackFromAsset() throws Exception {
+ LocatorInfo locator = service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(),
+ LocatorType.SAS));
+
+ ListResult<LocatorInfo> locators = service.list(Locator.list(assetInfo.getLocatorsLink()));
+
+ assertEquals(1, locators.size());
+ assertEquals(locator.getId(), locators.get(0).getId());
+
+ }
}

0 comments on commit 21ca170

Please sign in to comment.