Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester {
= DSpaceServicesFactory.getInstance().getConfigurationService();


protected AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
protected final AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();


/**
Expand Down Expand Up @@ -774,7 +774,14 @@ protected void addBitstreams(Context context, Item item,
manifest.crosswalkBitstream(context, params, bitstream, mfileID,
mdRefCallback);

authorizeService.addPolicies(context, bitstreamPolicies, bitstream);
// Only add the saved TYPE_SUBMISSION policies if the crosswalk actually removed them to prevent duplicates.
if (!bitstreamPolicies.isEmpty()) {
List<ResourcePolicy> remainingSubmissionPolicies =
authorizeService.findPoliciesByDSOAndType(context, bitstream, ResourcePolicy.TYPE_SUBMISSION);
if (remainingSubmissionPolicies.isEmpty()) {
authorizeService.addPolicies(context, bitstreamPolicies, bitstream);
}
}

// is this the primary bitstream?
if (primaryID != null && mfileID.equals(primaryID)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ public void testURLRedirectCurateTest() throws Exception {
// MetadataValueLinkChecker uri field with regular link
.withMetadata("dc", "description", null, "https://google.com")
// MetadataValueLinkChecker uri field with redirect link
.withMetadata("dc", "description", "uri", "https://demo7.dspace.org/handle/123456789/1")
.withMetadata("dc", "description", "uri", "http://google.com")
// MetadataValueLinkChecker uri field with non resolving link
.withMetadata("dc", "description", "uri", "https://www.atmire.com/broken-link")
.withSubject("ExtraEntry")
Expand All @@ -690,8 +690,8 @@ public void testURLRedirectCurateTest() throws Exception {

// field that should be ignored
assertFalse(checkIfInfoTextLoggedByHandler(handler, "demo.dspace.org/home"));
// redirect links in field that should not be ignored (https) => expect OK
assertTrue(checkIfInfoTextLoggedByHandler(handler, "https://demo7.dspace.org/handle/123456789/1 = 200 - OK"));
// redirect links in field that should not be ignored => expect OK (even though curl responds with 301)
assertTrue(checkIfInfoTextLoggedByHandler(handler, "http://google.com = 200 - OK"));
// regular link in field that should not be ignored (http) => expect OK
assertTrue(checkIfInfoTextLoggedByHandler(handler, "https://google.com = 200 - OK"));
// nonexistent link in field that should not be ignored => expect 404
Expand Down
Loading