diff options
Diffstat (limited to 'framework/src/main/java/org/onap/cli/fw/store/OnapCommandExecutionStore.java')
-rw-r--r-- | framework/src/main/java/org/onap/cli/fw/store/OnapCommandExecutionStore.java | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/store/OnapCommandExecutionStore.java b/framework/src/main/java/org/onap/cli/fw/store/OnapCommandExecutionStore.java index b0ebbda5..15996a8f 100644 --- a/framework/src/main/java/org/onap/cli/fw/store/OnapCommandExecutionStore.java +++ b/framework/src/main/java/org/onap/cli/fw/store/OnapCommandExecutionStore.java @@ -19,6 +19,9 @@ package org.onap.cli.fw.store; import java.io.File; import java.io.FilenameFilter; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; @@ -56,7 +59,7 @@ public class OnapCommandExecutionStore { private SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US); - private static String SEPARATOR = "__"; + private static final String SEPARATOR = "__"; private enum SearchMode { FIND, @@ -65,11 +68,11 @@ public class OnapCommandExecutionStore { } - private static SearchMode SEARCH_MODE = SearchMode.FILE; + private static SearchMode searchMode = SearchMode.FILE; static { String mode = OnapCommandConfig.getPropertyValue(OnapCommandConstants.OPEN_CLI_EXECUTION_SEARCH_MODE); if (mode.equalsIgnoreCase(SearchMode.FIND.name())) - SEARCH_MODE = SearchMode.FIND; + searchMode = SearchMode.FIND; } public static class ExecutionStoreContext { @@ -279,9 +282,11 @@ public class OnapCommandExecutionStore { FileUtils.touch(new File(context.getStorePath() + File.separator + COMPLETED)); else FileUtils.touch(new File(context.getStorePath() + File.separator + FAILED)); - - if(!new File(context.getStorePath() + File.separator + IN_PROGRESS).delete()){ - log.error("Failed to delete {}", context.getStorePath() + File.separator + IN_PROGRESS); + Path path= Paths.get(context.getStorePath() + File.separator + IN_PROGRESS); + try { + Files.delete(path); + } catch (IOException e) { + log.error("Failed to delete "+ context.getStorePath() + File.separator + IN_PROGRESS); } } catch (IOException e) { log.error("Failed to store the execution end details {}", context.storePath); @@ -334,7 +339,7 @@ public class OnapCommandExecutionStore { try { List <String> dirs = new ArrayList<>(); - if (System.getProperty("os.name").toLowerCase().startsWith("windows") || SEARCH_MODE.equals(SearchMode.FILE)) { + if (System.getProperty("os.name").toLowerCase().startsWith("windows") || searchMode.equals(SearchMode.FILE)) { for (File f: new File(getBasePath()).listFiles()) { if(search.containsKey(EXECUTIONID)) { if (f.getName().startsWith(search.get(EXECUTIONID))) @@ -347,7 +352,6 @@ public class OnapCommandExecutionStore { if (f.getName().startsWith(search.get(REQUESTID))) dirs.add(f.getAbsolutePath()); - continue; } else @@ -449,12 +453,9 @@ public class OnapCommandExecutionStore { } private File getExecutionDir(String executionId) throws OnapCommandExecutionNotFound { - File []f = new File(getBasePath()).listFiles(new FilenameFilter() { - - @Override - public boolean accept(File dir, String name) { - return name.startsWith(executionId); - } + File []f = new File(getBasePath()).listFiles((dir, name) -> { + if (name.startsWith(executionId)) return true; + return false; }); if (f.length == 0) { |