Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioG70 committed Jul 19, 2024
1 parent 3877922 commit 0317ab5
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 17 deletions.
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<version.gwt>2.11.0</version.gwt>
<scope.gwt-dev>provided</scope.gwt-dev>
<version.dbptk>3.0.0</version.dbptk>
<version.dbptk>3.1.0-SNAPSHOT</version.dbptk>
<version.roda>5.4.0</version.roda>
<version.jersey>3.1.6</version.jersey>
<version.swagger>2.2.20</version.swagger>
Expand Down Expand Up @@ -477,6 +477,11 @@
<artifactId>dbptk-bindings-siard2-1</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.databasepreservation</groupId>
<artifactId>dbptk-bindings-siarddk-2020</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.databasepreservation</groupId>
<artifactId>dbptk-model</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,9 @@ public ResponseEntity<StreamingResponseBody> exportLOB(
.equals(row.getCells().get(configTable.getColumnByIndex(columnIndex).getId()).getStoreType())) {
return handleExternalLobDownload(configTable, row, columnIndex);
} else {
return handleInternalLobDownload(database.getPath(), configTable, row, columnIndex);
// TODO use databaseUUID to get siard version
String version = ViewerConstants.SIARD2;
return handleInternalLobDownload(database.getPath(), configTable, row, columnIndex, version);
}
}
} catch (NotFoundException | GenericException | IOException e) {
Expand Down Expand Up @@ -583,7 +585,8 @@ private ResponseEntity<StreamingResponseBody> handleExternalLobDownload(TableSta
}

private ResponseEntity<StreamingResponseBody> 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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ 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";

/*
* DBPTK Metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public SafeHtml getValue(ViewerDatabase database) {
Column<ViewerDatabase, SafeHtml> description = new TooltipColumn<ViewerDatabase>() {
@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");
}
Expand All @@ -104,7 +104,7 @@ public SafeHtml getValue(ViewerDatabase database) {
Column<ViewerDatabase, SafeHtml> dataOwnerColumn = new TooltipColumn<ViewerDatabase>() {
@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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ 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("dk")) {
if (!btnIngestClicked) {
btnIngestClicked = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import java.util.Map;
import java.util.Set;

import com.databasepreservation.modules.siard.SIARDDK2020ModuleFactory;
import com.databasepreservation.modules.siard.SIARDDKEditFactory;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
Expand Down Expand Up @@ -603,7 +605,7 @@ private static void convertSIARDMetadataToSolr(Path siardPath, String databaseUU
Reporter reporter = new NoOpReporter();
SIARDEdition siardEdition = SIARDEdition.newInstance();

siardEdition.editModule(new SIARDEditFactory()).editModuleParameter(SIARDEditFactory.PARAMETER_FILE,
siardEdition.editModule(new SIARDDKEditFactory()).editModuleParameter(SIARDDKEditFactory.PARAMETER_FOLDER,
Collections.singletonList(siardPath.toAbsolutePath().toString()));

siardEdition.reporter(reporter);
Expand Down Expand Up @@ -697,9 +699,9 @@ 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");
databaseMigration.importModule(new SIARDDK2020ModuleFactory())
.importModuleParameter(SIARDDK2020ModuleFactory.PARAMETER_FOLDER, siardPath.toAbsolutePath().toString())
.importModuleParameter(SIARDDK2020ModuleFactory.PARAMETER_AS_SCHEMA, "public");

databaseMigration.exportModule(new DbvtkModuleFactory())
.exportModuleParameter(DbvtkModuleFactory.PARAMETER_DATABASE_UUID, databaseUUID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ private static ViewerCell getCell(CollectionStatus collectionConfiguration, View
actualViewerRow.addLobType(
collectionConfiguration.getTableStatusByTableId(table.getId()).getColumnByIndex(colIndex).getId(),
ViewerLobStoreType.INTERNALLY);

//TODO binaryCell.getFile() pass it to mimetype
detectMimeType(actualViewerRow, result, databasePath, collectionConfiguration, table, colIndex, lobName, true);
}
} else if (cell instanceof ComposedCell) {
Expand Down Expand Up @@ -886,10 +886,20 @@ private static void detectMimeType(ViewerRow row, ViewerCell cell, String databa
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 dbContainerName = databasePath.split("/")[databasePath.split("/").length - 1];

if (!dbContainerName.matches("AVID\\.[A-ZÆØÅ]{2,4}\\.[1-9][0-9].*")) {
String siardLobPath = LobManagerUtils.getZipFilePath(tableStatus, colIndex, lobName, ViewerConstants.SIARD_V21);
zipFile = new ZipFile(databasePath);
entry = zipFile.getEntry(siardLobPath);
} else {
blobIsInsideSiard = false;
//TODO CHANGE WAY TO GET SIARDDK PATH
String siardLobPath = LobManagerUtils.getZipFilePath(tableStatus, colIndex, lobName, ViewerConstants.SIARD_DK);
}

String lobCellValue = cell.getValue();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ public static String getZipFilePath(TableStatus configTable, int columnIndex, Vi
return "content" + "/" + siardSchemaFolder + "/" + siardTableFolder + "/" + siardLobFolder + "/" + lobCellValue;
}

public static String getZipFilePath(TableStatus configTable, int columnIndex, String recordValue) {
public static String getZipFilePath(TableStatus configTable, int columnIndex, String recordValue, String siardVersion) {
String siardSchemaFolder = configTable.getSchemaFolder();
String siardTableFolder = configTable.getTableFolder();
String siardLobFolder = ViewerConstants.SIARD_LOB_FOLDER_PREFIX + (columnIndex + 1);

return "content" + "/" + siardSchemaFolder + "/" + siardTableFolder + "/" + siardLobFolder + "/" + recordValue;
if (siardVersion.equals(ViewerConstants.SIARD_V21)) {
return "content" + "/" + siardSchemaFolder + "/" + siardTableFolder + "/" + siardLobFolder + "/" + recordValue;
} else {
return "content" + "/" + siardSchemaFolder + "/" + siardTableFolder + "/" + siardLobFolder + "/" + recordValue;
}
}

public static Path getConsolidatedPath(ViewerAbstractConfiguration configuration, String databaseUUID,
Expand Down

0 comments on commit 0317ab5

Please sign in to comment.