Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 1.0-maintenance
  • 1.1-maintenance
  • 1.10-maintenance
  • 1.11-maintenance
  • 1.3-maintenance
  • 1.5-maintenance
  • 1.6-RC
  • 1.6-maintenance
  • 1.7-maintenance
  • 1.8-maintenance
  • 1.9-maintenance
  • 2.0-maintenance
  • 2.1-maintenance
  • 2.2-maintenance
  • 2fa
  • 3.0-maintenance
  • ADF-deposit-purge
  • DGE-DLCM-MicroFactory-integration
  • DGE-DNAMIC-codec-v2
  • DLCM-2698_Support_SHA512_fingerprint
  • HCA-ARKv37
  • HCA-ChecksumCompute
  • HCA-CollectionNumber
  • HCA-DNAConnector-save
  • HCA-DataFileComplianceCheck
  • HCA-DnamicData
  • HCA-FixOrderSize
  • HCA-History
  • HCA-OpenApi-3.1.0
  • HCA-PremisAgents
  • HCA-PurgeDownloadedAip
  • HCA-Solidify3
  • JNA-docker-final
  • JPA-Siard-tool
  • MVO--jackson-test
  • MVO-ACL-allow-creator
  • MVO-Tools-JavaDoc
  • MVO-add-AnonymizedDepositPageId-on-deposit
  • MVO-add-JPEG-variants
  • MVO-add-pattern-matching-for-subset-dip
  • MVO-approve-submission-agreement-3tiers
  • MVO-auth3
  • MVO-clean-org-unit
  • MVO-clean-permission-service
  • MVO-complete-subResourceContainer-implementation
  • MVO-compute-notif-receivers
  • MVO-correct-IT-tests
  • MVO-dlcm-tools-web-client
  • MVO-dua-download
  • MVO-endpoint-for-data-files-status-stat
  • MVO-fix-DLCM-2456
  • MVO-fix-IT-tests
  • MVO-fix-NPE-DataFileListener
  • MVO-fix-annotations
  • MVO-fix-compound-accent-problem
  • MVO-fix-double-default
  • MVO-fix-fallback
  • MVO-fix-fullName
  • MVO-fix-mdWrapSize
  • MVO-fix-search-test
  • MVO-fix-serialize-change-info
  • MVO-fix-sip-update
  • MVO-fix-title-field
  • MVO-get-all-approbations
  • MVO-getAllApprobationsFiltering
  • MVO-improve-metadata-it2
  • MVO-institution-role
  • MVO-log-tokens
  • MVO-massive-deposit
  • MVO-metadata-unit-test
  • MVO-move-services-into-modules
  • MVO-new-notif
  • MVO-notification-history
  • MVO-ranking-auth
  • MVO-refacto-initDataIT
  • MVO-registry-message-transient
  • MVO-remove-getModule
  • MVO-remove-org-json
  • MVO-remove-persistent-id
  • MVO-remove-proxy-auth-filter
  • MVO-remove-public-private-index-tests
  • MVO-remove-user-repository
  • MVO-services-directly
  • MVO-submissionAgreementIT
  • MVO-update-sip-aip-names
  • MVO-upgrade-to-spring-boot-2.7
  • MVO-upgrade-xml-librairies
  • MVO-use-ES-keywords
  • MVO-use-RestClientService
  • MVO-use-RestTemplate-with-4MB-buffer
  • MVO-use-constructor-injection-on-service-layer
  • MVO-use-only-OffsetDateTime
  • MVO-use-only-role
  • MVO-use-only-token-auth
  • MVO-use-webclient-for-download
  • MVO-valid-by-jpql
  • MVO_test_token_expiration
  • Mvo-refactor-tools
  • NFO-docker
  • adf-177-archive-user-ranking
  • DLCM-Parent-0.0.1
  • DLCM-Parent-0.0.2
  • DLCM-Parent-0.0.3
  • DLCM-Parent-0.0.4
  • DLCM-Parent-0.0.5
  • dlcm-0-0.6
  • dlcm-0.0.7
  • dlcm-0.1.0
  • dlcm-0.2.0
  • dlcm-0.3.0
  • dlcm-0.4.0
  • dlcm-0.5.0
  • dlcm-0.6.0
  • dlcm-0.7.0
  • dlcm-0.7.1
  • dlcm-0.7.2
  • dlcm-0.8.0
  • dlcm-0.9.0
  • dlcm-1.0.0
  • dlcm-1.0.1
  • dlcm-1.0.2
  • dlcm-1.1.0
  • dlcm-1.1.1
  • dlcm-1.10.0
  • dlcm-1.10.0-RC1
  • dlcm-1.10.1
  • dlcm-1.10.2
  • dlcm-1.10.3
  • dlcm-1.10.4
  • dlcm-1.10.5
  • dlcm-1.10.6
  • dlcm-1.10.7
  • dlcm-1.11.0
  • dlcm-1.11.0-RC1
  • dlcm-1.11.0-RC2
  • dlcm-1.11.1
  • dlcm-1.11.2
  • dlcm-1.11.3
  • dlcm-1.11.4
  • dlcm-1.11.5
  • dlcm-1.11.6
  • dlcm-1.11.7
  • dlcm-1.11.8
  • dlcm-1.11.9
  • dlcm-1.12.0-RC1
  • dlcm-1.12.0-alpha
  • dlcm-1.2.0
  • dlcm-1.3.0
  • dlcm-1.3.1
  • dlcm-1.3.2
  • dlcm-1.3.3
  • dlcm-1.3.4
  • dlcm-1.4.0
  • dlcm-1.5.0
  • dlcm-1.5.1
  • dlcm-1.5.2
  • dlcm-1.5.3
  • dlcm-1.6.0
  • dlcm-1.6.0-RC1
  • dlcm-1.7.0
  • dlcm-1.7.0-RC1
  • dlcm-1.7.1
  • dlcm-1.7.2
  • dlcm-1.7.3
  • dlcm-1.8.0
  • dlcm-1.8.0-RC1
  • dlcm-1.9.0
  • dlcm-1.9.0-RC1
  • dlcm-1.9.0-RC2
  • dlcm-1.9.0-RC3
  • dlcm-1.9.1
  • dlcm-1.9.2
  • dlcm-2.0.0
  • dlcm-2.0.0-RC1
  • dlcm-2.0.0-RC2
  • dlcm-2.0.0-RC3
  • dlcm-2.0.1
  • dlcm-2.0.10
  • dlcm-2.0.11
  • dlcm-2.0.12
  • dlcm-2.0.13
  • dlcm-2.0.14
  • dlcm-2.0.15
  • dlcm-2.0.16
  • dlcm-2.0.17
  • dlcm-2.0.18
  • dlcm-2.0.19
  • dlcm-2.0.2
  • dlcm-2.0.3
  • dlcm-2.0.4
  • dlcm-2.0.5
  • dlcm-2.0.6
  • dlcm-2.0.7
  • dlcm-2.0.8
  • dlcm-2.0.9
  • dlcm-2.1.0
  • dlcm-2.1.0-RC1
  • dlcm-2.1.0-RC2
  • dlcm-2.1.0-RC3
  • dlcm-2.1.0-alpha1
200 results

Target

Select target project
  • dlcm/community/dlcm-backend
