/** * Deletes all dataset modules in a namespace. * * @throws DatasetModuleCannotBeDeletedException if one of the dataset modules cannot be deleted, * usually due to existing dataset instances using the dataset module * @throws IOException if a network error occurred * @throws UnauthenticatedException if the request is not authorized successfully in the gateway server */ public void deleteAll(NamespaceId namespace) throws DatasetModuleCannotBeDeletedException, IOException, UnauthenticatedException, UnauthorizedException { URL url = config.resolveNamespacedURLV3(namespace, "data/modules"); HttpResponse response = restClient.execute(HttpMethod.DELETE, url, config.getAccessToken(), HttpURLConnection.HTTP_CONFLICT); if (response.getResponseCode() == HttpURLConnection.HTTP_CONFLICT) { // TODO: exception for all modules throw new DatasetModuleCannotBeDeletedException(null); } }
/** * Deletes the specified {@link DatasetModuleId} */ @Override public void delete(DatasetModuleId datasetModuleId) throws Exception { NamespaceId namespaceId = datasetModuleId.getParent(); if (NamespaceId.SYSTEM.equals(namespaceId)) { throw new UnsupportedOperationException( String.format("Cannot delete module '%s' from '%s' namespace.", datasetModuleId.getModule(), datasetModuleId.getNamespace())); } ensureNamespaceExists(namespaceId); DatasetModuleMeta moduleMeta = typeManager.getModule(datasetModuleId); if (moduleMeta == null) { throw new DatasetModuleNotFoundException(datasetModuleId); } try { typeManager.deleteModule(datasetModuleId); } catch (DatasetModuleConflictException e) { throw new DatasetModuleCannotBeDeletedException(datasetModuleId, e.getMessage()); } }
/** * Deletes the specified {@link DatasetModuleId} */ @Override public void delete(DatasetModuleId datasetModuleId) throws Exception { NamespaceId namespaceId = datasetModuleId.getParent(); if (NamespaceId.SYSTEM.equals(namespaceId)) { throw new UnsupportedOperationException( String.format("Cannot delete module '%s' from '%s' namespace.", datasetModuleId.getModule(), datasetModuleId.getNamespace())); } ensureNamespaceExists(namespaceId); DatasetModuleMeta moduleMeta = typeManager.getModule(datasetModuleId); if (moduleMeta == null) { throw new DatasetModuleNotFoundException(datasetModuleId); } try { typeManager.deleteModule(datasetModuleId); } catch (DatasetModuleConflictException e) { throw new DatasetModuleCannotBeDeletedException(datasetModuleId, e.getMessage()); } }
/** * Deletes a dataset module. * * @param module the dataset module to delete * @throws DatasetModuleCannotBeDeletedException if the dataset module cannot be deleted, * usually due to other dataset modules or dataset instances using the dataset module * @throws DatasetModuleNotFoundException if the dataset module with the specified name was not found * @throws IOException if a network error occurred * @throws UnauthenticatedException if the request is not authorized successfully in the gateway server */ public void delete(DatasetModuleId module) throws DatasetModuleCannotBeDeletedException, DatasetModuleNotFoundException, IOException, UnauthenticatedException, UnauthorizedException { URL url = config.resolveNamespacedURLV3(module.getParent(), String.format("data/modules/%s", module.getModule())); HttpResponse response = restClient.execute(HttpMethod.DELETE, url, config.getAccessToken(), HttpURLConnection.HTTP_CONFLICT, HttpURLConnection.HTTP_NOT_FOUND); if (response.getResponseCode() == HttpURLConnection.HTTP_CONFLICT) { throw new DatasetModuleCannotBeDeletedException(module); } else if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) { throw new DatasetModuleNotFoundException(module); } }