Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added property to overwrite existing file when creating siard file #460

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading