From 6d59ad6805969bbeb2d151a04c2432ac31a4594a Mon Sep 17 00:00:00 2001 From: Andrei Molnar <1995am@pm.me> Date: Tue, 17 Nov 2026 23:38:32 +0100 Subject: [PATCH] Refactor --- .../sopa/calllog/CallLogRepository.java | 2 +- .../sopa/project/ProjectRepository.java | 42 +------------------ .../sopa/step/StepRepository.java | 2 +- 3 files changed, 3 insertions(+), 43 deletions(-) diff --git a/src/main/java/com/molnarandrei/sopa/calllog/CallLogRepository.java b/src/main/java/com/molnarandrei/sopa/calllog/CallLogRepository.java index 28fbef9..5c96376 100644 --- a/src/main/java/com/molnarandrei/sopa/calllog/CallLogRepository.java +++ b/src/main/java/com/molnarandrei/sopa/calllog/CallLogRepository.java @@ -76,7 +76,7 @@ public class CallLogRepository { public static CallLog get(Path responsePath) throws RepositoryException { if (! Files.isRegularFile(responsePath)) throw new DoesNotExistException(responsePath, "Unreadable"); - String response = ""; + String response; try { response = FileSystemCache.read(responsePath); } catch (IOException raise) { diff --git a/src/main/java/com/molnarandrei/sopa/project/ProjectRepository.java b/src/main/java/com/molnarandrei/sopa/project/ProjectRepository.java index 157a34a..26a24a7 100644 --- a/src/main/java/com/molnarandrei/sopa/project/ProjectRepository.java +++ b/src/main/java/com/molnarandrei/sopa/project/ProjectRepository.java @@ -17,13 +17,8 @@ import java.nio.file.Path; import java.util.Comparator; import java.util.logging.Logger; -/** - * IO operations belong here. - * Assume the filesystem to be the single source of truth. - * IDEA filelocks? - */ + public class ProjectRepository { - private static final Logger log = Logger.getLogger(ProjectRepository.class.getName()); public static Project get(Path projectPath) throws RepositoryException { @@ -45,10 +40,6 @@ public class ProjectRepository { } } - public static boolean isProjectFolder(Path projectDir) { - return Files.isReadable(projectDir.resolve("project.yml")); - } - public static void update(Path projectPath, Project project) throws RepositoryException{ try { var yaml = Yaml.toYaml(project); @@ -132,37 +123,6 @@ public class ProjectRepository { } } - public static void deleteProject(Path projectPath) throws RepositoryException { - if (! Files.exists(projectPath)) { - return; - } - - var projectDirectory = projectPath.getParent(); - try { - if (! Files.isDirectory(projectDirectory)) - return; - - try (var walk = Files.walk(projectDirectory)) { - walk.sorted(Comparator.reverseOrder()) - .forEach(p -> { - try { - Files.delete(p); - } catch (IOException ignore) {} - }); - } - - if (Files.exists(projectDirectory)) - throw new IOException("Not deleted."); - - } catch (IOException io) { - throw new RepositoryException(projectPath, "Could not delete project", io); - - } finally { - FileSystemCache.remove(projectDirectory); - ProjectMonitors.trigger(projectDirectory); - } - } - /** Moves the folder of a closed project to the {@link Trash}. @return where it is kept. */ public static Path trashProject(Path projectPath) throws RepositoryException { try { diff --git a/src/main/java/com/molnarandrei/sopa/step/StepRepository.java b/src/main/java/com/molnarandrei/sopa/step/StepRepository.java index 4987557..0abc6f9 100644 --- a/src/main/java/com/molnarandrei/sopa/step/StepRepository.java +++ b/src/main/java/com/molnarandrei/sopa/step/StepRepository.java @@ -139,7 +139,7 @@ public class StepRepository { throw new RepositoryException(toStepPath, "Step is not part of '%s'".formatted(toTestCaseFolderPath)); var shiftIndex = targetIndex + (putBefore? 0: 1); - var orderedSteps = new ArrayList(allSteps); + var orderedSteps = new ArrayList<>(allSteps); orderedSteps.add(shiftIndex, fromStepPath); var shifting = new LinkedHashMap();