Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

internal/epic-pid-service-never-called #431

Merged
merged 12 commits into from
Sep 12, 2023
Prev Previous commit
Next Next commit
Fixed failing IT. It was needed to update configuraition property.
  • Loading branch information
milanmajchrak committed Sep 7, 2023
commit e0f52f06706961b29ab448907bbdc3cad7933f99
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@
import org.dspace.content.service.CollectionService;
import org.dspace.content.service.ItemService;
import org.dspace.handle.Handle;
import org.dspace.handle.PIDConfiguration;
import org.dspace.handle.service.HandleClarinService;
import org.dspace.handle.service.HandleService;
import org.dspace.services.ConfigurationService;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -80,6 +82,9 @@ public class HandleRestRepositoryIT extends AbstractControllerIntegrationTest {

@Autowired
private HandleService handleService;

@Autowired
private ConfigurationService configurationService;
@Before
public void setup() {
context.turnOffAuthorisationSystem();
Expand All @@ -90,6 +95,20 @@ public void setup() {

col = CollectionBuilder.createCollection(context, parentCommunity).withName("Collection").build();

// Set property in the cfg
String allCommunityHandleDef = "community=*, prefix=123456789, " +
"type=local, canonical_prefix=http://hdl.handle.net/, subprefix=2";
String specificCommunityHandleDef = "community=09f09b11-cba1-4c43-9e01-29fe919991ab, prefix=123456789, " +
"type=local, canonical_prefix=http://hdl.handle.net/, subprefix=2";
ArrayList<String> configArrayCommunityConfig = new ArrayList<>(2);
configArrayCommunityConfig.add(allCommunityHandleDef);
configArrayCommunityConfig.add(specificCommunityHandleDef);
configurationService.setProperty("lr.pid.community.configurations", configArrayCommunityConfig);

// Reload the set property in the hash map.
PIDConfiguration pidConfiguration = PIDConfiguration.getInstance();
pidConfiguration.reloadPidCommunityConfigurations();

// 2. Create item and add it to the collection
publicItem = ItemBuilder.createItem(context, col)
.withAuthor(AUTHOR)
Expand Down Expand Up @@ -492,6 +511,16 @@ public void patchSetPrefixWithoutArchive() throws Exception {
context.turnOffAuthorisationSystem();
Community community = CommunityBuilder.createCommunity(context).build();
Collection col2 = CollectionBuilder.createCollection(context, community).build();

// Set property in the cfg
String specificCommunityHandleDef = "community=" + community.getID() + ",prefix=987654321," +
"type=local,canonical_prefix=http://hdl.handle.net/";
configurationService.setProperty("lr.pid.community.configurations", specificCommunityHandleDef);

// Reload the set property in the hash map.
PIDConfiguration pidConfiguration = PIDConfiguration.getInstance();
pidConfiguration.reloadPidCommunityConfigurations();

Item newItem = ItemBuilder.createItem(context, col2)
.withAuthor(AUTHOR)
.build();
Expand Down Expand Up @@ -558,6 +587,14 @@ public void patchSetPrefixWithArchive() throws Exception {
context.turnOffAuthorisationSystem();
Community community = CommunityBuilder.createCommunity(context).build();
Collection col2 = CollectionBuilder.createCollection(context, community).build();
// Set property in the cfg
String specificCommunityHandleDef = "community=" + community.getID() + ",prefix=987654321," +
"type=local,canonical_prefix=http://hdl.handle.net/";
configurationService.setProperty("lr.pid.community.configurations", specificCommunityHandleDef);

// Reload the set property in the hash map.
PIDConfiguration pidConfiguration = PIDConfiguration.getInstance();
pidConfiguration.reloadPidCommunityConfigurations();
Item newItem = ItemBuilder.createItem(context, col2)
.withAuthor(AUTHOR)
.build();
Expand Down