purge/triplestore: Better handle deleteing

This commit is contained in:
Tom Wiesing 2022-11-12 19:45:29 +01:00
parent cf835135a8
commit c22fd01ed5
No known key found for this signature in database
2 changed files with 13 additions and 6 deletions

View file

@ -99,25 +99,27 @@ func (ts Triplestore) Wait() error {
}, ts.PollContext, ts.PollInterval)
}
// TriplestorePurgeUser deletes the specified user from the triplestore
// PurgeUser deletes the specified user from the triplestore.
// When the user does not exist, returns no error.
func (ts Triplestore) PurgeUser(user string) error {
res, err := ts.OpenRaw("DELETE", "/rest/security/users/"+user, nil, "", "")
if err != nil {
return err
}
if res.StatusCode != http.StatusNoContent {
if res.StatusCode != http.StatusNoContent && res.StatusCode != http.StatusNotFound {
return errors.Errorf("Delete returned code %d", res.StatusCode)
}
return nil
}
// TriplestorePurgeRepo deletes the specified repo from the triplestore
// PurgeRepo deletes the specified repo from the triplestore.
// When the repo does not exist, returns no error.
func (ts Triplestore) PurgeRepo(repo string) error {
res, err := ts.OpenRaw("DELETE", "/rest/repositories/"+repo, nil, "", "")
if err != nil {
return err
}
if res.StatusCode != http.StatusOK {
if res.StatusCode != http.StatusOK && res.StatusCode != http.StatusNotFound {
return errors.Errorf("Delete returned code %d", res.StatusCode)
}
return nil