@Override public void handleError(Throwable t) { LOG.error("Error uploading version {} of resource {} of type {} for account {}.", version, name, resourceType, account, t); try { os.close(); // deletion flags the entry in the database as deleted metaStoreService.getResourceTypeView(account, resourceType).delete(name, version); // dont need the file in the plugin store if there was an error so delete it pluginStore.deleteResource(account, resourceType, name, version); responder.sendError(HttpResponseStatus.INTERNAL_SERVER_ERROR, t.getCause().getMessage()); } catch (IOException e) { LOG.error("Error uploading resource {} of type {} for account {}.", resourceMeta, resourceType, account, e); } } };
LOG.debug("deleted version {} of resource {} of type {} for account {} from meta store.", version, name, resourceType, account); pluginStore.deleteResource(account, resourceType, meta.getName(), meta.getVersion()); LOG.debug("deleted version {} of resource {} of type {} for account {} from plugin store.", version, name, resourceType, account);
pluginStore.deleteResource(account, resourceType, meta.getName(), meta.getVersion()); LOG.debug("deleted version {} of resource {} of type {} for account {}.", meta.getVersion(), name, resourceType, account);
@Test public void testDeleteWithinTenant() throws Exception { PluginStore store = getInitializedStore(); String contents = "hadoop cookbook"; ResourceType resourceType = new ResourceType(PluginType.AUTOMATOR, "chef-solo", "cookbooks"); String name = "hadoop"; int version = 1; // write different versions of the same module writeToStore(store, account1, resourceType, name, version, contents); // check it's there. Assert.assertEquals(contents, readFromStore(store, account1, resourceType, name, version)); // delete and check there's nothing store.deleteResource(account1, resourceType, name, version); Assert.assertNull(store.getResourceInputStream(account1, resourceType, name, version)); }
@Test public void testDeleteOnlyAffectsTenant() throws Exception { PluginStore store = getInitializedStore(); String contents = "hadoop cookbook"; ResourceType resourceType = new ResourceType(PluginType.AUTOMATOR, "chef-solo", "cookbooks"); String name = "hadoop"; int version = 1; // write different versions of the same module writeToStore(store, account1, resourceType, name, version, contents); writeToStore(store, account2, resourceType, name, version, contents); // check it's there. Assert.assertEquals(contents, readFromStore(store, account1, resourceType, name, version)); Assert.assertEquals(contents, readFromStore(store, account2, resourceType, name, version)); // delete and check there's nothing for the tenant it was deleted from, but is still there for the other store.deleteResource(account1, resourceType, name, version); Assert.assertNull(store.getResourceInputStream(account1, resourceType, name, version)); Assert.assertEquals(contents, readFromStore(store, account2, resourceType, name, version)); }