1 result
Select Git revision
  • 1.0-maintenance
  • 1.1-maintenance
  • 1.10-maintenance
  • 1.11-maintenance
  • 1.3-maintenance
  • 1.5-maintenance
  • 1.6-RC
  • 1.6-maintenance
  • 1.7-maintenance
  • 1.8-maintenance
  • 1.9-maintenance
  • 2.0-maintenance
  • 2.1-maintenance
  • 2.2-maintenance
  • 2fa
  • 3.0-maintenance
  • ADF-deposit-purge
  • DGE-DLCM-MicroFactory-integration
  • DGE-DNAMIC-codec-v2
  • DLCM-2698_Support_SHA512_fingerprint
  • HCA-ARKv37
  • HCA-ChecksumCompute
  • HCA-CollectionNumber
  • HCA-DNAConnector-save
  • HCA-DataFileComplianceCheck
  • HCA-DnamicData
  • HCA-FixOrderSize
  • HCA-History
  • HCA-OpenApi-3.1.0
  • HCA-PremisAgents
  • HCA-PurgeDownloadedAip
  • HCA-Solidify3
  • JNA-docker-final
  • JPA-Siard-tool
  • MVO--jackson-test
  • MVO-ACL-allow-creator
  • MVO-Tools-JavaDoc
  • MVO-add-AnonymizedDepositPageId-on-deposit
  • MVO-add-JPEG-variants
  • MVO-add-pattern-matching-for-subset-dip
  • MVO-approve-submission-agreement-3tiers
  • MVO-auth3
  • MVO-clean-org-unit
  • MVO-clean-permission-service
  • MVO-complete-subResourceContainer-implementation
  • MVO-compute-notif-receivers
  • MVO-correct-IT-tests
  • MVO-dlcm-tools-web-client
  • MVO-dua-download
  • MVO-endpoint-for-data-files-status-stat
  • MVO-fix-DLCM-2456
  • MVO-fix-IT-tests
  • MVO-fix-NPE-DataFileListener
  • MVO-fix-annotations
  • MVO-fix-compound-accent-problem
  • MVO-fix-double-default
  • MVO-fix-fallback
  • MVO-fix-fullName
  • MVO-fix-mdWrapSize
  • MVO-fix-search-test
  • MVO-fix-serialize-change-info
  • MVO-fix-sip-update
  • MVO-fix-title-field
  • MVO-get-all-approbations
  • MVO-getAllApprobationsFiltering
  • MVO-improve-metadata-it2
  • MVO-institution-role
  • MVO-log-tokens
  • MVO-massive-deposit
  • MVO-metadata-unit-test
  • MVO-move-services-into-modules
  • MVO-new-notif
  • MVO-notification-history
  • MVO-ranking-auth
  • MVO-refacto-initDataIT
  • MVO-registry-message-transient
  • MVO-remove-getModule
  • MVO-remove-org-json
  • MVO-remove-persistent-id
  • MVO-remove-proxy-auth-filter
  • MVO-remove-public-private-index-tests
  • MVO-remove-user-repository
  • MVO-services-directly
  • MVO-submissionAgreementIT
  • MVO-update-sip-aip-names
  • MVO-upgrade-to-spring-boot-2.7
  • MVO-upgrade-xml-librairies
  • MVO-use-ES-keywords
  • MVO-use-RestClientService
  • MVO-use-RestTemplate-with-4MB-buffer
  • MVO-use-constructor-injection-on-service-layer
  • MVO-use-only-OffsetDateTime
  • MVO-use-only-role
  • MVO-use-only-token-auth
  • MVO-use-webclient-for-download
  • MVO-valid-by-jpql
  • MVO_test_token_expiration
  • Mvo-refactor-tools
  • NFO-docker
  • adf-177-archive-user-ranking
  • DLCM-Parent-0.0.1
  • DLCM-Parent-0.0.2
  • DLCM-Parent-0.0.3
  • DLCM-Parent-0.0.4
  • DLCM-Parent-0.0.5
  • dlcm-0-0.6
  • dlcm-0.0.7
  • dlcm-0.1.0
  • dlcm-0.2.0
  • dlcm-0.3.0
  • dlcm-0.4.0
  • dlcm-0.5.0
  • dlcm-0.6.0
  • dlcm-0.7.0
  • dlcm-0.7.1
  • dlcm-0.7.2
  • dlcm-0.8.0
  • dlcm-0.9.0
  • dlcm-1.0.0
  • dlcm-1.0.1
  • dlcm-1.0.2
  • dlcm-1.1.0
  • dlcm-1.1.1
  • dlcm-1.10.0
  • dlcm-1.10.0-RC1
  • dlcm-1.10.1
  • dlcm-1.10.2
  • dlcm-1.10.3
  • dlcm-1.10.4
  • dlcm-1.10.5
  • dlcm-1.10.6
  • dlcm-1.10.7
  • dlcm-1.11.0
  • dlcm-1.11.0-RC1
  • dlcm-1.11.0-RC2
  • dlcm-1.11.1
  • dlcm-1.11.2
  • dlcm-1.11.3
  • dlcm-1.11.4
  • dlcm-1.11.5
  • dlcm-1.11.6
  • dlcm-1.11.7
  • dlcm-1.11.8
  • dlcm-1.11.9
  • dlcm-1.12.0-RC1
  • dlcm-1.12.0-alpha
  • dlcm-1.2.0
  • dlcm-1.3.0
  • dlcm-1.3.1
  • dlcm-1.3.2
  • dlcm-1.3.3
  • dlcm-1.3.4
  • dlcm-1.4.0
  • dlcm-1.5.0
  • dlcm-1.5.1
  • dlcm-1.5.2
  • dlcm-1.5.3
  • dlcm-1.6.0
  • dlcm-1.6.0-RC1
  • dlcm-1.7.0
  • dlcm-1.7.0-RC1
  • dlcm-1.7.1
  • dlcm-1.7.2
  • dlcm-1.7.3
  • dlcm-1.8.0
  • dlcm-1.8.0-RC1
  • dlcm-1.9.0
  • dlcm-1.9.0-RC1
  • dlcm-1.9.0-RC2
  • dlcm-1.9.0-RC3
  • dlcm-1.9.1
  • dlcm-1.9.2
  • dlcm-2.0.0
  • dlcm-2.0.0-RC1
  • dlcm-2.0.0-RC2
  • dlcm-2.0.0-RC3
  • dlcm-2.0.1
  • dlcm-2.0.10
  • dlcm-2.0.11
  • dlcm-2.0.12
  • dlcm-2.0.13
  • dlcm-2.0.14
  • dlcm-2.0.15
  • dlcm-2.0.16
  • dlcm-2.0.17
  • dlcm-2.0.18
  • dlcm-2.0.19
  • dlcm-2.0.2
  • dlcm-2.0.3
  • dlcm-2.0.4
  • dlcm-2.0.5
  • dlcm-2.0.6
  • dlcm-2.0.7
  • dlcm-2.0.8
  • dlcm-2.0.9
  • dlcm-2.1.0
  • dlcm-2.1.0-RC1
  • dlcm-2.1.0-RC2
  • dlcm-2.1.0-RC3
  • dlcm-2.1.0-alpha1
