Skip to content

Commit

Permalink
added property to overwrite existing file when creating siard file
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioG70 committed Dec 23, 2024
1 parent 2164f82 commit 2fa5456
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ public class ViewerConfiguration extends ViewerAbstractConfiguration {
public static final String PRESENTATION_EXTERNAL_SERVICE_NAME = "ui.iiif_viewer.presentation.service_name";
public static final String VIEWER_ENABLED = "ui.iiif_viewer.enabled";

public static final String OVERWRITE_EXISTING_FILE = "overwrite.existing.file";

private static boolean instantiatedWithoutErrors = true;
private static String applicationEnvironment = ViewerConstants.APPLICATION_ENV_SERVER;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
package com.databasepreservation.common.server.storage.fs;

import com.databasepreservation.common.server.ViewerConfiguration;
import com.databasepreservation.common.server.storage.ContentPayload;

import java.io.IOException;
Expand All @@ -31,11 +32,17 @@ public InputStream createInputStream() throws IOException {
return Files.newInputStream(path);
}

@Override
public void writeToPath(Path outPath) throws IOException {
// Files.copy(path, outPath, StandardCopyOption.REPLACE_EXISTING);
Files.copy(path, outPath);
@Override
public void writeToPath(Path outPath) throws IOException {
boolean allowOverwrite = ViewerConfiguration.getInstance().getViewerConfigurationAsBoolean(false,
ViewerConfiguration.OVERWRITE_EXISTING_FILE);

if (allowOverwrite) {
Files.copy(path, outPath, StandardCopyOption.REPLACE_EXISTING);
} else {
Files.copy(path, outPath);
}
}

@Override
public URI getURI() throws IOException, UnsupportedOperationException {
Expand Down
7 changes: 6 additions & 1 deletion src/main/resources/config/dbvtk-viewer.properties
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,9 @@ ui.searchAll.defaultSelection=all
# Default: "UTC"
# Possible values: Any valid Java ZoneId string
##############################################
permissions.expiry.zoneId.override=UTC
permissions.expiry.zoneId.override=UTC

###############################################
# Overwrite existing file when creating siard file
##############################################
overwrite.existing.file=false

0 comments on commit 2fa5456

Please sign in to comment.