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

Ensure DiSCO deletions are handled correctly by indexer #176

Open
karenhanson opened this issue Dec 22, 2017 · 4 comments
Open

Ensure DiSCO deletions are handled correctly by indexer #176

karenhanson opened this issue Dec 22, 2017 · 4 comments

Comments

@karenhanson
Copy link
Contributor

Deletion and tombstone Events against a DiSCO only affect the target DiSCO version. Other versions in the lineage maintain their current status. DiscosSolrOperations.deleteDocumentsForLineage(String lineageUri) appears to delete all DiSCOs in a lineage when a DiSCO deletion occurs, To match RMap's behavior, it should only act on the DiSCO version that is the target of the deletion or tombstone Event. Here is an example to illustrate how statuses can change within a lineage:

//create discoV1
discoV1 (active)
//update discoV1
discoV1 (inactive)
discoV2 (active)
//update discoV2
discoV1 (inactive)
discoV2 (inactive)
discoV3 (active)
//update discoV2 
Cant update, the most recent version is discoV3
//tombstone discoV2
discoV1 (inactive)
discoV2 (tombstoned - but content in triplestore)
discoV3 (active)
//hard delete discoV3
discoV1 (inactive)
discoV2 (tombstoned - but content in triplestore)
discoV3 (deleted - content not in triplestore)
@karenhanson karenhanson changed the title Ensure deletions are handled appropriately by indexer Ensure DiSCO deletions are handled correctly by indexer Dec 22, 2017
emetsger added a commit to emetsger/rmap that referenced this issue Jan 10, 2018
emetsger added a commit to emetsger/rmap that referenced this issue Jan 10, 2018
karenhanson pushed a commit that referenced this issue Jan 10, 2018
* Indexer now removes documents in the index that pertain _only_ to the tombstoned DiSCO (the indexer used to remove the entire lineage)

* Includes an IT based on the information in #176.
@emetsger
Copy link
Contributor

@karenhanson can this be closed?

IIRC, there is no support for "hard deletes" anywhere in RMap, so at the moment the indexer doesn't need to support them. If hard delete support needs to be tracked, maybe we can add an issue for that separately?

@emetsger
Copy link
Contributor

Ah @karenhanson I see hard-delete is a function of the admin tool. Let me see if I can easily update the indexer to accommodate.

@emetsger
Copy link
Contributor

@karenhanson ok, it looks like the code should accommodate hard-deletes: the indexer treats them the same as tombstones (the documents for the deleted disco are removed from the index).

What is missing is an integration test for hard-delete.

Is there a way I can simulate a hard-delete using the API or UI in an integration test?

@karenhanson
Copy link
Contributor Author

karenhanson commented Jan 12, 2018

@emetsger This test simulates delete:

@Test(expected=RMapDeletedObjectException.class)
public void testDeleteDiSCOConfirmPost() throws Exception {
ORMapDiSCO disco = getRMapDiSCOObj(TestFile.DISCOB_V1_XML);
String discoUri = disco.getId().toString();
assertNotNull(discoUri);
rmapService.createDiSCO(disco, reqEventDetails);
//create mock form using new discoUri
DeleteDiSCOForm discoDelete = new DeleteDiSCOForm();
discoDelete.setDiscoUri(discoUri); //valid uri
mockMvc.perform(post("/admin/disco/deleteconfirm").sessionAttr(Constants.ADMIN_LOGGEDIN_SESSATTRIB, true).flashAttr("deleteDiSCO", discoDelete))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("/admin/disco/deleted"))
.andExpect(flash().attributeExists("eventId"))
.andExpect(flash().attributeExists("deleteDiSCO"));
//confirm delete, should throw expected exception
rmapService.readDiSCO(new URI(discoUri));
}

This is the method that actually does the deletion work - it creates an Admin Agent in RMap if one doesn't already exist and then uses that Agent to delete the DiSCO:
@Override
public RMapEvent deleteDiSCOByAdmin(URI discoUri, String description) {
prepareRMapAdministratorAgent();
RequestEventDetails requestEventDetails = new RequestEventDetails(rmapAuthService.getAdministratorAgentUri());
requestEventDetails.setDescription(description);
return rmapService.deleteDiSCO(discoUri, requestEventDetails);
}

The description provided goes into RMapEvent.description

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants