Skip to content

Commit

Permalink
RESOLVED #7988: Cachedb-import: Exportación
Browse files Browse the repository at this point in the history
  • Loading branch information
martalite committed Dec 14, 2024
1 parent 4e54f96 commit cfd72a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/main/java/es/litesolutions/cache/RESTRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand All @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> arguments)
Expand All @@ -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
Expand Down Expand Up @@ -69,7 +72,12 @@ void writeItems(final Set<String> 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());
Expand Down

0 comments on commit cfd72a1

Please sign in to comment.