diff --git a/weaver/sdks/corda/src/main/kotlin/org/hyperledger/cacti/weaver/sdk/corda/CredentialsExtractor.java b/weaver/sdks/corda/src/main/kotlin/org/hyperledger/cacti/weaver/sdk/corda/CredentialsExtractor.java index 8b36177e22..cb02067823 100644 --- a/weaver/sdks/corda/src/main/kotlin/org/hyperledger/cacti/weaver/sdk/corda/CredentialsExtractor.java +++ b/weaver/sdks/corda/src/main/kotlin/org/hyperledger/cacti/weaver/sdk/corda/CredentialsExtractor.java @@ -290,13 +290,19 @@ private static JsonObject getNodeTlsCertChain(KeyStore ks, JsonObject configObj, return configObj; } - private static void deleteFolder(File folder) { + private static void deleteFolder(File folder) throws Exception { if (folder.isDirectory()) { - for (File subf: folder.listFiles()) { - deleteFolder(subf); + for (File subf : folder.listFiles()) { + try { + deleteFolder(subf); + } catch (Exception e) { + String errorMessage = "An error occurred while deleting : " + subf.getPath(); + throw new Exception(errorMessage); + } } } folder.delete(); + System.out.println((folder.exists() ? "Failed to delete : " : "Deleted successfully : ") + folder.getPath()); } public static String getConfig(String baseNodesPath, String[] nodes) { @@ -326,7 +332,11 @@ public static String getConfig(String baseNodesPath, String[] nodes) { //} configObj.add(node, nodeConfigObj); } - deleteFolder(new File(tempStore)); + try { + deleteFolder(new File(tempStore)); + } catch (Exception e) { + e.printStackTrace(); + } System.out.println("Extracted configuration for " + node); } System.out.println("Extracted configuration for all nodes");