/** * Get the number of all versions of all resources in the account. Resources can be in any state. * * @param account Account to get the number of resources for * @return Number of resources in the account * @throws IOException */ public int numResources(Account account) throws IOException { return metaStoreService.getAccountView(account).numResources(); }
/** * Update the metadata store, syncing the resources in the given collection for the given account. * * @param account Account containing resources to sync * @param resourceCollection Collection of synced resources * @throws IOException */ public void syncResourceMeta(Account account, ResourceCollection resourceCollection) throws IOException { metaStoreService.getAccountView(account).syncResources(resourceCollection); }
@Test public void testGetNumResources() throws Exception { PluginMetaStoreService service = getPluginResourceMetaStoreService(); // for account1 write 6 resources (7 but one is deleted) in all different states service.getResourceTypeView(account1, type1).add(new ResourceMeta("r1", 1, ResourceStatus.ACTIVE)); service.getResourceTypeView(account1, type1).add(new ResourceMeta("r1", 2, ResourceStatus.INACTIVE)); service.getResourceTypeView(account1, type1).add(new ResourceMeta("r2", 1, ResourceStatus.INACTIVE)); service.getResourceTypeView(account1, type1).add(new ResourceMeta("r2", 2, ResourceStatus.STAGED)); service.getResourceTypeView(account1, type2).add(new ResourceMeta("r3", 1, ResourceStatus.RECALLED)); service.getResourceTypeView(account1, type2).add(new ResourceMeta("r3", 2, ResourceStatus.STAGED)); service.getResourceTypeView(account1, type2).add(new ResourceMeta("r3", 3, ResourceStatus.STAGED)); service.getResourceTypeView(account1, type2).delete("r3", 3); Assert.assertEquals(6, service.getAccountView(account1).numResources()); // account 2 should have nothing Assert.assertEquals(0, service.getAccountView(account2).numResources()); }
syncedResources.addResources(type2, new ResourceTypeSpecification(ResourceTypeFormat.FILE, "400"), ImmutableSet.of(bob2, sally1)); service.getAccountView(account1).syncResources(syncedResources);