200 results
Show changes
Commits on Source (5)
Showing
with 620 additions and 107 deletions
......@@ -181,7 +181,7 @@ public class ZipAssemblingService extends AssemblingService {
// Generate DIP iD
String dipId = StringTool.generateResId();
// Generate DIP zip
if (!dipBuilderService.createDIPArchive(this.orderLocation, order, dipId, orgUnitId, accessLevel, accessPath,
if (!dipBuilderService.createDipArchive(this.orderLocation, order, dipId, orgUnitId, accessLevel, accessPath,
this.getDipFolder(order.getResId(), orgUnitId, accessLevel))) {
return null;
}
......
......@@ -42,6 +42,7 @@ import ch.dlcm.DLCMConstants;
import ch.dlcm.DLCMMetadataVersion;
import ch.dlcm.config.DLCMProperties;
import ch.dlcm.config.DLCMRepositoryDescription;
import ch.dlcm.model.access.Order;
import ch.dlcm.model.oais.ArchivalInfoPackage;
import ch.dlcm.service.MetadataService;
......@@ -65,10 +66,18 @@ public class BasicDipBuilderService extends DipBuilderService {
}
@Override
public Path getDestinationFolderFromDisseminationPolicy(Path rootFolder, ArchivalInfoPackage aip) {
public Path getDestinationFolderToUnzipAip(Path rootFolder, ArchivalInfoPackage aip) {
return rootFolder.resolve(aip.getResId());
}
@Override
public Path getBasePathToCreateDipZip(Path accessPath, Order order) {
if (order.getAipPackages().size() == 1) {
return accessPath.resolve(order.getAipPackages().get(0).getResId());
} else {
return accessPath;
}
}
private void extractDataciteMetadata(Path workingFolder, DLCMMetadataVersion metadataVersion) {
try {
......
......@@ -69,28 +69,30 @@ public abstract class DipBuilderService extends DLCMService {
public abstract void buildDip(Path workingFolder, DLCMMetadataVersion metadataVersion);
public abstract Path getDestinationFolderFromDisseminationPolicy(Path rootFolder, ArchivalInfoPackage aip);
public abstract Path getDestinationFolderToUnzipAip(Path rootFolder, ArchivalInfoPackage aip);
public boolean createDIPArchive(String orderLocation, Order order, String dipId, String orgUnitId, Access accessLevel, Path accessPath,
public abstract Path getBasePathToCreateDipZip(Path accessPath, Order order);
public boolean createDipArchive(String orderLocation, Order order, String dipId, String orgUnitId, Access accessLevel, Path accessPath,
Path dipFolder) throws IOException, JAXBException {
final ZipTool zipTool;
// Create order archive (i.e. DIP) & Purge working files for each orgUnit
zipTool = new ZipTool(this.getDIPArchiveUri(orderLocation, order.getResId(), orgUnitId, accessLevel, dipId));
if (!zipTool.zipFiles(accessPath)) {
zipTool = new ZipTool(this.getDipArchiveUri(orderLocation, order.getResId(), orgUnitId, accessLevel, dipId));
if (!zipTool.zipFiles(this.getBasePathToCreateDipZip(accessPath, order))) {
return false;
}
order.getAipPackages().forEach(aip -> FileTool.deleteFolder(accessPath.resolve(aip.getResId())));
return true;
}
public URI getDIPArchiveUri(String rootPath, String orderId, String orgUnitId, Access accessLevel, String dipId) {
public URI getDipArchiveUri(String rootPath, String orderId, String orgUnitId, Access accessLevel, String dipId) {
return Paths.get(rootPath).resolve(orderId).resolve(orgUnitId).resolve(accessLevel.name())
.resolve(dipId + SolidifyConstants.ZIP_EXT).toUri();
}
public boolean buildDip(Path rootFolder, List<ArchivalInfoPackage> aips, Order order, List<OrderSubsetItem> subsetItemList) {
for (final ArchivalInfoPackage aip : aips) {
Path destinationFolder = this.getDestinationFolderFromDisseminationPolicy(rootFolder, aip);
Path destinationFolder = this.getDestinationFolderToUnzipAip(rootFolder, aip);
if (!this.extractArchive(aip.getArchiveContainer(), aip.getDownloadUriForAccess(), destinationFolder)) {
return false;
}
......
......@@ -31,6 +31,7 @@ import ch.unige.solidify.service.MessageService;
import ch.dlcm.DLCMMetadataVersion;
import ch.dlcm.config.DLCMProperties;
import ch.dlcm.model.access.Order;
import ch.dlcm.model.oais.ArchivalInfoPackage;
import ch.dlcm.service.MetadataService;
......@@ -46,10 +47,19 @@ public class HederaDipBuilderService extends DipBuilderService {
public void buildDip(Path workingFolder, DLCMMetadataVersion metadataVersion) {
}
@Override
public Path getDestinationFolderFromDisseminationPolicy(Path rootFolder, ArchivalInfoPackage aip) {
public Path getDestinationFolderToUnzipAip(Path rootFolder, ArchivalInfoPackage aip) {
return rootFolder.resolve(aip.getResId());
}
@Override
public Path getBasePathToCreateDipZip(Path accessPath, Order order) {
if (order.getAipPackages().size() == 1) {
return accessPath.resolve(order.getAipPackages().get(0).getResId());
} else {
return accessPath;
}
}
}
......@@ -31,6 +31,7 @@ import ch.unige.solidify.service.MessageService;
import ch.dlcm.DLCMMetadataVersion;
import ch.dlcm.config.DLCMProperties;
import ch.dlcm.model.access.Order;
import ch.dlcm.model.oais.ArchivalInfoPackage;
import ch.dlcm.service.MetadataService;
......@@ -48,8 +49,17 @@ public class IiifDipBuilderService extends DipBuilderService {
}
@Override
public Path getDestinationFolderFromDisseminationPolicy(Path rootFolder, ArchivalInfoPackage aip) {
public Path getDestinationFolderToUnzipAip(Path rootFolder, ArchivalInfoPackage aip) {
return rootFolder.resolve(aip.getResId());
}
@Override
public Path getBasePathToCreateDipZip(Path accessPath, Order order) {
if (order.getAipPackages().size() == 1) {
return accessPath.resolve(order.getAipPackages().get(0).getResId());
} else {
return accessPath;
}
}
}
......@@ -57,18 +57,22 @@ public class OaisDipBuilderService extends DipBuilderService {
}
@Override
public Path getDestinationFolderFromDisseminationPolicy(Path rootFolder, ArchivalInfoPackage aip) {
public Path getDestinationFolderToUnzipAip(Path rootFolder, ArchivalInfoPackage aip) {
return rootFolder.resolve(DLCMConstants.DATA_FOLDER).resolve(aip.getResId());
}
@Override
public Path getBasePathToCreateDipZip(Path accessPath, Order order) {
return accessPath;
}
@Override
public boolean createDIPArchive(String orderLocation, Order order, String dipId, String orgUnitId, Access accessLevel, Path accessPath, Path dipFolder)
public boolean createDipArchive(String orderLocation, Order order, String dipId, String orgUnitId, Access accessLevel, Path accessPath, Path dipFolder)
throws IOException, JAXBException {
// For the OAIS dissemination policy, it is needed to generate the dlcm.xml metadata file
this.metadataService.generateMetadata(order, dipId, orgUnitId, accessLevel, dipFolder);
// Create order archive (i.e. DIP) & Purge working files for each orgUnit
final ZipTool zipTool = new ZipTool(this.getDIPArchiveUri(orderLocation, order.getResId(), orgUnitId, accessLevel, dipId));
final ZipTool zipTool = new ZipTool(this.getDipArchiveUri(orderLocation, order.getResId(), orgUnitId, accessLevel, dipId));
if (!zipTool.zipFiles(accessPath) || !FileTool.deleteFolder(accessPath.resolve(DLCMConstants.DATA_FOLDER))) {
return false;
}
......
......@@ -58,6 +58,12 @@ public class DLCMTestConstants {
public static final String THIRD_PARTY_USER_ID = "THIRD-PARTY-USER";
public static final String FOR_NO_ONE = "for no one";
/**
* Test ORCID account on Sandbox
* dlcm-test@mailinator.com
*/
public static final String ORCID_VALUE = "0009-0002-9189-3897";
public enum OrganizationalUnitStatus {
CLOSED, OPEN
}
......
......@@ -120,35 +120,73 @@ class MetadataIT extends AbstractAccessIT {
@Test
void downloadArchiveTest() throws IOException {
final RestCollection<ArchiveMetadata> archives = this.metadataClientService.listAllPublic();
if (archives.getPage().getTotalItems() > 0) {
// get the aip from collection created by init test
final List<ArchivalInfoPackage> aipList = this.aipClientService
.searchByProperties(Map.of("info.name", DLCMTestConstants.ARCHIVAL_UNIT_LABEL + " 1"));
if (aipList.isEmpty()) {
fail("Missing closed archive necessary for testing");
}
final String aipId = aipList.get(0).getResId();
// check if order has been already created
String orderId = this.metadataClientService.prepareDownload(aipId, DLCMConstants.DISSEMINATION_POLICY_OAIS_ID);
this.orderITService.waitForPublicOrderIsReadyOrInError(orderId, aipId);
// get the aip from collection created by init test
final List<ArchivalInfoPackage> aipList = this.aipClientService
.searchByProperties(Map.of("info.name", DLCMTestConstants.ARCHIVAL_UNIT_LABEL + " 1"));
if (aipList.isEmpty()) {
fail("Missing closed archive necessary for testing");
}
final String aipId = aipList.get(0).getResId();
// check if order has been already created
String orderId = this.metadataClientService.prepareDownload(aipId, DLCMConstants.DISSEMINATION_POLICY_OAIS_ID);
this.orderITService.waitForPublicOrderIsReadyOrInError(orderId, aipId);
Path path1 = Paths.get(System.getProperty("java.io.tmpdir"), "download1.tmp");
this.metadataClientService.downloadArchive(aipId, path1, orderId);
assertNotNull(path1.toFile());
Path path1 = Paths.get(System.getProperty("java.io.tmpdir"), "download1.tmp");
this.metadataClientService.downloadArchive(aipId, path1, orderId);
assertNotNull(path1.toFile());
// compare the archive with the one return by dip
Path path2 = Paths.get(System.getProperty("java.io.tmpdir"), "download2.tmp");
final DisseminationInfoPackage dip = this.dipClientService.searchByProperties(Map.of("info.name", aipId))
.stream().max(Comparator.comparing(n -> n.getLastUpdate().getWhen())).get();
this.dipClientService.downloadArchive(dip.getResId(), path2);
// compare the archive with the one return by dip
Path path2 = Paths.get(System.getProperty("java.io.tmpdir"), "download2.tmp");
final DisseminationInfoPackage dip = this.dipClientService.searchByProperties(Map.of("info.name", aipId))
.stream().max(Comparator.comparing(n ->n.getLastUpdate().getWhen())).get();
this.dipClientService.downloadArchive(dip.getResId(), path2);
assertNotNull(path2.toFile());
assertArrayEquals(Files.readAllBytes(path1), Files.readAllBytes(path2));
assertNotNull(path2.toFile());
assertArrayEquals(Files.readAllBytes(path1), Files.readAllBytes(path2));
FileTool.deleteFile(path1);
FileTool.deleteFile(path2);
FileTool.deleteFile(path1);
FileTool.deleteFile(path2);
}
@Test
void checkFilePathInArchiveZipTest() throws IOException {
// get the aip from collection created by init test
final List<ArchivalInfoPackage> aipList = this.aipClientService
.searchByProperties(Map.of("info.name", DLCMTestConstants.ARCHIVAL_UNIT_LABEL + " 1"));
if (aipList.isEmpty()) {
fail("Missing closed archive necessary for testing");
}
final String aipId = aipList.get(0).getResId();
// check if order has been already created
String orderId = this.metadataClientService.prepareDownload(aipId, DLCMConstants.DISSEMINATION_POLICY_OAIS_ID);
this.orderITService.waitForPublicOrderIsReadyOrInError(orderId, aipId);
Path path1 = Paths.get(System.getProperty("java.io.tmpdir"), "download1.tmp");
this.metadataClientService.downloadArchive(aipId, path1, orderId);
assertNotNull(path1.toFile());
// compare the archive with the one return by dip
Path path2 = Paths.get(System.getProperty("java.io.tmpdir"), "download2.tmp");
final DisseminationInfoPackage dip = this.dipClientService.searchByProperties(Map.of("info.name", aipId))
.stream().max(Comparator.comparing(n -> n.getLastUpdate().getWhen())).get();
this.dipClientService.downloadArchive(dip.getResId(), path2);
assertNotNull(path2.toFile());
assertArrayEquals(Files.readAllBytes(path1), Files.readAllBytes(path2));
// Check content of the zip has the aipId as root.
final ZipTool zip = new ZipTool(path1.toUri());
final Path tempPath = Paths.get(System.getProperty("java.io.tmpdir"));
List<String> pathList = zip.unzipFilesAndReturnList(tempPath, false)
.stream()
.map(Path::toString)
.toList();
assertTrue(pathList.contains(tempPath.resolve("data/" + aipId + "/researchdata/tmp/dlcm/test/budget-2013.pdf").normalize().toString()));
FileTool.deleteFile(path1);
FileTool.deleteFile(path2);
}
......@@ -196,8 +234,8 @@ class MetadataIT extends AbstractAccessIT {
.map(Path::toString)
.toList();
assertTrue(pathList.contains(tempPath.resolve(aipId + "/researchdata/Yareta 2.0/Yareta-logo.png").normalize().toString()));
assertFalse(pathList.contains(tempPath.resolve(aipId + "/researchdata/file_that_does_not_exist.pdf").normalize().toString()));
assertTrue(pathList.contains(tempPath.resolve("researchdata/Yareta 2.0/Yareta-logo.png").normalize().toString()));
assertFalse(pathList.contains(tempPath.resolve("researchdata/file_that_does_not_exist.pdf").normalize().toString()));
FileTool.deleteFile(path1);
}
......@@ -225,7 +263,7 @@ class MetadataIT extends AbstractAccessIT {
final Path path2 = Paths.get(System.getProperty("java.io.tmpdir"), "download2.tmp");
final DisseminationInfoPackage dip = this.dipClientService.searchByProperties(Map.of("info.name", aipId))
.stream().max(Comparator.comparing(n ->n.getLastUpdate().getWhen())).get();
.stream().max(Comparator.comparing(n -> n.getLastUpdate().getWhen())).get();
this.dipClientService.downloadArchive(dip.getResId(), path2);
assertNotNull(path2.toFile());
......@@ -237,8 +275,8 @@ class MetadataIT extends AbstractAccessIT {
.map(Path::toString)
.toList();
assertTrue(pathList.contains(tempPath.resolve(aipId + "/researchdata/Yareta 2.0/Yareta-logo.png").normalize().toString()));
assertTrue(pathList.contains(tempPath.resolve(aipId + "/researchdata/I-Love-RD-Sticker.pdf").normalize().toString()));
assertTrue(pathList.contains(tempPath.resolve("researchdata/Yareta 2.0/Yareta-logo.png").normalize().toString()));
assertTrue(pathList.contains(tempPath.resolve("researchdata/I-Love-RD-Sticker.pdf").normalize().toString()));
FileTool.deleteFile(path1);
FileTool.deleteFile(path2);
......
......@@ -30,7 +30,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
......@@ -65,7 +64,8 @@ class NotificationAsAdminIT extends AbstractNotificationIT {
@Autowired
public NotificationAsAdminIT(Environment env, SudoRestClientTool restClientTool, NotificationClientService notificationClientService,
UserClientService userClientService, OrgUnitITService orgUnitITService, PersonITService personITService, DepositITService depositITService) {
UserClientService userClientService, OrgUnitITService orgUnitITService, PersonITService personITService,
DepositITService depositITService) {
super(env, restClientTool, notificationClientService, userClientService, orgUnitITService, personITService, depositITService);
}
......@@ -252,7 +252,8 @@ class NotificationAsAdminIT extends AbstractNotificationIT {
List<Notification> notificationList = this.notificationClientService.getInboxNotifications(NotificationType.VALIDATE_DEPOSIT_REQUEST);
int countValidatedDepositRequest = notificationList.size();
final Deposit deposit = this.depositITService.createRemoteDepositWithContributorAndSubmissionApprove(PersistenceMode.TEMPORARY, "Deposit notification", DEFAULT_DESCRIPTION);
final Deposit deposit = this.depositITService.createRemoteDepositWithContributorsAndSubmissionApprove(PersistenceMode.TEMPORARY,
"Deposit notification", DEFAULT_DESCRIPTION);
final DepositDataFile depositDataFile = this.depositITService.createDataFile(deposit);
this.depositITService.addDataFileToDeposit(deposit.getResId(), depositDataFile);
......@@ -270,7 +271,8 @@ class NotificationAsAdminIT extends AbstractNotificationIT {
// Check that the notification has been change the status
notificationList = this.notificationClientService.getInboxNotifications(NotificationType.VALIDATE_DEPOSIT_REQUEST);
Optional<Notification> notificationFromDepositOpt = notificationList.stream().filter(n -> deposit.getResId().equals(n.getObjectId())).findFirst();
Optional<Notification> notificationFromDepositOpt = notificationList.stream().filter(n -> deposit.getResId().equals(n.getObjectId()))
.findFirst();
assertTrue(notificationFromDepositOpt.isPresent());
assertEquals(NotificationStatus.APPROVED, notificationFromDepositOpt.get().getNotificationStatus());
}
......@@ -280,7 +282,8 @@ class NotificationAsAdminIT extends AbstractNotificationIT {
List<Notification> notificationList = this.notificationClientService.getInboxNotifications(NotificationType.VALIDATE_DEPOSIT_REQUEST);
int countValidatedDepositRequest = notificationList.size();
final Deposit deposit = this.depositITService.createRemoteDepositWithContributorAndSubmissionApprove(PersistenceMode.TEMPORARY, "Deposit notification", DEFAULT_DESCRIPTION);
final Deposit deposit = this.depositITService.createRemoteDepositWithContributorsAndSubmissionApprove(PersistenceMode.TEMPORARY,
"Deposit notification", DEFAULT_DESCRIPTION);
final DepositDataFile depositDataFile = this.depositITService.createDataFile(deposit);
this.depositITService.addDataFileToDeposit(deposit.getResId(), depositDataFile);
......@@ -298,7 +301,8 @@ class NotificationAsAdminIT extends AbstractNotificationIT {
// Check that the notification has been change the status
notificationList = this.notificationClientService.getInboxNotifications(NotificationType.VALIDATE_DEPOSIT_REQUEST);
Optional<Notification> notificationFromDepositOpt = notificationList.stream().filter(n -> deposit.getResId().equals(n.getObjectId())).findFirst();
Optional<Notification> notificationFromDepositOpt = notificationList.stream().filter(n -> deposit.getResId().equals(n.getObjectId()))
.findFirst();
assertTrue(notificationFromDepositOpt.isPresent());
assertEquals(NotificationStatus.REFUSED, notificationFromDepositOpt.get().getNotificationStatus());
}
......
......@@ -189,6 +189,46 @@ abstract class AbstractDepositAsCreatorIT extends AbstractDepositWithRoleIT {
assertEquals(person1.getLastName(), person2.getLastName());
}
@Test
void contributorWithOrcidTest() {
final Deposit deposit = this.createRemoteDepositForCurrentRole();
// Create a new Person
final Person person1 = this.personITService.getOrCreateRemotePerson();
// Add the person as contributor
this.depositClientService.addContributor(deposit.getResId(), person1.getResId());
List<Person> listContributors = this.depositClientService.getContributors(deposit.getResId());
assertEquals(1, listContributors.size());
Person fetchedPerson1 = listContributors.get(0);
// Test the contributor
assertEquals(person1.getResId(), fetchedPerson1.getResId());
assertEquals(person1.getFirstName(), fetchedPerson1.getFirstName());
assertEquals(person1.getLastName(), fetchedPerson1.getLastName());
// Create and add a new Person with ORCID
final Person person2 = this.personITService.getOrCreateRemotePersonWithOrcid();
this.depositClientService.addContributor(deposit.getResId(), person2.getResId());
listContributors = this.depositClientService.getContributors(deposit.getResId());
assertEquals(2, listContributors.size());
fetchedPerson1 = listContributors.get(0);
final Person fetchedPerson2 = listContributors.get(1);
// Test the contributors
assertEquals(person1.getResId(), fetchedPerson1.getResId());
assertEquals(person1.getFirstName(), fetchedPerson1.getFirstName());
assertEquals(person1.getLastName(), fetchedPerson1.getLastName());
assertNull(person1.getOrcid());
assertEquals(person2.getResId(), fetchedPerson2.getResId());
assertEquals(person2.getFirstName(), fetchedPerson2.getFirstName());
assertEquals(person2.getLastName(), fetchedPerson2.getLastName());
assertNotNull(fetchedPerson2.getOrcid());
assertEquals(person2.getOrcid(), fetchedPerson2.getOrcid());
}
@Test
void creationWithResIdTest() {
final Deposit deposit = this.createLocalDepositForCurrentRole();
......@@ -212,6 +252,93 @@ abstract class AbstractDepositAsCreatorIT extends AbstractDepositWithRoleIT {
assertThrows(HttpClientErrorException.NotFound.class, () -> this.depositClientService.findOne(resId));
}
@Test
void deleteWithContributorTest() {
Deposit deposit = this.createRemoteDepositForCurrentRole();
// Create and add a new Person
final Person person1 = this.personITService.getOrCreateRemotePerson();
this.depositClientService.addContributor(deposit.getResId(), person1.getResId());
List<Person> listContributors = this.depositClientService.getContributors(deposit.getResId());
assertEquals(1, listContributors.size());
Person fetchedPerson1 = listContributors.get(0);
assertEquals(person1.getResId(), fetchedPerson1.getResId());
// Delete the deposit
final String resId = deposit.getResId();
this.depositClientService.delete(resId);
// Wait one second to let asynchronous deletion complete before to check
SolidifyTime.waitOneSecond();
assertThrows(HttpClientErrorException.NotFound.class, () -> this.depositClientService.findOne(resId));
}
@Test
void deleteWithDeletedContributorTest() {
Deposit deposit = this.createRemoteDepositForCurrentRole();
// Create and add a new Person
String firstName = DLCMTestConstants.getRandomNameWithTemporaryLabel("John");
String lastName = DLCMTestConstants.getRandomNameWithTemporaryLabel("Doe");
final Person person1 = this.personITService.getOrCreateRemotePerson(firstName, lastName, null);
final String personId = person1.getResId();
this.depositClientService.addContributor(deposit.getResId(), personId);
List<Person> listContributors = this.depositClientService.getContributors(deposit.getResId());
assertEquals(1, listContributors.size());
Person fetchedPerson1 = listContributors.get(0);
assertEquals(personId, fetchedPerson1.getResId());
// Check Person exists
assertNotNull(this.personITService.findOne(personId));
// Delete the person
this.restClientTool.sudoAdmin();
this.personITService.delete(personId);
this.restClientTool.exitSudo();
assertThrows(HttpClientErrorException.NotFound.class, () -> this.personITService.findOne(personId));
// Delete the deposit
final String resId = deposit.getResId();
this.depositClientService.delete(resId);
// Wait one second to let asynchronous deletion complete before to check
SolidifyTime.waitOneSecond();
assertThrows(HttpClientErrorException.NotFound.class, () -> this.depositClientService.findOne(resId));
}
@Test
void deleteWithDeletedContributorWithOrcidTest() {
Deposit deposit = this.createRemoteDepositForCurrentRole();
// Create and add a new Person
String firstName = DLCMTestConstants.getRandomNameWithTemporaryLabel("John");
String lastName = DLCMTestConstants.getRandomNameWithTemporaryLabel("Doe");
String orcid = "1234-1234-1234-4567";
final Person person1 = this.personITService.getOrCreateRemotePerson(firstName, lastName, orcid);
final String personId = person1.getResId();
this.depositClientService.addContributor(deposit.getResId(), personId);
List<Person> listContributors = this.depositClientService.getContributors(deposit.getResId());
assertEquals(1, listContributors.size());
Person fetchedPerson1 = listContributors.get(0);
assertEquals(personId, fetchedPerson1.getResId());
// Check Person exists
Person foundPerson1 = this.personITService.findOne(personId);
assertNotNull(foundPerson1);
assertEquals(orcid, foundPerson1.getOrcid());
// Delete the person
this.restClientTool.sudoAdmin();
this.personITService.delete(personId);
this.restClientTool.exitSudo();
assertThrows(HttpClientErrorException.NotFound.class, () -> this.personITService.findOne(personId));
// Delete the deposit
final String resId = deposit.getResId();
this.depositClientService.delete(resId);
// Wait one second to let asynchronous deletion complete before to check
SolidifyTime.waitOneSecond();
assertThrows(HttpClientErrorException.NotFound.class, () -> this.depositClientService.findOne(resId));
}
@Test
void dontUpdateResIdTest() {
final Deposit deposit = this.createRemoteDepositForCurrentRole();
......@@ -286,6 +413,7 @@ abstract class AbstractDepositAsCreatorIT extends AbstractDepositWithRoleIT {
DLCMTestConstants.OrganizationalUnitStatus.OPEN,
NO_ONE, null, false);
this.restClientTool.exitSudo();
assertThrows(HttpClientErrorException.Forbidden.class, () -> this.depositClientService.findAllWithOrgunitId(organizationalUnit.getOrganizationalUnitId()));
assertThrows(HttpClientErrorException.Forbidden.class,
() -> this.depositClientService.findAllWithOrgunitId(organizationalUnit.getOrganizationalUnitId()));
}
}
......@@ -87,15 +87,18 @@ abstract class AbstractMetadataEditionIT extends AbstractPreingestIT {
DEFAULT_DESCRIPTION, Role.MANAGER_ID, false, DLCMMetadataVersion.getDefaultVersion());
deposit.setMetadataVersion(metadataVersion);
deposit = this.depositClientService.create(deposit);
final Person person = this.personITService.getOrCreateRemotePerson();
this.depositClientService.addContributor(deposit.getResId(), person.getResId());
final Person person1 = this.personITService.getOrCreateRemotePerson();
this.depositClientService.addContributor(deposit.getResId(), person1.getResId());
final Person person2 = this.personITService.getOrCreateRemotePersonWithOrcid();
this.depositClientService.addContributor(deposit.getResId(), person2.getResId());
// TODO: this.restClientTool.exitSudo();
final OrganizationalUnit orgUnit = this.orgUnitITService.getOrganizationalUnit(deposit.getOrganizationalUnitId());
return this.getDepositWithCompleteAip(orgUnit, deposit);
}
private Deposit getDepositWithCompleteAip(OrganizationalUnit orgUnit, Deposit deposit) {
protected Deposit getDepositWithCompleteAip(OrganizationalUnit orgUnit, Deposit deposit) {
this.restClientTool.sudoAdmin();
deposit.addItem(this.depositITService.createLocalDepositDataFile(deposit));
final Deposit deposit1 = this.depositITService.createRemoteDepositWithData(deposit);
......@@ -114,7 +117,7 @@ abstract class AbstractMetadataEditionIT extends AbstractPreingestIT {
DLCMTestConstants.OrganizationalUnitStatus.OPEN, Role.MANAGER_ID, AuthApplicationRole.USER_ID, false);
// Create and complete a deposit
this.restClientTool.sudoAdmin();
final Deposit deposit = this.depositITService.createRemoteDepositWithContributorAndSubmissionApprove(PersistenceMode.TEMPORARY,
final Deposit deposit = this.depositITService.createRemoteDepositWithContributorsAndSubmissionApprove(PersistenceMode.TEMPORARY,
TEMP_DEPOSIT_WITH_COMPLETED_AIP_TITLE, DEFAULT_DESCRIPTION);
deposit.addItem(this.depositITService.createLocalDepositDataFile(deposit));
final Deposit deposit1 = this.depositITService.createRemoteDepositWithData(deposit);
......
......@@ -63,12 +63,16 @@ class DepositNotificationIT extends AbstractPreingestIT {
void checkNotificationsDuringSubmissionProcess() {
// Check inbox for each notification before creating a deposit
List<Notification> toApproveDepositNotificationList = this.notificationITService.getInboxNotifications(NotificationType.VALIDATE_DEPOSIT_REQUEST);
List<Notification> approvedDepositNotificationList = this.notificationITService.getInboxNotifications(NotificationType.MY_APPROVED_DEPOSIT_INFO);
List<Notification> completedDepositNotificationList = this.notificationITService.getInboxNotifications(NotificationType.MY_COMPLETED_DEPOSIT_INFO);
List<Notification> toApproveDepositNotificationList = this.notificationITService.getInboxNotifications(
NotificationType.VALIDATE_DEPOSIT_REQUEST);
List<Notification> approvedDepositNotificationList = this.notificationITService.getInboxNotifications(
NotificationType.MY_APPROVED_DEPOSIT_INFO);
List<Notification> completedDepositNotificationList = this.notificationITService.getInboxNotifications(
NotificationType.MY_COMPLETED_DEPOSIT_INFO);
// Create a deposit and wait until it is completed
final Deposit deposit = this.depositITService.createRemoteDepositWithContributorAndSubmissionApprove(DLCMTestConstants.PersistenceMode.TEMPORARY,
final Deposit deposit = this.depositITService.createRemoteDepositWithContributorsAndSubmissionApprove(
DLCMTestConstants.PersistenceMode.TEMPORARY,
"Test creation of notifications when creating and submitting deposit", DEFAULT_DESCRIPTION);
deposit.addItem(this.depositITService.createLocalDepositDataFile(deposit));
final Deposit depositRemote = this.depositITService.createRemoteDepositWithData(deposit);
......@@ -81,9 +85,12 @@ class DepositNotificationIT extends AbstractPreingestIT {
this.depositITService.waitDepositIsCompleted(deposit.getResId());
// Check notification's inbox after creating the deposit
List<Notification> toApproveDepositNotificationListAfterNewDeposit = this.notificationITService.getInboxNotifications(NotificationType.VALIDATE_DEPOSIT_REQUEST);
List<Notification> approvedDepositNotificationListAfterNewDeposit = this.notificationITService.getInboxNotifications(NotificationType.MY_APPROVED_DEPOSIT_INFO);
List<Notification> completedDepositNotificationListAfterNewDeposit = this.notificationITService.getInboxNotifications(NotificationType.MY_COMPLETED_DEPOSIT_INFO);
List<Notification> toApproveDepositNotificationListAfterNewDeposit = this.notificationITService.getInboxNotifications(
NotificationType.VALIDATE_DEPOSIT_REQUEST);
List<Notification> approvedDepositNotificationListAfterNewDeposit = this.notificationITService.getInboxNotifications(
NotificationType.MY_APPROVED_DEPOSIT_INFO);
List<Notification> completedDepositNotificationListAfterNewDeposit = this.notificationITService.getInboxNotifications(
NotificationType.MY_COMPLETED_DEPOSIT_INFO);
assertEquals(toApproveDepositNotificationList.size() + 1, toApproveDepositNotificationListAfterNewDeposit.size());
assertEquals(approvedDepositNotificationList.size() + 1, approvedDepositNotificationListAfterNewDeposit.size());
......
......@@ -26,6 +26,7 @@ package ch.dlcm.test.preingest;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
......@@ -66,6 +67,7 @@ import ch.dlcm.model.preingest.Deposit;
import ch.dlcm.model.preingest.Deposit.DepositStatus;
import ch.dlcm.model.security.Role;
import ch.dlcm.model.settings.OrganizationalUnit;
import ch.dlcm.model.settings.Person;
import ch.dlcm.service.access.MetadataClientService;
import ch.dlcm.service.preingest.DepositClientService;
import ch.dlcm.test.DLCMTestConstants;
......@@ -88,7 +90,16 @@ class MetadataUpdateIT extends AbstractMetadataEditionIT {
MetadataClientService metadataClientService,
OrderITService orderITService,
PersonITService personITService) {
super(env, restClientTool, orgUnitITService, depositITService, depositClientService, aipITService, metadataClientService, orderITService, personITService);
super(env, restClientTool, orgUnitITService, depositITService, depositClientService, aipITService, metadataClientService, orderITService,
personITService);
}
@Override
protected void deleteFixtures() {
super.deleteFixtures();
this.restClientTool.sudoRoot();
this.personITService.clearPeopleFixtures();
this.restClientTool.exitSudo();
}
@Test
......@@ -370,36 +381,135 @@ class MetadataUpdateIT extends AbstractMetadataEditionIT {
@Test
void cancelMetadataEditingTest() {
this.testCancelMetadataEditing(false);
}
@Test
void cancelMetadataEditingWithDeletedContributorsTest() {
this.testCancelMetadataEditing(true);
}
private void testCancelMetadataEditing(boolean withDeletedContributors) {
Deposit deposit = this.createDepositWithCompletedAip();
String originalTitle = deposit.getTitle();
String originalDescription = deposit.getDescription();
this.depositITService.waitDepositIsCompleted(deposit.getResId());
final String depositId = deposit.getResId();
final String originalTitle = deposit.getTitle();
final String originalDescription = deposit.getDescription();
this.depositITService.waitDepositIsCompleted(depositId);
this.aipITService.waitAIPIsReady(deposit.getOrganizationalUnitId(), originalTitle);
List<Person> listContributors = this.depositClientService.getContributors(depositId);
assertEquals(2, listContributors.size());
deposit = this.depositITService.startEditingMetadata(deposit);
String title = DLCMTestConstants.getRandomNameWithTemporaryLabel("Deposit v1");
deposit.setTitle(title);
deposit.setDescription("Deposit corrected (version 1)");
assertEquals(originalDescription, deposit.getDescription());
final String newTitle = DLCMTestConstants.getRandomNameWithTemporaryLabel("Deposit v1");
final String newDescription = "Deposit corrected (version 1)";
deposit.setTitle(newTitle);
deposit.setDescription(newDescription);
this.depositClientService.update(depositId, deposit);
Deposit updatedDeposit = this.depositClientService.findOne(depositId);
assertEquals(newTitle, updatedDeposit.getTitle());
assertEquals(newDescription, updatedDeposit.getDescription());
// Create and add a new Person with ORCID
final String firstName3 = DLCMTestConstants.getRandomNameWithTemporaryLabel("John");
final String lastName3 = DLCMTestConstants.getRandomNameWithTemporaryLabel("Doe");
final String orcid = "1234-1234-1234-4567";
final Person person3 = this.personITService.getOrCreateRemotePerson(firstName3, lastName3, orcid);
final String personId3 = person3.getResId();
this.depositClientService.addContributor(depositId, personId3);
// Create and add a new Person
final String firstName4 = DLCMTestConstants.getRandomNameWithTemporaryLabel("Jane");
final String lastName4 = DLCMTestConstants.getRandomNameWithTemporaryLabel("Doe");
final Person person4 = this.personITService.getOrCreateRemotePerson(firstName4, lastName4, null);
final String personId4 = person4.getResId();
this.depositClientService.addContributor(depositId, personId4);
// Check contributors are added to the deposit
listContributors = this.depositClientService.getContributors(depositId);
assertEquals(4, listContributors.size());
final Person fetchedPerson3 = listContributors.get(2);
assertEquals(personId3, fetchedPerson3.getResId());
assertEquals(orcid, fetchedPerson3.getOrcid());
final Person fetchedPerson4 = listContributors.get(3);
assertEquals(personId4, fetchedPerson4.getResId());
assertNull(fetchedPerson4.getOrcid());
if (withDeletedContributors) {
// Delete contributors before cancelling the update
this.restClientTool.sudoAdmin();
this.personITService.delete(personId3);
this.personITService.delete(personId4);
this.restClientTool.exitSudo();
}
this.depositClientService.update(deposit.getResId(), deposit);
this.depositClientService.cancelEditingMetadata(deposit.getResId());
this.depositITService.waitDepositIsCompleted(deposit.getResId());
// Find deposit with original values by searching
Map<String, String> properties = new HashMap<>();
properties.put("title", title);
properties.put("title", originalTitle);
properties.put("organizationalUnitId", deposit.getOrganizationalUnitId());
Deposit depositChanged = this.depositClientService.searchByProperties(properties).get(0);
updatedDeposit = this.depositClientService.searchByProperties(properties).get(0);
assertEquals(deposit.getTitle(), depositChanged.getTitle());
assertEquals(deposit.getDescription(), depositChanged.getDescription());
assertEquals(originalTitle, updatedDeposit.getTitle());
assertEquals(originalDescription, updatedDeposit.getDescription());
listContributors = this.depositClientService.getContributors(depositId);
assertEquals(2, listContributors.size());
}
@Test
void restoreMetadataWithContributorThatHasNoMoreOrcid() {
this.restClientTool.sudoAdmin();
Deposit deposit = this.depositITService.createLocalDeposit(PersistenceMode.TEMPORARY, TEMP_DEPOSIT_WITH_COMPLETED_AIP_TITLE,
DEFAULT_DESCRIPTION, Role.MANAGER_ID, false, DLCMMetadataVersion.getDefaultVersion());
deposit.setMetadataVersion(DLCMMetadataVersion.getDefaultVersion());
deposit = this.depositClientService.create(deposit);
final String depositId = deposit.getResId();
final String firstName = DLCMTestConstants.getRandomNameWithTemporaryLabel("John");
final String lastName = DLCMTestConstants.getRandomNameWithTemporaryLabel("Doe");
final String orcid = "1234-1234-1234-4567";
Person person = this.personITService.getOrCreateRemotePerson(firstName, lastName, orcid);
final String personId = person.getResId();
this.depositClientService.addContributor(depositId, personId);
final OrganizationalUnit orgUnit = this.orgUnitITService.getOrganizationalUnit(deposit.getOrganizationalUnitId());
deposit = this.getDepositWithCompleteAip(orgUnit, deposit);
this.restClientTool.exitSudo();
// Start metadata edition
deposit = this.depositITService.startEditingMetadata(deposit);
// Remove ORCID from contributor
person = this.personITService.findOne(personId);
assertEquals(orcid, person.getOrcid());
this.restClientTool.sudoAdmin();
person.setOrcid(null);
this.personITService.update(personId, person);
this.restClientTool.exitSudo();
person = this.personITService.findOne(personId);
assertNull(person.getOrcid());
this.depositClientService.cancelEditingMetadata(deposit.getResId());
this.depositITService.waitDepositIsCompleted(deposit.getResId());
properties.clear();
properties.put("title", originalTitle);
properties.put("organizationalUnitId", deposit.getOrganizationalUnitId());
depositChanged = this.depositClientService.searchByProperties(properties).get(0);
assertEquals(originalTitle, depositChanged.getTitle());
assertEquals(originalDescription, depositChanged.getDescription());
deposit = this.depositClientService.findOne(depositId);
assertEquals(DepositStatus.COMPLETED, deposit.getStatus());
// Check that even if ORCID is removed, the contributor is found back
// Note: it works only if only one Person with the same name exists.
List<Person> listContributors = this.depositClientService.getContributors(depositId);
assertEquals(1, listContributors.size());
Person person1 = listContributors.get(0);
assertEquals(firstName, person1.getFirstName());
assertEquals(lastName, person1.getLastName());
assertEquals(personId, person1.getResId());
assertNull(person1.getOrcid());
}
@Test
......
......@@ -113,13 +113,15 @@ public class DepositITService extends ITService {
return deposit;
}
public Deposit createLocalDepositWithMetadataVersion(PersistenceMode persistenceMode, String title, String description, DLCMMetadataVersion version) {
public Deposit createLocalDepositWithMetadataVersion(PersistenceMode persistenceMode, String title, String description,
DLCMMetadataVersion version) {
final Deposit deposit = this.createLocalDeposit(persistenceMode, title, description);
deposit.setMetadataVersion(version);
return deposit;
}
public Deposit createLocalDeposit(PersistenceMode persistenceMode, String title, String description, String role, boolean inheritedRole, DLCMMetadataVersion version) {
public Deposit createLocalDeposit(PersistenceMode persistenceMode, String title, String description, String role, boolean inheritedRole,
DLCMMetadataVersion version) {
final Deposit deposit = this.createLocalDepositWithMetadataVersion(persistenceMode, title, description, version);
final OrganizationalUnit organizationalUnit = this.orgUnitITService.getTestOrganizationalUnitAsUser(PersistenceMode.PERMANENT,
OrganizationalUnitStatus.OPEN, role, false, inheritedRole);
......@@ -151,7 +153,8 @@ public class DepositITService extends ITService {
return this.createRemoteDeposit(persistenceMode, title, description, Role.MANAGER_ID, false, version);
}
public Deposit createRemoteDeposit(PersistenceMode persistenceMode, String title, String description, String role, boolean inheritedRole, DLCMMetadataVersion version) {
public Deposit createRemoteDeposit(PersistenceMode persistenceMode, String title, String description, String role, boolean inheritedRole,
DLCMMetadataVersion version) {
Deposit deposit = this.createLocalDeposit(persistenceMode, title, description, role, inheritedRole, version);
return this.depositClientService.create(deposit);
}
......@@ -160,7 +163,8 @@ public class DepositITService extends ITService {
return this.createRemoteDepositWithContributorAndVersion(persistenceMode, title, description, DLCMMetadataVersion.getDefaultVersion());
}
public Deposit createRemoteDepositWithContributorAndVersion(PersistenceMode persistenceMode, String title, String description, DLCMMetadataVersion version) {
public Deposit createRemoteDepositWithContributorAndVersion(PersistenceMode persistenceMode, String title, String description,
DLCMMetadataVersion version) {
final Deposit deposit = this.createRemoteDeposit(persistenceMode, title, description, Role.MANAGER_ID, false, version);
final Person person = this.personITService.getOrCreateRemotePerson();
this.depositClientService.addContributor(deposit.getResId(), person.getResId());
......@@ -192,9 +196,8 @@ public class DepositITService extends ITService {
return deposit;
}
public Deposit createRemoteDepositWithContributorAndSubmissionApprove(PersistenceMode persistenceMode, String title,
String description) {
return this.createRemoteDepositWithContributorAndSubmissionApprove(persistenceMode, title, description, false);
public Deposit createRemoteDepositWithContributorsAndSubmissionApprove(PersistenceMode persistenceMode, String title, String description) {
return this.createRemoteDepositWithContributorsAndSubmissionApprove(persistenceMode, title, description, false);
}
public Deposit createRemoteDepositWithData(Deposit deposit) {
......@@ -213,17 +216,19 @@ public class DepositITService extends ITService {
return remoteDeposit;
}
private Deposit createRemoteDepositWithSubmissionApprove(PersistenceMode persistenceMode, String title, String description,
String role, boolean inheritedRole) {
private Deposit createRemoteDepositWithSubmissionApprove(PersistenceMode persistenceMode, String title, String description, String role,
boolean inheritedRole) {
Deposit deposit = this.createLocalDepositWithSubmissionApprove(persistenceMode, title, description, role, inheritedRole);
return this.depositClientService.create(deposit);
}
private Deposit createRemoteDepositWithContributorAndSubmissionApprove(PersistenceMode persistenceMode, String title,
String description, boolean inheritedRole) {
private Deposit createRemoteDepositWithContributorsAndSubmissionApprove(PersistenceMode persistenceMode, String title, String description,
boolean inheritedRole) {
final Deposit deposit = this.createRemoteDepositWithSubmissionApprove(persistenceMode, title, description, Role.MANAGER_ID, inheritedRole);
final Person person = this.personITService.getOrCreateRemotePerson();
this.depositClientService.addContributor(deposit.getResId(), person.getResId());
final Person person1 = this.personITService.getOrCreateRemotePerson();
this.depositClientService.addContributor(deposit.getResId(), person1.getResId());
final Person person2 = this.personITService.getOrCreateRemotePersonWithOrcid();
this.depositClientService.addContributor(deposit.getResId(), person2.getResId());
return deposit;
}
......
......@@ -35,6 +35,9 @@ import org.springframework.stereotype.Service;
import ch.unige.solidify.auth.model.ApplicationRole;
import ch.unige.solidify.auth.model.AuthApplicationRole;
import ch.unige.solidify.exception.SolidifyRuntimeException;
import ch.unige.solidify.util.StringTool;
import ch.unige.solidify.util.ValidationTool;
import ch.dlcm.model.security.User;
import ch.dlcm.model.settings.Person;
......@@ -67,9 +70,27 @@ public class PersonITService extends ITService {
}
public Person getOrCreateRemotePerson(String applicationRole) {
String firstName = DLCMTestConstants.getNameWithPermanentLabel(applicationRole + FIRST_NAME_TEST_SUFFIX);
String lastName = DLCMTestConstants.getNameWithPermanentLabel(applicationRole + LAST_NAME_TEST_SUFFIX);
return this.getOrCreateRemotePerson(firstName, lastName, null);
}
public Person getOrCreateRemotePersonWithOrcid() {
String firstName = DLCMTestConstants.getNameWithPermanentLabel("person_with_orcid" + FIRST_NAME_TEST_SUFFIX);
String lastName = DLCMTestConstants.getNameWithPermanentLabel("person_with_orcid" + LAST_NAME_TEST_SUFFIX);
return this.getOrCreateRemotePerson(firstName, lastName, DLCMTestConstants.ORCID_VALUE);
}
public Person getOrCreateRemotePerson(String firstName, String lastName, String orcid) {
final Person person = new Person();
person.setFirstName(DLCMTestConstants.getNameWithPermanentLabel(applicationRole + FIRST_NAME_TEST_SUFFIX));
person.setLastName(DLCMTestConstants.getNameWithPermanentLabel(applicationRole + LAST_NAME_TEST_SUFFIX));
person.setFirstName(firstName);
person.setLastName(lastName);
if (!StringTool.isNullOrEmpty(orcid)) {
if (!ValidationTool.isValidOrcid(orcid)) {
throw new SolidifyRuntimeException(orcid + " is not a valid ORCID");
}
person.setOrcid(orcid);
}
// Return the existing person if already created
for (final Person p : this.personClientService.findAll()) {
if (p.getFirstName().equalsIgnoreCase(person.getFirstName()) &&
......@@ -87,7 +108,19 @@ public class PersonITService extends ITService {
public void clearPeopleFixtures() {
this.personClientService.findAll().stream()
.filter(person -> person.getLastName().startsWith(DLCMTestConstants.TEMPORARY_TEST_DATA_LABEL))
.forEach(person -> this.personClientService.delete(person.getResId()));
.forEach(person -> this.delete(person.getResId()));
}
public void delete(String resId) {
this.personClientService.delete(resId);
}
public Person findOne(String resId) {
return this.personClientService.findOne(resId);
}
public Person update(String resId, Person resource) {
return this.personClientService.update(resId, resource);
}
public User getUserWithRole(ApplicationRole role) {
......
......@@ -98,6 +98,8 @@ public class DLCMConstants {
"/" + ModuleName.PRES_PLANNING + "/" + ResourceName.MODULE,
"/" + ModuleName.ARCHIVALSTORAGE + "/" + ResourceName.AIP + "/*/" + ActionName.DOWNLOAD,
"/" + ModuleName.PREINGEST + "/" + ResourceName.DEPOSIT + "/*/" + ActionName.DOWNLOAD,
"/" + ModuleName.PREINGEST + "/" + ResourceName.DEPOSIT + "/*/" + DLCMActionName.GET_ANONYMIZED_DEPOSIT_PAGE,
"/" + ModuleName.PREINGEST + "/" + ResourceName.DEPOSIT + "/*/" + DLCMActionName.DOWNLOAD_ANONYMIZED_DEPOSIT,
"/" + ModuleName.PREINGEST + "/" + ResourceName.DEPOSIT + "/*/" + ResourceName.DATAFILE + "/*/" +ActionName.DOWNLOAD,
"/" + ModuleName.INGEST + "/" + ResourceName.SIP + "/*/" + ActionName.DOWNLOAD,
"/" + ModuleName.INGEST + "/" + ResourceName.SIP + "/*/" + ResourceName.DATAFILE + "/*/" +ActionName.DOWNLOAD,
......
/*-
* %%----------------------------------------------------------------------------------------------
* DLCM Technology - DLCM Model - AnonymizedDeposit.java
* SPDX-License-Identifier: GPL-2.0-or-later
* %----------------------------------------------------------------------------------------------%
* Copyright (C) 2017 - 2025 University of Geneva
* %----------------------------------------------------------------------------------------------%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* ----------------------------------------------------------------------------------------------%%
*/
package ch.dlcm.model.preingest;
import java.time.OffsetDateTime;
import java.util.Objects;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.Entity;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.validation.constraints.NotNull;
import ch.unige.solidify.rest.ResourceNormalized;
import ch.dlcm.DLCMConstants;
import ch.dlcm.rest.ModuleName;
@Entity
public class AnonymizedDeposit extends ResourceNormalized {
@Schema(description = "The corresponding non anonymized deposit")
@NotNull
@ManyToOne
@JoinColumn(name = DLCMConstants.DB_PACKAGE_ID, referencedColumnName = DLCMConstants.DB_RES_ID)
private Deposit deposit;
@Schema(description = "The timestamp when the zip file of the anonymized deposit has been created")
private OffsetDateTime timestamp;
@Schema(description = "The checksum of the checksums of all data files")
private String aggregateChecksum;
@Schema(description = "The id of the page listing all anonymized deposits of a given deposit")
private String pageId;
public @NotNull Deposit getDeposit() {
return deposit;
}
public OffsetDateTime getTimestamp() {
return timestamp;
}
public String getAggregateChecksum() {
return aggregateChecksum;
}
public String getPageId() {
return pageId;
}
public void setDeposit(@NotNull Deposit deposit) {
this.deposit = deposit;
}
public void setTimestamp(OffsetDateTime timestamp) {
this.timestamp = timestamp;
}
public void setAggregateChecksum(String aggregateChecksum) {
this.aggregateChecksum = aggregateChecksum;
}
public void setPageId(String linkId) {
this.pageId = linkId;
}
@Override
public void init() {
// Do nothing
}
@Override
public String managedBy() {
return ModuleName.PREINGEST;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
if (!super.equals(o))
return false;
AnonymizedDeposit that = (AnonymizedDeposit) o;
return Objects.equals(deposit, that.deposit) && Objects.equals(timestamp, that.timestamp) && Objects.equals(
aggregateChecksum, that.aggregateChecksum) && Objects.equals(pageId, that.pageId);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), deposit, timestamp, aggregateChecksum, pageId);
}
}
/*-
* %%----------------------------------------------------------------------------------------------
* DLCM Technology - DLCM Model - AnonymizedDepositEntry.java
* SPDX-License-Identifier: GPL-2.0-or-later
* %----------------------------------------------------------------------------------------------%
* Copyright (C) 2017 - 2025 University of Geneva
* %----------------------------------------------------------------------------------------------%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* ----------------------------------------------------------------------------------------------%%
*/
package ch.dlcm.model.preingest;
public class AnonymizedDepositEntry {
private final String anonymizedDepositResId;
private final String timestamp;
public AnonymizedDepositEntry(String anonymizedDepositResId, String timestamp) {
this.anonymizedDepositResId = anonymizedDepositResId;
this.timestamp = timestamp;
}
public String getAnonymizedDepositResId() { return anonymizedDepositResId; }
public String getTimestamp() { return timestamp; }
}
......@@ -333,9 +333,6 @@ public class Deposit extends SearchableResourceNormalized<Deposit> implements Re
@JsonIgnore
private List<String> subjectAreas = new ArrayList<>();
@Schema(description = "The identifier of the last anonymized deposit, can be null")
private String lastAnonymizedDepositId;
@Override
public <T> boolean addItem(T t) {
......@@ -497,10 +494,6 @@ public class Deposit extends SearchableResourceNormalized<Deposit> implements Re
return this.subjectAreas;
}
public String getLastAnonymizedDepositId() {
return this.lastAnonymizedDepositId;
}
/****************************************************************/
@JsonIgnore
......@@ -1006,10 +999,6 @@ public class Deposit extends SearchableResourceNormalized<Deposit> implements Re
this.isObsoletedBy = doi;
}
public void setLastAnonymizedDepositId(String lastAnonymizedDepositId) {
this.lastAnonymizedDepositId = lastAnonymizedDepositId;
}
private boolean addAip(ArchivalInfoPackage aip) {
this.collection.add(aip.getResId());
return true;
......
......@@ -128,6 +128,7 @@ public class DLCMActionName {
public static final String DOWNLOAD_DUA = "download-dua";
public static final String DOWNLOAD_DATASET_FILE = "download-dataset-file";
public static final String DOWNLOAD_ANONYMIZED_DEPOSIT = "download-anonymized-deposit";
public static final String GET_ANONYMIZED_DEPOSIT_PAGE = "get-anonymized-deposit-page";
public static final String DELETE_DUA = "delete-dua";
public static final String DELETE_DATASET_FILE = "delete-dataset-file";
......@@ -147,7 +148,7 @@ public class DLCMActionName {
public static final String GET_ALL_APPROBATIONS = "get-all-approbations";
public static final String GET_MY_ACLS = "get-my-acls";
public static final String GET_MY_APPROBATIONS = "get-my-approbations";
public static final String GET_ANONYMIZED_DOWNLOAD_LINK = "get-anonymized-download-link";
public static final String GENERATE_ANONYMIZED_DEPOSIT_PAGE = "generate-anonymized-deposit-page";
public static final String LIST_INHERITED_ROLE = "list-inherited-role";
public static final String LIST_INHERITED_PERSON_ROLES = "list-inherited-person-roles";
......