-
Notifications
You must be signed in to change notification settings - Fork 18
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
feat(api-v2): Erase a resource #1429
Conversation
Have you included https://en.wikipedia.org/wiki/Eraser_(film) in the docs? :-) |
@tobiasschweizer Sorry, I only include references to films I've seen. :) |
What happens if the resource (e..g, a |
Currently Knora never deletes files from Sipi, and I think this is still the safest policy, because of use cases like #1078. |
(from Sipi's permanent storage I mean) |
@@ -956,6 +956,38 @@ class ResourcesRouteV2E2ESpec extends E2ESpec(ResourcesRouteV2E2ESpec.config) { | |||
) | |||
} | |||
} | |||
|
|||
"erase a resource" in { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test attempting to erase a resource that is referred to to make sure the request is rejected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a test for that in ResourcesResponderV2Spec
:
https://github.com/dhlab-basel/Knora/pull/1429/files#diff-b1ef5075da04ef708a48de2a6b007436R2062
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. Sorry, I missed this one.
* @param ignoreKnoraConstraints if true, knora-base:subjectClassConstraint and knora-base:objectClassConstraint will be ignored. | ||
* This is necessary when modifying the cardinalities of a class. | ||
* @param ignoreRdfSubjectAndObject if true, rdf:subject and rdf:object will be ignored. This is necessary when checking |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this ignores reifications (link values) referring to the IRI of the resource to be deleted if set to true?
Wouldn't this mean that a resource is referenced and hence cannot be deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect that the IRI can be used as an rdf:subject (outgoing link) but not as an rdf:object (incoming link) (https://docs.knora.org/paradox/02-knora-ontologies/knora-base.html#linkvalue).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suppose we want to erase resource A
, and resource B
has a link value that points to A
, and the link value is marked as deleted. The link value will still contain an rdf:object
pointing to A
. It's OK to ignore it, because B
no longer refers to A
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the link value would have an rdf:object
with the IRI of A
that does not occur anymore as a subject in the triplestore, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the link value would have an
rdf:object
with the IRI ofA
that does not occur anymore as a subject in the triplestore, right?
That's correct. This wouldn't be a problem for Knora or for the GraphDB consistency checking. @lrosenth are you saying that these (marked-as-deleted) references would need to be erased for legal reasons?
Since this is a killer feature in the proper sense, I would like to discuss this together with @benjamingeer and @lrosenth. |
We could always create placeholder resources for deleted resources with incoming links. |
The use case that @lrosenth had in mind is that he's creating a new project by doing an import, and he wants to remove some incorrect resources and import them again. |
I know, but what if project A creates a resource and project B links to it. So now project A wants to delete the resource. Are we not going to allow this? The data belongs to project A and they should be able to do what they want IMHO. |
Currently project A can mark the resource as deleted, but they can't erase it. I guess in this case, if they want to erase it, it would make sense to replace it with a dummy resource. @lrosenth ? |
Although the problem would be that the placeholder resource would have to be of the correct class, which could have required cardinalities for links to other resources. So we could end up having to create a whole graph of dummy resources just to erase one resource. This is the same problem as the bulk import problem. |
Since erasing resources in production is supposed to be something very rare, and can only be done by a sysadmin or project admin, maybe it would be best to leave it up to the admin to decide how to deal with this scenario. If they want to create a graph of dummy resources and change existing links first before erasing, they could do that via the API. |
OK – I would suggest the following rules:
Case (3) is not as urgent as (1) and (2) Erasing a resource is always a "last resort action" that needs admin privileges |
We have a use case, #1078, where the same Sipi files could be reused in different resources: "Use case: bulk import has been done, and needs to be redone because data has changed, but images have not changed." That seems similar to your use case here. Then you would want to keep the Sipi files, right? Also, when you mark a resource or value as deleted, Knora doesn't remove its Sipi files. Should it?
That seems feasible. |
Once a resource with an attached file value gets erased/deleted, will the file in Sipi then be unaccessible because no permissions will be granted for an erased/deleted resource? In other words, the file would still be in Sipi, but it would never be served. |
It would never be served, but it could be used again to create another resource or value, which is the use case in #1078:
|
Which permissions would be required to use an existing file? If the original resource was erased, the original permissions cannot be determined. I am thinking of a copyright protected information that required the erasure of a resource. |
To reuse an existing file, you'd have to move it to Sipi's If you don't want to reuse the file, you can delete it from Sipi's storage using |
So this would require write access to Sipi's file system. I think that's fine since you would need admin privileges to use the functionality added with this PR. |
This PR looks fine to me. I leave the final approval to @lrosenth |
Thanks. I'm currently writing the code to erase marked-as-deleted link values. |
You are the Eraser ... |
@lrosenth Is this OK now? It erases deleted link values pointing to the resource that's being erased. For the reasons explained above, it doesn't touch files in Sipi. Does that seem reasonable to you? |
Seems very reasonable to me! Maybe at some point we need a "Purge" algorithm whoiich detect unreferenced SIPI files and allows the to be deleted... But that's not urgent! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot!
Thanks for the review! |
This PR introduces a route
/v2/resources/erase
, for erasing a resource from the triplestore.ResourcesResponderV2
.ResourcesResponderV2Spec
.ResourcesRouteV2E2ESpec
.Resolves #1421.