diff --git a/dev/codeserver/pom.xml b/dev/codeserver/pom.xml
index 36ab40e8f..3c4cbde25 100644
--- a/dev/codeserver/pom.xml
+++ b/dev/codeserver/pom.xml
@@ -62,13 +62,13 @@
com.databasepreservation
dbptk-bindings
- 2.0.0
+ 2.1.0-SNAPSHOT
pom
com.databasepreservation
dbptk-bindings-siard2-1
- 2.0.0
+ 2.1.0-SNAPSHOT
com.databasepreservation
diff --git a/pom.xml b/pom.xml
index 003e4ab6f..1c2789c70 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@
2.11.0
provided
- 3.0.0
+ 3.1.0-SNAPSHOT
5.4.0
3.1.6
2.2.20
@@ -486,13 +486,23 @@
com.databasepreservation
dbptk-bindings
- 2.0.0
+ 2.1.0-SNAPSHOT
pom
com.databasepreservation
dbptk-bindings-siard2-1
- 2.0.0
+ 2.1.0-SNAPSHOT
+
+
+ com.databasepreservation
+ dbptk-bindings-siarddk-128
+ 2.1.0-SNAPSHOT
+
+
+ com.databasepreservation
+ dbptk-bindings-siarddk-1007
+ 2.1.0-SNAPSHOT
com.databasepreservation
diff --git a/src/main/java/com/databasepreservation/DBVTK.java b/src/main/java/com/databasepreservation/DBVTK.java
index 07d1a9660..540e2f405 100644
--- a/src/main/java/com/databasepreservation/DBVTK.java
+++ b/src/main/java/com/databasepreservation/DBVTK.java
@@ -132,7 +132,7 @@ public FilterRegistrationBean casSingleSignOutFilter() {
FilterRegistrationBean registrationBean = new FilterRegistrationBean<>();
registrationBean.setFilter(new OnOffFilter());
registrationBean.setName("CasSingleSignOutFilter");
- registrationBean.addInitParameter("inner-filter-class", "org.jasig.cas.client.session.SingleSignOutFilter");
+ registrationBean.addInitParameter("inner-filter-class", "org.apereo.cas.client.session.SingleSignOutFilter");
registrationBean.addInitParameter("config-prefix", "ui.filter.cas");
registrationBean.addInitParameter("casServerUrlPrefix", "http://localhost:8888/cas");
registrationBean.addUrlPatterns("/*");
@@ -151,7 +151,7 @@ public FilterRegistrationBean casValidationFilter() {
registrationBean.setFilter(new OnOffFilter());
registrationBean.setName("CasValidationFilter");
registrationBean.addInitParameter("inner-filter-class",
- "org.jasig.cas.client.validation.Cas30ProxyReceivingTicketValidationFilter");
+ "org.apereo.cas.client.validation.Cas30ProxyReceivingTicketValidationFilter");
registrationBean.addInitParameter("config-prefix", "ui.filter.cas");
registrationBean.addInitParameter("casServerUrlPrefix", "https://localhost:8443/cas");
registrationBean.addInitParameter("serverName", "https://localhost:8888");
@@ -170,7 +170,7 @@ public FilterRegistrationBean casAuthenticationFilter() {
FilterRegistrationBean registrationBean = new FilterRegistrationBean<>();
registrationBean.setFilter(new OnOffFilter());
registrationBean.setName("CasAuthenticationFilter");
- registrationBean.addInitParameter("inner-filter-class", "org.jasig.cas.client.authentication.AuthenticationFilter");
+ registrationBean.addInitParameter("inner-filter-class", "org.apereo.cas.client.authentication.AuthenticationFilter");
registrationBean.addInitParameter("config-prefix", "ui.filter.cas");
registrationBean.addInitParameter("casServerLoginUrl", "https://localhost:8443/cas/login");
registrationBean.addUrlPatterns("/login");
@@ -184,7 +184,7 @@ public FilterRegistrationBean casRequestWrapperFilter() {
registrationBean.setFilter(new OnOffFilter());
registrationBean.setName("CasRequestWrapperFilter");
registrationBean.addInitParameter("inner-filter-class",
- "org.jasig.cas.client.util.HttpServletRequestWrapperFilter");
+ "org.apereo.cas.client.util.HttpServletRequestWrapperFilter");
registrationBean.addInitParameter("config-prefix", "ui.filter.cas");
registrationBean.addUrlPatterns("/*");
diff --git a/src/main/java/com/databasepreservation/common/api/utils/ExtraMediaType.java b/src/main/java/com/databasepreservation/common/api/utils/ExtraMediaType.java
index 40e6a9433..09d47c594 100644
--- a/src/main/java/com/databasepreservation/common/api/utils/ExtraMediaType.java
+++ b/src/main/java/com/databasepreservation/common/api/utils/ExtraMediaType.java
@@ -28,6 +28,7 @@ private ExtraMediaType() {
*/
public static final String TEXT_CSV = "text/csv";
public static final String APPLICATION_ZIP = "application/zip";
+ public static final String ZIP_FILE_EXTENSION = ".zip";
public static final String APPLICATION_JAVASCRIPT = "application/javascript";
}
diff --git a/src/main/java/com/databasepreservation/common/api/v1/CollectionResource.java b/src/main/java/com/databasepreservation/common/api/v1/CollectionResource.java
index b7ca5d06c..49b27d20e 100644
--- a/src/main/java/com/databasepreservation/common/api/v1/CollectionResource.java
+++ b/src/main/java/com/databasepreservation/common/api/v1/CollectionResource.java
@@ -13,6 +13,7 @@
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -24,9 +25,14 @@
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
+import java.util.zip.ZipOutputStream;
import com.databasepreservation.common.api.exceptions.RESTException;
import com.databasepreservation.common.exceptions.AuthorizationException;
+import com.databasepreservation.common.client.models.structure.ViewerCell;
+import com.databasepreservation.model.data.Cell;
+import com.databasepreservation.common.api.utils.ExtraMediaType;
+import com.databasepreservation.model.exception.ModuleException;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
import org.roda.core.data.exceptions.*;
@@ -197,9 +203,9 @@ public StringResponse createCollection(String databaseUUID) {
}
final ViewerDatabase database = ViewerFactory.getSolrManager().retrieve(ViewerDatabase.class, databaseUUID);
- StringResponse collection = new StringResponse(SIARDController.loadFromLocal(database.getPath(), databaseUUID));
- return collection;
+ return new StringResponse(SIARDController.loadFromLocal(database.getPath(), databaseUUID, database.getVersion()));
+
} catch (GenericException | AuthorizationDeniedException | NotFoundException | AuthorizationException e) {
state = LogEntryState.FAILURE;
throw new RESTException(e);
@@ -529,7 +535,8 @@ public ResponseEntity exportLOB(
.equals(row.getCells().get(configTable.getColumnByIndex(columnIndex).getId()).getStoreType())) {
return handleExternalLobDownload(configTable, row, columnIndex);
} else {
- return handleInternalLobDownload(database.getPath(), configTable, row, columnIndex);
+ String version = ViewerFactory.getSolrManager().retrieve(ViewerDatabase.class, databaseUUID).getVersion();
+ return handleInternalLobDownload(database.getPath(), configTable, row, columnIndex, version);
}
}
} catch (NotFoundException | GenericException | IOException | AuthorizationException e) {
@@ -598,37 +605,53 @@ private ResponseEntity handleExternalLobDownload(TableSta
}
private ResponseEntity handleInternalLobDownload(String databasePath,
- TableStatus tableConfiguration, ViewerRow row, int columnIndex) throws IOException, GenericException {
+ TableStatus tableConfiguration, ViewerRow row, int columnIndex, String version)
+ throws IOException, GenericException {
String handlebarsFilename = HandlebarsUtils.applyExportTemplate(row, tableConfiguration, columnIndex);
if (ViewerStringUtils.isBlank(handlebarsFilename)) {
handlebarsFilename = ViewerConstants.SIARD_RECORD_PREFIX + row.getUuid()
+ ViewerConstants.SIARD_LOB_FILE_EXTENSION;
}
- String handlebarsMimeType = HandlebarsUtils.applyMimeTypeTemplate(row, tableConfiguration, columnIndex);
+ String handlebarsMimeType = HandlebarsUtils.applyMimeTypeTemplate(row, tableConfiguration, columnIndex);
if (ViewerStringUtils.isBlank(handlebarsMimeType)) {
handlebarsMimeType = tableConfiguration.getColumnByIndex(columnIndex).getApplicationType();
}
- if (LobManagerUtils.isLobEmbedded(tableConfiguration, row, columnIndex)) {
- // handle lob as embedded
- String lobCellValue = LobManagerUtils.getLobCellValue(tableConfiguration, row, columnIndex);
- lobCellValue = lobCellValue.replace(ViewerConstants.SIARD_EMBEDDED_LOB_PREFIX, "");
- String decodedString = new String(Base64.decodeBase64(lobCellValue.getBytes()));
+ if (version.equals(ViewerConstants.SIARD_DK_1007) || version.equals(ViewerConstants.SIARD_DK_128)) {
+ String filePath = row.getCells().get(row.getCells().keySet().toArray()[row.getCells().size() - 1]).getValue();
+ Path path = Paths.get(filePath);
+ // if the lob is a directory zip it
+ if (path.toFile().isDirectory()) {
+ Path zipFile = LobManagerUtils.zipDirectory(path, databasePath, handlebarsFilename);
- return ApiUtils.okResponse(new StreamResponse(handlebarsFilename, handlebarsMimeType,
- DownloadUtils.stream(new BufferedInputStream(new ByteArrayInputStream(decodedString.getBytes())))));
- } else {
- // handle lob as internal on separated folder
- ZipFile zipFile = new ZipFile(databasePath);
- final ZipEntry entry = zipFile.getEntry(LobManagerUtils.getZipFilePath(tableConfiguration, columnIndex, row));
- if (entry == null) {
- throw new GenericException("Zip archive entry is missing");
+ return ApiUtils.okResponse(new StreamResponse(handlebarsFilename, handlebarsMimeType,
+ DownloadUtils.stream(new BufferedInputStream(new FileInputStream(zipFile.toFile())))));
+ } else {
+ return ApiUtils.okResponse(new StreamResponse(handlebarsFilename, handlebarsMimeType,
+ DownloadUtils.stream(new BufferedInputStream(new FileInputStream(filePath)))));
}
+ } else {
+ if (LobManagerUtils.isLobEmbedded(tableConfiguration, row, columnIndex)) {
+ // handle lob as embedded
+ String lobCellValue = LobManagerUtils.getLobCellValue(tableConfiguration, row, columnIndex);
+ lobCellValue = lobCellValue.replace(ViewerConstants.SIARD_EMBEDDED_LOB_PREFIX, "");
+ String decodedString = new String(Base64.decodeBase64(lobCellValue.getBytes()));
+
+ return ApiUtils.okResponse(new StreamResponse(handlebarsFilename, handlebarsMimeType,
+ DownloadUtils.stream(new BufferedInputStream(new ByteArrayInputStream(decodedString.getBytes())))));
+ } else {
+ // handle lob as internal on separated folder
+ ZipFile zipFile = new ZipFile(databasePath);
+ final ZipEntry entry = zipFile.getEntry(LobManagerUtils.getZipFilePath(tableConfiguration, columnIndex, row));
+ if (entry == null) {
+ throw new GenericException("Zip archive entry is missing");
+ }
- return ApiUtils.okResponse(new StreamResponse(handlebarsFilename, handlebarsMimeType,
- DownloadUtils.stream(new BufferedInputStream(zipFile.getInputStream(entry)))));
+ return ApiUtils.okResponse(new StreamResponse(handlebarsFilename, handlebarsMimeType,
+ DownloadUtils.stream(new BufferedInputStream(zipFile.getInputStream(entry)))));
+ }
}
}
diff --git a/src/main/java/com/databasepreservation/common/api/v1/DatabaseResource.java b/src/main/java/com/databasepreservation/common/api/v1/DatabaseResource.java
index 0293ae426..ee3607273 100644
--- a/src/main/java/com/databasepreservation/common/api/v1/DatabaseResource.java
+++ b/src/main/java/com/databasepreservation/common/api/v1/DatabaseResource.java
@@ -125,7 +125,7 @@ public IndexResult findAll(FindRequest findRequest, String local
}
@Override
- public StringResponse create(String path) {
+ public StringResponse create(String path, ViewerConstants.SiardVersion siardVersion) {
final ControllerAssistant controllerAssistant = new ControllerAssistant() {};
LogEntryState state = LogEntryState.SUCCESS;
@@ -133,7 +133,7 @@ public StringResponse create(String path) {
try {
user = controllerAssistant.checkRoles(request);
- return new StringResponse(SIARDController.loadMetadataFromLocal(path));
+ return new StringResponse(SIARDController.loadMetadataFromLocal(path, siardVersion));
} catch (GenericException | AuthorizationException e) {
state = LogEntryState.FAILURE;
throw new RESTException(e);
diff --git a/src/main/java/com/databasepreservation/common/api/v1/FileResource.java b/src/main/java/com/databasepreservation/common/api/v1/FileResource.java
index 033a38c75..d960a7182 100644
--- a/src/main/java/com/databasepreservation/common/api/v1/FileResource.java
+++ b/src/main/java/com/databasepreservation/common/api/v1/FileResource.java
@@ -16,6 +16,7 @@
import java.util.List;
import java.util.stream.Collectors;
+import com.databasepreservation.common.utils.LobManagerUtils;
import org.roda.core.data.exceptions.AlreadyExistsException;
import org.roda.core.data.exceptions.GenericException;
import org.roda.core.data.exceptions.NotFoundException;
@@ -90,9 +91,13 @@ public ResponseEntity getSIARDFile(String filename) {
java.nio.file.Path basePath = Paths.get(ViewerConfiguration.getInstance().getViewerConfigurationAsString("/",
ViewerConfiguration.PROPERTY_BASE_UPLOAD_PATH));
java.nio.file.Path siardPath = siardFilesPath.resolve(filename);
- if (java.nio.file.Files.exists(siardPath) && !java.nio.file.Files.isDirectory(siardPath)
- && (ViewerConfiguration.checkPathIsWithin(siardPath, siardFilesPath)
- || ViewerConfiguration.checkPathIsWithin(siardPath, basePath))) {
+
+ if (java.nio.file.Files.isDirectory(siardPath)) {
+ siardPath = LobManagerUtils.zipDirectory(siardPath);
+ }
+
+ if (java.nio.file.Files.exists(siardPath) && (ViewerConfiguration.checkPathIsWithin(siardPath, siardFilesPath)
+ || ViewerConfiguration.checkPathIsWithin(siardPath, basePath))) {
InputStreamResource resource = new InputStreamResource(new FileInputStream(siardPath.toFile()));
return ResponseEntity.ok()
@@ -101,7 +106,7 @@ public ResponseEntity getSIARDFile(String filename) {
} else {
throw new NotFoundException("SIARD file not found");
}
- } catch (NotFoundException | FileNotFoundException | AuthorizationException e) {
+ } catch (NotFoundException | AuthorizationException | IOException e) {
state = LogEntryState.FAILURE;
throw new RESTException(e);
} finally {
@@ -149,7 +154,7 @@ public ResponseEntity createSIARDFile(MultipartFile resource
if (!fileExtension.equals(ViewerConstants.SIARD)) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
- .body(new ApiResponseMessage(ApiResponseMessage.ERROR, "Must be a SIARD file"));
+ .body(new ApiResponseMessage(ApiResponseMessage.ERROR, "Must be a SIARD file"));
}
java.nio.file.Path path = Paths.get(ViewerConfiguration.getInstance().getSIARDFilesPath().toString(), filename);
diff --git a/src/main/java/com/databasepreservation/common/client/ViewerConstants.java b/src/main/java/com/databasepreservation/common/client/ViewerConstants.java
index d909e3085..edefa4910 100644
--- a/src/main/java/com/databasepreservation/common/client/ViewerConstants.java
+++ b/src/main/java/com/databasepreservation/common/client/ViewerConstants.java
@@ -91,6 +91,7 @@ public class ViewerConstants {
public static final String DENORMALIZATION_STATUS_PREFIX = "denormalization-";
public static final String INTERNAL_ZIP_LOB_FOLDER = "lobs/";
+ public static final String SIARDDK_DEFAULT_SCHEMA_NAME = "public";
/*
* SOLR CONFIGSETS
@@ -441,7 +442,9 @@ public class ViewerConstants {
public static final String SIARD_V10 = "1.0";
public static final String SIARD_V20 = "2.0";
public static final String SIARD_V21 = "2.1";
-
+ public static final String SIARD_DK = "dk";
+ public static final String SIARD_DK_1007 = "dk-1007";
+ public static final String SIARD_DK_128 = "dk-128";
/*
* DBPTK Metadata
*/
@@ -552,6 +555,7 @@ public class ViewerConstants {
public static final String PROPERTY_PLUGIN_LOAD_ON_ACCESS = "ui.plugin.loadOnAccess";
public static final String ALIAS_PREFIX = "alias-";
+ public static final String TEMP_PREFIX = "temp-";
public static final String EMPTY_SEARCH = "";
@@ -566,6 +570,10 @@ public class ViewerConstants {
*/
public static final String PROPERTY_REFERENCE_TABLE_SHOW_SCHEMA_NAME = "ui.reference.table.show.schema.name";
+ public enum SiardVersion {
+ V1_0, V2_0, V2_1, DK, DK_1007, DK_128;
+ }
+
/**
* private constructor
*/
diff --git a/src/main/java/com/databasepreservation/common/client/common/helpers/HelperUploadSIARDFile.java b/src/main/java/com/databasepreservation/common/client/common/helpers/HelperUploadSIARDFile.java
index 557726ea1..d4d2ea4cb 100644
--- a/src/main/java/com/databasepreservation/common/client/common/helpers/HelperUploadSIARDFile.java
+++ b/src/main/java/com/databasepreservation/common/client/common/helpers/HelperUploadSIARDFile.java
@@ -108,7 +108,7 @@ private void uploadMetadataSIARD(String path, FlowPanel panel) {
Dialogs.showErrors(messages.errorMessagesOpenFile(path), errorMessage, messages.basicActionClose());
// Toast.showError(messages.errorMessagesOpenFile(), errorMessage);
panel.remove(loading);
- }).create(path);
+ }).create(path, ViewerConstants.SiardVersion.V2_1);
}
private void successHandler(Boolean confirm, FlowPanel panel, String databaseUUID, String path) {
diff --git a/src/main/java/com/databasepreservation/common/client/common/lists/DatabaseList.java b/src/main/java/com/databasepreservation/common/client/common/lists/DatabaseList.java
index 7ef5d800a..e73030fda 100644
--- a/src/main/java/com/databasepreservation/common/client/common/lists/DatabaseList.java
+++ b/src/main/java/com/databasepreservation/common/client/common/lists/DatabaseList.java
@@ -86,7 +86,7 @@ public SafeHtml getValue(ViewerDatabase database) {
Column description = new TooltipColumn() {
@Override
public SafeHtml getValue(ViewerDatabase database) {
- return database != null && database.getMetadata() != null
+ return database != null && database.getMetadata() != null && database.getMetadata().getDescription() != null
? SafeHtmlUtils.fromString(database.getMetadata().getDescription())
: SafeHtmlUtils.fromString("unknown");
}
@@ -104,7 +104,7 @@ public SafeHtml getValue(ViewerDatabase database) {
Column dataOwnerColumn = new TooltipColumn() {
@Override
public SafeHtml getValue(ViewerDatabase database) {
- return database != null && database.getMetadata() != null
+ return database != null && database.getMetadata() != null && database.getMetadata().getDataOwner() != null
? SafeHtmlUtils.fromString(database.getMetadata().getDataOwner())
: SafeHtmlUtils.fromString("unknown");
}
diff --git a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/SIARDManagerPage.java b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/SIARDManagerPage.java
index ac58e1c0b..8d1ded178 100644
--- a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/SIARDManagerPage.java
+++ b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/SIARDManagerPage.java
@@ -143,7 +143,8 @@ private void populateNavigationPanels() {
if (ApplicationType.getType().equals(ViewerConstants.APPLICATION_ENV_SERVER)) {
DatabaseService.Util.call((Set databasePermissions) -> {
ContextService.Util.call((Set authorizationGroups) -> {
- permissionsNavigationPanel = PermissionsNavigationPanel.getInstance(database, databasePermissions, authorizationGroups);
+ permissionsNavigationPanel = PermissionsNavigationPanel.getInstance(database, databasePermissions,
+ authorizationGroups);
if (permissionsNavigationPanel.hasPermissionsOrGroups()) {
navigationPanels.add(permissionsNavigationPanel.build());
}
@@ -207,16 +208,23 @@ private void setupFooterButtons() {
if (ApplicationType.getType().equals(ViewerConstants.APPLICATION_ENV_DESKTOP)) {
message = messages.SIARDHomePageTextForDeleteAllFromDesktop();
}
- CommonDialogs.showConfirmDialog(messages.SIARDHomePageDialogTitleForDelete(), message,
- messages.basicActionCancel(), messages.basicActionConfirm(), CommonDialogs.Level.DANGER, "500px",
- new DefaultAsyncCallback() {
- @Override
- public void onSuccess(Boolean result) {
- if (result) {
- deleteAll();
+ if (database.getVersion().equals(ViewerConstants.SIARD_DK_1007)
+ || database.getVersion().equals(ViewerConstants.SIARD_DK_128)) {
+ Dialogs.showInformationDialog(messages.SIARDHomePageDialogTitleForDelete(),
+ messages.SIARDHomePageDialogTextForDeleteNotAvailable(ViewerConstants.SIARD_V21),
+ messages.basicActionUnderstood(), "btn btn-link");
+ } else {
+ CommonDialogs.showConfirmDialog(messages.SIARDHomePageDialogTitleForDelete(), message,
+ messages.basicActionCancel(), messages.basicActionConfirm(), CommonDialogs.Level.DANGER, "500px",
+ new DefaultAsyncCallback() {
+ @Override
+ public void onSuccess(Boolean result) {
+ if (result) {
+ deleteAll();
+ }
}
- }
- });
+ });
+ }
} else if (ViewerDatabaseStatus.INGESTING.equals(database.getStatus())) {
Dialogs.showInformationDialog(messages.SIARDManagerPageInformationDialogTitle(),
messages.SIARDManagerPageTextForWaitForFinishing(), messages.basicActionClose(), "btn btn-link");
diff --git a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/BrowseNavigationPanel.java b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/BrowseNavigationPanel.java
index 79433cf4a..a47a87c74 100644
--- a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/BrowseNavigationPanel.java
+++ b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/BrowseNavigationPanel.java
@@ -68,8 +68,11 @@ private void browseButton() {
}
private void handleBrowseAction() {
- if (database.getStatus().equals(ViewerDatabaseStatus.METADATA_ONLY)) { // Initial state
- if (database.getVersion().equals(ViewerConstants.SIARD_V21)) {
+ if (database.getStatus().equals(ViewerDatabaseStatus.METADATA_ONLY)) {
+ // Initial state
+ if (database.getVersion().equals(ViewerConstants.SIARD_V21)
+ || database.getVersion().equals(ViewerConstants.SIARD_DK_1007)
+ || database.getVersion().equals(ViewerConstants.SIARD_DK_128)) {
if (!btnIngestClicked) {
btnIngestClicked = true;
diff --git a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/SIARDNavigationPanel.java b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/SIARDNavigationPanel.java
index 18204e459..31c6b2214 100644
--- a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/SIARDNavigationPanel.java
+++ b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/SIARDNavigationPanel.java
@@ -15,6 +15,7 @@
import com.databasepreservation.common.client.common.DefaultAsyncCallback;
import com.databasepreservation.common.client.common.NavigationPanel;
import com.databasepreservation.common.client.common.dialogs.CommonDialogs;
+import com.databasepreservation.common.client.common.dialogs.Dialogs;
import com.databasepreservation.common.client.common.fields.GenericField;
import com.databasepreservation.common.client.common.fields.MetadataField;
import com.databasepreservation.common.client.common.utils.ApplicationType;
@@ -66,7 +67,14 @@ public NavigationPanel build() {
btnEditMetadata.setText(messages.SIARDHomePageButtonTextEditMetadata());
btnEditMetadata.addStyleName("btn btn-outline-primary btn-edit");
btnEditMetadata.addClickHandler(clickEvent -> {
- HistoryManager.gotoSIARDEditMetadata(database.getUuid());
+ if (database.getVersion().equals(ViewerConstants.SIARD_DK_1007)
+ || database.getVersion().equals(ViewerConstants.SIARD_DK_128)) {
+ Dialogs.showInformationDialog(messages.SIARDHomePageButtonTitleEditMetadataNotAvailable(),
+ messages.SIARDHomePageButtonTextEditMetadataNotAvailable(ViewerConstants.SIARD_V21),
+ messages.basicActionUnderstood(), "btn btn-link");
+ } else {
+ HistoryManager.gotoSIARDEditMetadata(database.getUuid());
+ }
});
// Migration button
@@ -109,18 +117,25 @@ public NavigationPanel build() {
if (database.getPath() != null && !database.getPath().isEmpty()) {
btnDelete.setText(messages.SIARDHomePageButtonTextForDeleteIngested());
btnDelete.addClickHandler(event -> {
- if (!database.getStatus().equals(ViewerDatabaseStatus.REMOVING)
- && !database.getStatus().equals(ViewerDatabaseStatus.INGESTING)) {
- CommonDialogs.showConfirmDialog(messages.SIARDHomePageDialogTitleForDelete(),
- messages.SIARDHomePageTextForDeleteSIARD(), messages.basicActionCancel(), messages.basicActionConfirm(),
- CommonDialogs.Level.DANGER, "500px", new DefaultAsyncCallback() {
- @Override
- public void onSuccess(Boolean result) {
- if (result) {
- delete();
+ if (database.getVersion().equals(ViewerConstants.SIARD_DK_1007)
+ || database.getVersion().equals(ViewerConstants.SIARD_DK_128)) {
+ Dialogs.showInformationDialog(messages.SIARDHomePageTitleForDeleteSIARDNotAvailable(),
+ messages.SIARDHomePageTextForDeleteSIARDNotAvailable(ViewerConstants.SIARD_V21),
+ messages.basicActionUnderstood(), "btn btn-link");
+ } else {
+ if (!database.getStatus().equals(ViewerDatabaseStatus.REMOVING)
+ && !database.getStatus().equals(ViewerDatabaseStatus.INGESTING)) {
+ CommonDialogs.showConfirmDialog(messages.SIARDHomePageDialogTitleForDelete(),
+ messages.SIARDHomePageTextForDeleteSIARD(), messages.basicActionCancel(), messages.basicActionConfirm(),
+ CommonDialogs.Level.DANGER, "500px", new DefaultAsyncCallback() {
+ @Override
+ public void onSuccess(Boolean result) {
+ if (result) {
+ delete();
+ }
}
- }
- });
+ });
+ }
}
});
}
diff --git a/src/main/java/com/databasepreservation/common/client/services/DatabaseService.java b/src/main/java/com/databasepreservation/common/client/services/DatabaseService.java
index 864efe3c6..48cf56168 100644
--- a/src/main/java/com/databasepreservation/common/client/services/DatabaseService.java
+++ b/src/main/java/com/databasepreservation/common/client/services/DatabaseService.java
@@ -76,7 +76,8 @@ IndexResult findAll(@RequestBody FindRequest findRequest,
@RequestMapping(path = "/create", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Creates a database")
- StringResponse create(@Parameter(name = "path") @RequestParam(name = "path") String path);
+ StringResponse create(@Parameter(name = "path") @RequestParam(name = "path") String path,
+ @Parameter(name = "version") @RequestParam(defaultValue = "V2_1", name = "version") ViewerConstants.SiardVersion version);
@RequestMapping(path = "/{databaseUUID}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Retrieves a specific database")
diff --git a/src/main/java/com/databasepreservation/common/server/controller/SIARDController.java b/src/main/java/com/databasepreservation/common/server/controller/SIARDController.java
index 068dd3dd8..174eacf5c 100644
--- a/src/main/java/com/databasepreservation/common/server/controller/SIARDController.java
+++ b/src/main/java/com/databasepreservation/common/server/controller/SIARDController.java
@@ -20,6 +20,8 @@
import java.util.Map;
import java.util.Set;
+import com.databasepreservation.modules.siard.SIARDDKEditFactory;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
@@ -79,6 +81,8 @@
import com.databasepreservation.modules.config.ImportConfigurationModuleFactory;
import com.databasepreservation.modules.jdbc.in.JDBCImportModule;
import com.databasepreservation.modules.siard.SIARD2ModuleFactory;
+import com.databasepreservation.modules.siard.SIARDDK1007ModuleFactory;
+import com.databasepreservation.modules.siard.SIARDDK128ModuleFactory;
import com.databasepreservation.modules.siard.SIARDEditFactory;
import com.databasepreservation.modules.siard.SIARDValidateFactory;
import com.databasepreservation.modules.viewer.DbvtkModuleFactory;
@@ -578,20 +582,23 @@ private static Module getFilterModuleParameters(DatabaseFilterFactory factory) {
return module;
}
- public static String loadMetadataFromLocal(String localPath) throws GenericException {
+ public static String loadMetadataFromLocal(String localPath, ViewerConstants.SiardVersion siardVersion)
+ throws GenericException {
String databaseUUID = SolrUtils.randomUUID();
- return loadMetadataFromLocal(databaseUUID, localPath);
+ return loadMetadataFromLocal(databaseUUID, localPath, siardVersion);
}
- private static String loadMetadataFromLocal(String databaseUUID, String localPath) throws GenericException {
+ private static String loadMetadataFromLocal(String databaseUUID, String localPath,
+ ViewerConstants.SiardVersion siardVersion) throws GenericException {
Path basePath = Paths.get(ViewerConfiguration.getInstance().getViewerConfigurationAsString("/",
ViewerConfiguration.PROPERTY_BASE_UPLOAD_PATH));
Path siardPath = basePath.resolve(localPath);
- convertSIARDMetadataToSolr(siardPath, databaseUUID);
+ convertSIARDMetadataToSolr(siardPath, databaseUUID, siardVersion);
return databaseUUID;
}
- private static void convertSIARDMetadataToSolr(Path siardPath, String databaseUUID) throws GenericException {
+ private static void convertSIARDMetadataToSolr(Path siardPath, String databaseUUID,
+ ViewerConstants.SiardVersion siardVersion) throws GenericException {
validateSIARDLocation(siardPath);
LOGGER.info("starting to import metadata database {}", siardPath.toAbsolutePath());
@@ -599,9 +606,16 @@ private static void convertSIARDMetadataToSolr(Path siardPath, String databaseUU
try {
Reporter reporter = new NoOpReporter();
SIARDEdition siardEdition = SIARDEdition.newInstance();
-
- siardEdition.editModule(new SIARDEditFactory()).editModuleParameter(SIARDEditFactory.PARAMETER_FILE,
- Collections.singletonList(siardPath.toAbsolutePath().toString()));
+ if (siardVersion.equals(ViewerConstants.SiardVersion.DK_1007)
+ || siardVersion.equals(ViewerConstants.SiardVersion.DK_128)) {
+ siardEdition.editModule(new SIARDDKEditFactory()).editModuleParameter(SIARDDKEditFactory.PARAMETER_FOLDER,
+ Collections.singletonList(siardPath.toAbsolutePath().toString()));
+ } else if (siardVersion.equals(ViewerConstants.SiardVersion.V2_1)) {
+ siardEdition.editModule(new SIARDEditFactory()).editModuleParameter(SIARDEditFactory.PARAMETER_FILE,
+ Collections.singletonList(siardPath.toAbsolutePath().toString()));
+ } else {
+ throw new SIARDVersionNotSupportedException();
+ }
siardEdition.reporter(reporter);
@@ -615,7 +629,14 @@ private static void convertSIARDMetadataToSolr(Path siardPath, String databaseUU
viewerDatabase.setUuid(databaseUUID);
viewerDatabase.setPath(siardPath.toAbsolutePath().toString());
- viewerDatabase.setSize(siardPath.toFile().length());
+
+ if (siardVersion.equals(ViewerConstants.SiardVersion.DK_1007)
+ || siardVersion.equals(ViewerConstants.SiardVersion.DK_128)) {
+ viewerDatabase.setSize(FileUtils.sizeOfDirectory(siardPath.toFile()));
+ } else {
+ viewerDatabase.setSize(siardPath.toFile().length());
+ }
+
viewerDatabase.setVersion(siardEdition.getSIARDVersion());
viewerDatabase.setAvailableToSearchAll(ViewerConfiguration.getInstance().getViewerConfigurationAsBoolean(true,
ViewerConfiguration.SIARD_AVAILABLE_TO_SEARCH_ALL));
@@ -666,13 +687,14 @@ private static void validateSIARDLocation(Path siardPath) throws GenericExceptio
}
}
- public static String loadFromLocal(String localPath, String databaseUUID) throws GenericException {
+ public static String loadFromLocal(String localPath, String databaseUUID, String siardVersion)
+ throws GenericException {
LOGGER.info("Preparing the SIARD to be browsable ({})", databaseUUID);
Path basePath = Paths.get(ViewerConfiguration.getInstance().getViewerConfigurationAsString("/",
ViewerConfiguration.PROPERTY_BASE_UPLOAD_PATH));
try {
Path siardPath = basePath.resolve(localPath);
- convertSIARDtoSolr(siardPath, databaseUUID);
+ convertSIARDtoSolr(siardPath, databaseUUID, siardVersion);
LOGGER.info("Conversion to SIARD successful, database: {}", databaseUUID);
} catch (GenericException e) {
LOGGER.error("Conversion to SIARD failed for database {}", databaseUUID, e);
@@ -681,7 +703,8 @@ public static String loadFromLocal(String localPath, String databaseUUID) throws
return databaseUUID;
}
- private static void convertSIARDtoSolr(Path siardPath, String databaseUUID) throws GenericException {
+ private static void convertSIARDtoSolr(Path siardPath, String databaseUUID, String siardVersion)
+ throws GenericException {
validateSIARDLocation(siardPath);
LOGGER.info("starting to convert database {}", siardPath.toAbsolutePath());
@@ -696,9 +719,23 @@ private static void convertSIARDtoSolr(Path siardPath, String databaseUUID) thro
// XXX remove this workaround after fix of NPE
databaseMigration.filterFactories(new ArrayList<>());
- databaseMigration.importModule(new SIARD2ModuleFactory())
- .importModuleParameter(SIARD2ModuleFactory.PARAMETER_FILE, siardPath.toAbsolutePath().toString())
- .importModuleParameter(SIARD2ModuleFactory.PARAMETER_IGNORE_LOBS, "true");
+ if (siardVersion.equals(ViewerConstants.SIARD_DK_128)) {
+ databaseMigration.importModule(new SIARDDK128ModuleFactory())
+ .importModuleParameter(SIARDDK128ModuleFactory.PARAMETER_FOLDER, siardPath.toAbsolutePath().toString())
+ .importModuleParameter(SIARDDK128ModuleFactory.PARAMETER_AS_SCHEMA,
+ ViewerConstants.SIARDDK_DEFAULT_SCHEMA_NAME);
+ } else if (siardVersion.equals(ViewerConstants.SIARD_DK_1007)) {
+ databaseMigration.importModule(new SIARDDK1007ModuleFactory())
+ .importModuleParameter(SIARDDK1007ModuleFactory.PARAMETER_FOLDER, siardPath.toAbsolutePath().toString())
+ .importModuleParameter(SIARDDK1007ModuleFactory.PARAMETER_AS_SCHEMA,
+ ViewerConstants.SIARDDK_DEFAULT_SCHEMA_NAME);
+ } else if (siardVersion.equals(ViewerConstants.SIARD_V21)) {
+ databaseMigration.importModule(new SIARD2ModuleFactory())
+ .importModuleParameter(SIARD2ModuleFactory.PARAMETER_FILE, siardPath.toAbsolutePath().toString())
+ .importModuleParameter(SIARD2ModuleFactory.PARAMETER_IGNORE_LOBS, "true");
+ } else {
+ throw new GenericException("SIARD version not supported");
+ }
databaseMigration.exportModule(new DbvtkModuleFactory())
.exportModuleParameter(DbvtkModuleFactory.PARAMETER_DATABASE_UUID, databaseUUID);
diff --git a/src/main/java/com/databasepreservation/common/transformers/ToolkitStructure2ViewerStructure.java b/src/main/java/com/databasepreservation/common/transformers/ToolkitStructure2ViewerStructure.java
index 85cdb5f59..0772c3f03 100644
--- a/src/main/java/com/databasepreservation/common/transformers/ToolkitStructure2ViewerStructure.java
+++ b/src/main/java/com/databasepreservation/common/transformers/ToolkitStructure2ViewerStructure.java
@@ -7,10 +7,13 @@
*/
package com.databasepreservation.common.transformers;
+import com.databasepreservation.common.api.utils.ExtraMediaType;
import com.databasepreservation.common.client.models.structure.ViewerLobStoreType;
import java.io.ByteArrayInputStream;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -365,7 +368,10 @@ private static List getViews(ViewerDatabaseFromToolkit vdb, List result = new ArrayList<>();
if (views != null) {
for (ViewStructure view : views) {
- result.add(getView(vdb, view));
+ if (view.getColumns() != null) {
+ ViewerView viewerView = getView(vdb, view);
+ result.add(viewerView);
+ }
}
}
return result;
@@ -749,7 +755,7 @@ private static ViewerType getType(Type type) throws ViewerException {
}
public static ViewerRow getRow(CollectionStatus collectionConfiguration, ViewerTable table, Row row, long rowIndex,
- String databasePath) {
+ String databasePath, String siardVersion) {
setCurrentTable(table);
ViewerRow result = new ViewerRow();
@@ -759,7 +765,7 @@ public static ViewerRow getRow(CollectionStatus collectionConfiguration, ViewerT
result.setTableId(table.getId());
result.setTableUUID(table.getUuid());
result.setUuid(rowUUID);
- result.setCells(getCells(collectionConfiguration, table, row, databasePath, result));
+ result.setCells(getCells(collectionConfiguration, table, row, databasePath, result, siardVersion));
return result;
}
@@ -770,7 +776,7 @@ private static void setCurrentTable(ViewerTable table) {
}
private static Map getCells(CollectionStatus collectionConfiguration, ViewerTable table, Row row,
- String databasePath, ViewerRow actualViewerRow) {
+ String databasePath, ViewerRow actualViewerRow, String siardVersion) {
Map result = new LinkedHashMap<>();
int colIndex = 0;
@@ -779,7 +785,7 @@ private static Map getCells(CollectionStatus collectionConfi
String solrColumnName = viewerColumn.getSolrName();
try {
result.put(solrColumnName, getCell(collectionConfiguration, table, toolkitCells.get(colIndex), colIndex++,
- databasePath, actualViewerRow));
+ databasePath, actualViewerRow, siardVersion));
} catch (ViewerException e) {
LOGGER.error("Problem converting cell, omitted it (as if it were NULL)", e);
}
@@ -789,7 +795,7 @@ private static Map getCells(CollectionStatus collectionConfi
}
private static ViewerCell getCell(CollectionStatus collectionConfiguration, ViewerTable table, Cell cell,
- int colIndex, String databasePath, ViewerRow actualViewerRow) throws ViewerException {
+ int colIndex, String databasePath, ViewerRow actualViewerRow, String siardVersion) throws ViewerException {
ViewerCell result = new ViewerCell();
ViewerType columnType = table.getColumns().get(colIndex).getType();
@@ -810,8 +816,8 @@ private static ViewerCell getCell(CollectionStatus collectionConfiguration, View
String index = getRowIndex(cell.getId());
String lobName = ViewerConstants.SIARD_RECORD_PREFIX + index + ViewerConstants.SIARD_LOB_FILE_EXTENSION;
actualViewerRow.addLobType(
- collectionConfiguration.getTableStatusByTableId(table.getId()).getColumnByIndex(colIndex).getId(),
- ViewerLobStoreType.EXTERNALLY);
+ collectionConfiguration.getTableStatusByTableId(table.getId()).getColumnByIndex(colIndex).getId(),
+ ViewerLobStoreType.EXTERNALLY);
detectMimeType(actualViewerRow, result, databasePath, collectionConfiguration, table, colIndex, lobName,
true);
@@ -832,22 +838,31 @@ private static ViewerCell getCell(CollectionStatus collectionConfiguration, View
result.setValue(siardFilesPath.relativize(lobPath).normalize().toString());
collectionConfiguration.getTableStatusByTableId(table.getId()).getColumnByIndex(colIndex).setExternalLob(true);
actualViewerRow.addLobType(
- collectionConfiguration.getTableStatusByTableId(table.getId()).getColumnByIndex(colIndex).getId(),
- ViewerLobStoreType.EXTERNALLY);
+ collectionConfiguration.getTableStatusByTableId(table.getId()).getColumnByIndex(colIndex).getId(),
+ ViewerLobStoreType.EXTERNALLY);
detectMimeType(actualViewerRow, result, databasePath, collectionConfiguration, table, colIndex, lobName, false);
} else {
// BLOB is internal to the SIARD but is stored outside the table.xml (Normal)
-
- String lobName = Paths.get(binaryCell.getFile()).getFileName().toString();
- result.setValue(lobName);
+ String lobName;
+
collectionConfiguration.getTableStatusByTableId(table.getId()).getColumnByIndex(colIndex).setExternalLob(false);
actualViewerRow.addLobType(
collectionConfiguration.getTableStatusByTableId(table.getId()).getColumnByIndex(colIndex).getId(),
ViewerLobStoreType.INTERNALLY);
- detectMimeType(actualViewerRow, result, databasePath, collectionConfiguration, table, colIndex, lobName, true);
+ if (siardVersion.equals(ViewerConstants.SIARD_DK_128) || siardVersion.equals(ViewerConstants.SIARD_DK_1007)) {
+ lobName = binaryCell.getFile();
+ result.setValue(lobName);
+ detectMimeType(actualViewerRow, result, databasePath, collectionConfiguration, table, colIndex, lobName, true,
+ true);
+ } else {
+ lobName = Paths.get(binaryCell.getFile()).getFileName().toString();
+ result.setValue(lobName);
+ detectMimeType(actualViewerRow, result, databasePath, collectionConfiguration, table, colIndex, lobName, true);
+ }
+
}
} else if (cell instanceof ComposedCell) {
ComposedCell composedCell = (ComposedCell) cell;
@@ -881,70 +896,94 @@ private static ViewerCell getCell(CollectionStatus collectionConfiguration, View
private static void detectMimeType(ViewerRow row, ViewerCell cell, String databasePath,
CollectionStatus collectionConfiguration, ViewerTable table, int colIndex, String lobName,
boolean blobIsInsideSiard) {
+ detectMimeType(row, cell, databasePath, collectionConfiguration, table, colIndex, lobName, blobIsInsideSiard,
+ false);
+ }
+
+ private static void detectMimeType(ViewerRow row, ViewerCell cell, String databasePath,
+ CollectionStatus collectionConfiguration, ViewerTable table, int colIndex, String lobName,
+ boolean blobIsInsideSiard, boolean isSiardDK) {
try {
String mimeType;
String fileExtension;
InputStream inputStream;
TableStatus tableStatus = collectionConfiguration.getTableStatusByTableId(table.getId());
- String siardLobPath = LobManagerUtils.getZipFilePath(tableStatus, colIndex, lobName);
- ZipFile zipFile = new ZipFile(databasePath);
- ZipEntry entry = zipFile.getEntry(siardLobPath);
+ ZipFile zipFile = null;
+ ZipEntry entry = null;
+ String siardLobPath;
- String lobCellValue = cell.getValue();
-
- if (entry != null && blobIsInsideSiard) {
- inputStream = zipFile.getInputStream(entry);
- } else if (blobIsInsideSiard) {
- lobCellValue = lobCellValue.replace(ViewerConstants.SIARD_EMBEDDED_LOB_PREFIX, "");
- inputStream = new ByteArrayInputStream(Base64.decodeBase64(lobCellValue.getBytes()));
+ File lobFile = new File(lobName);
+ if (lobFile.isDirectory()) {
+ mimeType = ExtraMediaType.APPLICATION_ZIP;
+ fileExtension = ExtraMediaType.ZIP_FILE_EXTENSION;
} else {
- lobCellValue = cell.getValue();
- final Path lobPath = Paths.get(lobCellValue);
- final Path completeLobPath = ViewerFactory.getViewerConfiguration().getSIARDFilesPath().resolve(lobPath);
- inputStream = Files.newInputStream(completeLobPath);
- }
-
- mimeType = tika.detect(inputStream);
- fileExtension = MimeTypes.getDefaultMimeTypes().forName(mimeType).getExtension();
-
- if (StringUtils.isAllBlank(fileExtension)) {
- try {
- if (blobIsInsideSiard) {
- if (entry != null) {
- inputStream = zipFile.getInputStream(entry);
- } else {
- inputStream = new ByteArrayInputStream(lobCellValue.getBytes());
- }
+ String lobCellValue = cell.getValue();
+
+ if (!isSiardDK) {
+ siardLobPath = LobManagerUtils.getZipFilePath(tableStatus, colIndex, lobName);
+ zipFile = new ZipFile(databasePath);
+ entry = zipFile.getEntry(siardLobPath);
+
+ if (entry != null && blobIsInsideSiard) {
+ inputStream = zipFile.getInputStream(entry);
+ } else if (blobIsInsideSiard) {
+ lobCellValue = lobCellValue.replace(ViewerConstants.SIARD_EMBEDDED_LOB_PREFIX, "");
+ inputStream = new ByteArrayInputStream(Base64.decodeBase64(lobCellValue.getBytes()));
} else {
+ lobCellValue = cell.getValue();
final Path lobPath = Paths.get(lobCellValue);
final Path completeLobPath = ViewerFactory.getViewerConfiguration().getSIARDFilesPath().resolve(lobPath);
inputStream = Files.newInputStream(completeLobPath);
}
+ } else {
+ inputStream = Files.newInputStream(Paths.get(lobName));
+ }
- AutoDetectParser parser = new AutoDetectParser();
- Metadata metadata = new Metadata();
+ mimeType = tika.detect(inputStream);
+ fileExtension = MimeTypes.getDefaultMimeTypes().forName(mimeType).getExtension();
+
+ if (StringUtils.isAllBlank(fileExtension)) {
+ try {
+ if (blobIsInsideSiard) {
+ if (entry != null) {
+ inputStream = zipFile.getInputStream(entry);
+ } else {
+ inputStream = new ByteArrayInputStream(lobCellValue.getBytes());
+ }
+ } else {
+ final Path lobPath = Paths.get(lobCellValue);
+ final Path completeLobPath = ViewerFactory.getViewerConfiguration().getSIARDFilesPath().resolve(lobPath);
+ inputStream = Files.newInputStream(completeLobPath);
+ }
- Boolean autoDetectParserNoLimit = ViewerFactory.getEnvBoolean("AUTO_DETECT_PARSER_NO_LIMIT", false);
+ AutoDetectParser parser = new AutoDetectParser();
+ Metadata metadata = new Metadata();
- if (autoDetectParserNoLimit) {
- parser.parse(inputStream, new BodyContentHandler(-1), metadata, new ParseContext());
- } else {
- parser.parse(inputStream, new BodyContentHandler(), metadata, new ParseContext());
+ Boolean autoDetectParserNoLimit = ViewerFactory.getEnvBoolean("AUTO_DETECT_PARSER_NO_LIMIT", false);
+
+ if (autoDetectParserNoLimit) {
+ parser.parse(inputStream, new BodyContentHandler(-1), metadata, new ParseContext());
+ } else {
+ parser.parse(inputStream, new BodyContentHandler(), metadata, new ParseContext());
+ }
+
+ mimeType = metadata.get("Content-Type");
+ fileExtension = MimeTypes.getDefaultMimeTypes().forName(mimeType).getExtension();
+
+ } catch (SAXException | TikaException e) {
+ LOGGER.error("Could not calculate mimeType for special extensions in the cell: [{}]", cell.getValue(), e);
}
+ }
- mimeType = metadata.get("Content-Type");
- fileExtension = MimeTypes.getDefaultMimeTypes().forName(mimeType).getExtension();
+ inputStream.close();
- } catch (SAXException | TikaException e) {
- LOGGER.error("Could not calculate mimeType for special extensions in the cell: [{}]", cell.getValue(), e);
+ if (zipFile != null) {
+ zipFile.close();
}
}
- inputStream.close();
- zipFile.close();
-
cell.setMimeType(mimeType);
cell.setFileExtension(fileExtension);
diff --git a/src/main/java/com/databasepreservation/common/utils/LobManagerUtils.java b/src/main/java/com/databasepreservation/common/utils/LobManagerUtils.java
index 670f8e312..6ce1d286f 100644
--- a/src/main/java/com/databasepreservation/common/utils/LobManagerUtils.java
+++ b/src/main/java/com/databasepreservation/common/utils/LobManagerUtils.java
@@ -7,8 +7,17 @@
*/
package com.databasepreservation.common.utils;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.nio.file.Files;
import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+import com.databasepreservation.common.api.exceptions.RESTException;
+import com.databasepreservation.common.api.utils.ExtraMediaType;
import com.databasepreservation.common.client.ViewerConstants;
import com.databasepreservation.common.client.models.status.collection.TableStatus;
import com.databasepreservation.common.client.models.structure.ViewerRow;
@@ -48,6 +57,52 @@ public static String getZipFilePath(TableStatus configTable, int columnIndex, St
String siardLobFolder = ViewerConstants.SIARD_LOB_FOLDER_PREFIX + (columnIndex + 1);
return "content" + "/" + siardSchemaFolder + "/" + siardTableFolder + "/" + siardLobFolder + "/" + recordValue;
+
+ }
+
+ public static Path zipDirectory(Path dirPath) throws IOException {
+ return zipDirectory(dirPath, null, null);
+ }
+
+ public static Path zipDirectory(Path dirPath, String databasePath, String handlebarsFilename) throws IOException {
+ Path zipFilePath;
+
+ if (databasePath == null) {
+ zipFilePath = dirPath.resolveSibling(dirPath.getFileName().toString() + ExtraMediaType.ZIP_FILE_EXTENSION);
+ } else {
+ if (handlebarsFilename != null) {
+ zipFilePath = buildSIARDKZipLobPath(databasePath, handlebarsFilename);
+ } else {
+ zipFilePath = Files.createTempFile(ViewerConstants.TEMP_PREFIX, ExtraMediaType.ZIP_FILE_EXTENSION);
+ }
+ }
+
+ try (FileOutputStream fos = new FileOutputStream(zipFilePath.toFile());
+ ZipOutputStream zos = new ZipOutputStream(fos)) {
+
+ Files.walk(dirPath).filter(path -> !Files.isDirectory(path)).forEach(path -> {
+ ZipEntry zipEntry = new ZipEntry(dirPath.relativize(path).toString());
+ try {
+ zos.putNextEntry(zipEntry);
+ Files.copy(path, zos);
+ zos.closeEntry();
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ });
+ } catch (UncheckedIOException e) {
+ // Throwing the exception that occurred inside the lambda
+ throw e.getCause();
+ }
+
+ return zipFilePath;
+ }
+
+ public static final Path buildSIARDKZipLobPath(String databasePath, String handlebarsFilename) {
+ Path dbPath = Paths.get(databasePath);
+ String dbName = dbPath.getFileName().toString();
+ return dbPath.getParent().getParent().resolve(ViewerConstants.VIEWER_LOBS_FOLDER)
+ .resolve(dbName + "-" + handlebarsFilename);
}
public static Path getConsolidatedPath(ViewerAbstractConfiguration configuration, String databaseUUID,
diff --git a/src/main/java/com/databasepreservation/desktop/client/dbptk/wizard/upload/CreateWizardManager.java b/src/main/java/com/databasepreservation/desktop/client/dbptk/wizard/upload/CreateWizardManager.java
index 4cbd9ab3c..5e8dbb253 100644
--- a/src/main/java/com/databasepreservation/desktop/client/dbptk/wizard/upload/CreateWizardManager.java
+++ b/src/main/java/com/databasepreservation/desktop/client/dbptk/wizard/upload/CreateWizardManager.java
@@ -502,6 +502,6 @@ private void importSIARDMetadata(String path) {
HistoryManager.gotoHome();
Dialogs.showErrors(messages.createSIARDWizardManagerInformationMessagesTitle(), errorMessage,
messages.basicActionClose());
- }).create(path);
+ }).create(path, ViewerConstants.SiardVersion.V2_1);
}
}
diff --git a/src/main/java/com/databasepreservation/modules/viewer/DbvtkExportModule.java b/src/main/java/com/databasepreservation/modules/viewer/DbvtkExportModule.java
index f3327e2af..410d88102 100644
--- a/src/main/java/com/databasepreservation/modules/viewer/DbvtkExportModule.java
+++ b/src/main/java/com/databasepreservation/modules/viewer/DbvtkExportModule.java
@@ -141,8 +141,8 @@ public void handleDataOpenTable(String tableId) throws ModuleException {
*/
@Override
public void handleDataRow(Row row) throws ModuleException {
- solrManager.addRow(retrieved.getUuid(),
- ToolkitStructure2ViewerStructure.getRow(collectionConfiguration, currentTable, row, rowIndex++,retrieved.getPath()));
+ solrManager.addRow(retrieved.getUuid(), ToolkitStructure2ViewerStructure.getRow(collectionConfiguration,
+ currentTable, row, rowIndex++, retrieved.getPath(), retrieved.getVersion()));
rowsProcessedByTableCounter++;
rowCounter++;
@@ -153,15 +153,14 @@ public void handleDataRow(Row row) throws ModuleException {
}
}
-
/**
* Checks if a row process log should be done
*
*/
private boolean shouldLogRowProgress() {
- return rowCounter == rowThreshold ||
- (currentTable.getCountRows() <= rowThreshold && rowsProcessedByTableCounter == currentTable.getCountRows()) ||
- rowsProcessedByTableCounter == currentTable.getCountRows();
+ return rowCounter == rowThreshold
+ || (currentTable.getCountRows() <= rowThreshold && rowsProcessedByTableCounter == currentTable.getCountRows())
+ || rowsProcessedByTableCounter == currentTable.getCountRows();
}
/**
diff --git a/src/main/java/com/databasepreservation/server/client/browse/upload/SIARDUpload.java b/src/main/java/com/databasepreservation/server/client/browse/upload/SIARDUpload.java
index 7b1c091c5..ff3ca211b 100644
--- a/src/main/java/com/databasepreservation/server/client/browse/upload/SIARDUpload.java
+++ b/src/main/java/com/databasepreservation/server/client/browse/upload/SIARDUpload.java
@@ -161,7 +161,7 @@ public void onSuccess(String id) {
// Toast.showError("Cannot create SIARD", PathUtils.getFileName(path));
item.addClassName("error");
doneItemLoadHandler(item, errorMessage, null);
- }).create(path);
+ }).create(path, ViewerConstants.SiardVersion.V2_1);
}
});
} else {
diff --git a/src/main/java/config/i18n/client/ClientMessages.java b/src/main/java/config/i18n/client/ClientMessages.java
index 2a58a46c9..5e424699d 100644
--- a/src/main/java/config/i18n/client/ClientMessages.java
+++ b/src/main/java/config/i18n/client/ClientMessages.java
@@ -729,6 +729,10 @@ public interface ClientMessages extends Messages {
String SIARDHomePageButtonTextEditMetadata();
+ String SIARDHomePageButtonTitleEditMetadataNotAvailable();
+
+ String SIARDHomePageButtonTextEditMetadataNotAvailable(String version);
+
String SIARDHomePageButtonTextMigrateToSIARD();
String SIARDHomePageButtonTextSendToLiveDBMS();
@@ -829,6 +833,8 @@ public interface ClientMessages extends Messages {
String SIARDHomePageDialogTitleForDelete();
+ String SIARDHomePageDialogTextForDeleteNotAvailable(String version);
+
String SIARDHomePageDialogTitleForDeleteBrowseContent();
String SIARDHomePageDialogTitleForDeleteValidationReport();
@@ -841,6 +847,10 @@ public interface ClientMessages extends Messages {
SafeHtml SIARDHomePageTextForDeleteSIARD();
+ String SIARDHomePageTitleForDeleteSIARDNotAvailable();
+
+ String SIARDHomePageTextForDeleteSIARDNotAvailable(String version);
+
SafeHtml SIARDHomePageTextForDeleteSIARDReportValidation();
String SIARDHomePageTextForIngestNotSupported();
diff --git a/src/main/resources/config/i18n/client/ClientMessages.properties b/src/main/resources/config/i18n/client/ClientMessages.properties
index 707d58241..046d3d0a5 100644
--- a/src/main/resources/config/i18n/client/ClientMessages.properties
+++ b/src/main/resources/config/i18n/client/ClientMessages.properties
@@ -269,6 +269,8 @@ SIARDManagerPageInformationDialogTitle=SIARD Manager
SIARDManagerPageTextForWaitForFinishing=Please wait for the current process to finish
SIARDHomePageToastTitle=SIARD - {0}
SIARDHomePageButtonTextEditMetadata=edit metadata
+SIARDHomePageButtonTitleEditMetadataNotAvailable=Edit metadata information
+SIARDHomePageButtonTextEditMetadataNotAvailable=Metadata edition only supports SIARD version {0}.
SIARDHomePageButtonTextMigrateToSIARD=migrate to SIARD
SIARDHomePageButtonTextSendToLiveDBMS=send to live DBMS
SIARDHomePageButtonTextShowFile=Show file
@@ -329,6 +331,7 @@ SIARDHomePageDialogTitleForBrowsing=Browsing
SIARDHomePageTextForIngestNotSupported=Browsing the data only supports SIARD version 2.1, in order to browse the SIARD export it using the option '"'migrate to SIARD'"' available in the '"'SIARD'"' options.
SIARDHomePageTextForIngestSuccess=SIARD data successfully imported
SIARDHomePageDialogTitleForDelete=Delete
+SIARDHomePageDialogTextForDeleteNotAvailable=SIARD deletion only supports SIARD version {0}
SIARDHomePageDialogTitleForDeleteValidationReport=Delete validation report
SIARDHomePageDialogTitleForDeleteBrowseContent=Delete browse content
SIARDHomePageTextForDeleteAllFromServer=Are you sure you want to {startBold,}remove{endBold,} the SIARD structure, data and the file from the server? If you are aware of the consequences confirm the action, otherwise cancel.
@@ -336,6 +339,8 @@ SIARDHomePageTextForDeleteAllFromDesktop=Are you sure you want to {startBold,
SIARDHomePageTextForDeleteFromSolr=Are you sure you want to {startBold,}remove{endBold,} the SIARD data from the application? If you are aware of the consequences confirm the action, otherwise cancel.
SIARDHomePageTextForDeleteSIARD=Are you sure you want to {startBold,}remove{endBold,} the SIARD file from the server? Removing the SIARD will make the download of LOBs unavailable. If you are aware of the consequences confirm the action, otherwise cancel.
SIARDHomePageTextForDeleteSIARDReportValidation=Are you sure you want to {startBold,}delete{endBold,} the validation report file? If you are aware of the consequences confirm the action, otherwise cancel.
+SIARDHomePageTitleForDeleteSIARDNotAvailable=Delete metadata information
+SIARDHomePageTextForDeleteSIARDNotAvailable=Metadata deletion only supports SIARD version {0}
SIARDHomePageTextForRequiredSIARDFile=SIARD file not found on the system and is required to perform this action.
SIARDHomePageOptionsHeaderForPermissions=Permissions
SIARDHomePageOptionsDescriptionForPermissions=See the roles that are authorized to browse this database.
diff --git a/src/main/resources/config/i18n/client/ClientMessages_pt_PT.properties b/src/main/resources/config/i18n/client/ClientMessages_pt_PT.properties
index 1fe6e2900..6f4b66561 100644
--- a/src/main/resources/config/i18n/client/ClientMessages_pt_PT.properties
+++ b/src/main/resources/config/i18n/client/ClientMessages_pt_PT.properties
@@ -266,6 +266,8 @@ SIARDManagerPageInformationDialogTitle=Gestor do SIARD
SIARDManagerPageTextForWaitForFinishing=Por favor aguarde que o processo atual finalize
SIARDHomePageToastTitle=SIARD - {0}
SIARDHomePageButtonTextEditMetadata=editar metadados
+SIARDHomePageButtonTitleEditMetadataNotAvailable=Informação sobre edição de metadados
+SIARDHomePageButtonTextEditMetadataNotAvailable=Edição de metadados apenas suportada na versão {0}
SIARDHomePageButtonTextMigrateToSIARD=migrar para SIARD
SIARDHomePageButtonTextSendToLiveDBMS=enviar para um SGBDD
SIARDHomePageButtonTextShowFile=Mostrar ficheiro
@@ -326,6 +328,7 @@ SIARDHomePageDialogTitleForBrowsing=Navegação
SIARDHomePageTextForIngestNotSupported=A navegação pelos dados é apenas suportada para a versão 2.1 do SIARD.
SIARDHomePageTextForIngestSuccess=Os dados do SIARD foram importados com sucesso
SIARDHomePageDialogTitleForDelete=Eliminar
+SIARDHomePageDialogTextForDeleteNotAvailable=Eliminação de SIARDs apenas suportada na versão {0}
SIARDHomePageDialogTitleForDeleteValidationReport=Eliminar o relatório de validação
SIARDHomePageDialogTitleForDeleteBrowseContent=Eliminar o conteúdo da navegação
SIARDHomePageTextForDeleteAllFromServer=Tem a certeza que deseja {startBold,}eliminar endBold,} o SIARD da aplicação? Esta operação irá eliminar os metadados, dados (se ingerido) e o ficheiro SIARD. Se está consciente das consequências confirme a ação, caso contrário cancele.
@@ -333,6 +336,8 @@ SIARDHomePageTextForDeleteAllFromDesktop=Tem a certeza que deseja {startBold,
SIARDHomePageTextForDeleteFromSolr=Tem a certeza que deseja {startBold,}apagar{endBold,} os dados do SIARD? Essa ação irá remover da aplicação o conteudo do SIARD. Se está consciente das consequências confirme a ação, caso contrário cancele.
SIARDHomePageTextForDeleteSIARD=Tem a certeza que deseja {startBold,}eliminar{endBold,} o ficheiro SIARD? Esta operação irá eliminar o ficheiro SIARD do sistema. A remoção fará com que os LOB fiquem indisponíveis para descarregar. Se está consciente das consequências confirme a ação, caso contrário cancele.
SIARDHomePageTextForDeleteSIARDReportValidation=Tem a certeza que deseja {startBold,}eliminar{endBold,} o relatório de validação do SIARD? Esta operação irá eliminar o ficheiro do sistema. Se está consciente das consequências confirme a ação, caso contrário cancele.
+SIARDHomePageTitleForDeleteSIARDNotAvailable=Informação sobre eliminação de metadados
+SIARDHomePageTextForDeleteSIARDNotAvailable=Eliminação de metadados de SIARDs apenas suportada na versão {0}
SIARDHomePageTextForRequiredSIARDFile=Ficheiro SIARD não encontrado no sistema e é necessário para executar essa ação
SIARDHomePageOptionsHeaderForPermissions=Permissões
SIARDHomePageOptionsDescriptionForPermissions=Consulte as funções que estão autorizadas a navegar nesta base de dados.
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index 7cd2d4ac6..753234774 100644
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -83,7 +83,7 @@
com.databasepreservation.common.filter.OnOffFilter
inner-filter-class
- org.jasig.cas.client.session.SingleSignOutFilter
+ org.apereo.cas.client.session.SingleSignOutFilter
config-prefix
@@ -100,7 +100,7 @@
- org.jasig.cas.client.session.SingleSignOutHttpSessionListener
+ org.apereo.cas.client.session.SingleSignOutHttpSessionListener
@@ -109,7 +109,7 @@
com.databasepreservation.common.filter.OnOffFilter
inner-filter-class
- org.jasig.cas.client.validation.Cas30ProxyReceivingTicketValidationFilter
+ org.apereo.cas.client.validation.Cas30ProxyReceivingTicketValidationFilter
config-prefix
@@ -150,7 +150,7 @@
com.databasepreservation.common.filter.OnOffFilter
inner-filter-class
- org.jasig.cas.client.authentication.AuthenticationFilter
+ org.apereo.cas.client.authentication.AuthenticationFilter
config-prefix
@@ -175,7 +175,7 @@
com.databasepreservation.common.filter.OnOffFilter
inner-filter-class
- org.jasig.cas.client.util.HttpServletRequestWrapperFilter
+ org.apereo.cas.client.util.HttpServletRequestWrapperFilter
config-prefix