private void deleteLocation(NamespaceId namespaceId) throws IOException { // TODO: CDAP-1581: Implement soft delete Location namespaceHome = namespacePathLocator.get(namespaceId); try { if (hasCustomLocation(namespaceQueryAdmin.get(namespaceId))) { LOG.debug("Custom location mapping {} was found while deleting namespace {}. Deleting all data inside it but" + "skipping namespace home directory delete.", namespaceHome, namespaceId); // delete everything inside the namespace home but not the namespace home as its user owned directory Locations.deleteContent(namespaceHome); } else { // a custom location was not provided for this namespace so cdap is responsible for managing the lifecycle of // the location hence delete it. if (namespaceHome.exists() && !namespaceHome.delete(true)) { throw new IOException(String.format("Error while deleting home directory '%s' for namespace '%s'", namespaceHome, namespaceId)); } } } catch (Exception e) { throw new IOException(String.format("Error while deleting home directory %s for namespace %s ", namespaceHome, namespaceId), e); } }
private void deleteLocation(NamespaceId namespaceId) throws IOException { // TODO: CDAP-1581: Implement soft delete Location namespaceHome = namespacedLocationFactory.get(namespaceId); try { if (hasCustomLocation(namespaceQueryAdmin.get(namespaceId))) { LOG.debug("Custom location mapping {} was found while deleting namespace {}. Deleting all data inside it but" + "skipping namespace home directory delete.", namespaceHome, namespaceId); // delete everything inside the namespace home but not the namespace home as its user owned directory Locations.deleteContent(namespaceHome); } else { // a custom location was not provided for this namespace so cdap is responsible for managing the lifecycle of // the location hence delete it. if (namespaceHome.exists() && !namespaceHome.delete(true)) { throw new IOException(String.format("Error while deleting home directory '%s' for namespace '%s'", namespaceHome, namespaceId)); } } } catch (Exception e) { throw new IOException(String.format("Error while deleting home directory %s for namespace %s ", namespaceHome, namespaceId), e); } }
Locations.deleteContent(deletedLocation);