From cfd72a1c80883e5e36a000fd4b8f42614ec98fbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Gonz=C3=A1lez?= Date: Sat, 14 Dec 2024 14:47:09 +0100 Subject: [PATCH] =?UTF-8?q?RESOLVED=20#7988:=20Cachedb-import:=20Exportaci?= =?UTF-8?q?=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/es/litesolutions/cache/RESTRunner.java | 3 ++- .../es/litesolutions/cache/commands/ExportCommand.java | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/es/litesolutions/cache/RESTRunner.java b/src/main/java/es/litesolutions/cache/RESTRunner.java index a2f9bd6..0c171ea 100644 --- a/src/main/java/es/litesolutions/cache/RESTRunner.java +++ b/src/main/java/es/litesolutions/cache/RESTRunner.java @@ -300,7 +300,7 @@ private JsonObject request(String method, String requestURL, JsonObject data) th try { resultObject = JsonParser.parseReader(in).getAsJsonObject(); } catch (Exception ex) { -// ex.printStackTrace(); + //ex.printStackTrace(); } String status = ""; @@ -310,6 +310,7 @@ private JsonObject request(String method, String requestURL, JsonObject data) th status = result.get("status").getAsString(); } } catch (Exception ex) { + ex.printStackTrace(); status = "Unexpected status: " + connection.getResponseMessage(); } if (!status.isEmpty()) { diff --git a/src/main/java/es/litesolutions/cache/commands/ExportCommand.java b/src/main/java/es/litesolutions/cache/commands/ExportCommand.java index f3f7ebd..efb7496 100644 --- a/src/main/java/es/litesolutions/cache/commands/ExportCommand.java +++ b/src/main/java/es/litesolutions/cache/commands/ExportCommand.java @@ -25,9 +25,11 @@ public final class ExportCommand private static final String OVERWRITE = "overwrite"; private static final String OVERWRITE_DEFAULT = "false"; + private static final String PACKAGE = "package"; // New argument private final Path outputDir; private final boolean overwrite; + private final String packageFilter; // Package filter public ExportCommand(final Connection connection, String restUrl, final Map arguments) @@ -37,6 +39,7 @@ public ExportCommand(final Connection connection, String restUrl, outputDir = Paths.get(getArgument(OUTPUTDIR)).toAbsolutePath(); overwrite = Boolean.parseBoolean(getArgumentOrDefault(OVERWRITE, OVERWRITE_DEFAULT)); + packageFilter = getArgumentOrDefault(PACKAGE, ""); // Get package argument, default is empty } @Override @@ -69,7 +72,12 @@ void writeItems(final Set items) { Path out; - for (final String itemName: items) { + for (final String itemName : items) { + // Filter items by package + if (!packageFilter.isEmpty() && !itemName.startsWith(packageFilter)) { + continue; + } + final String itemFileName = itemName; out = computePath(itemFileName); Files.createDirectories(out.getParent());