(data, patchObject, contentType, uri)
| 718 | } |
| 719 | |
| 720 | async applyPatch (data, patchObject, contentType, uri) { |
| 721 | const baseGraph = $rdf.graph() |
| 722 | let patchedGraph |
| 723 | |
| 724 | try { |
| 725 | $rdf.parse(data, baseGraph, uri, contentType) |
| 726 | } catch (err) { |
| 727 | throw error(500, 'Cannot parse file for patching: ' + uri) |
| 728 | } |
| 729 | |
| 730 | // Apply patches |
| 731 | if (patchObject.updates) { |
| 732 | patchedGraph = await this.applyPatchUpdate(baseGraph, patchObject.updates, uri, contentType) |
| 733 | } else if (patchObject.deletes || patchObject.inserts) { |
| 734 | patchedGraph = await this.applyPatchInsertDelete(baseGraph, patchObject, uri, contentType) |
| 735 | } else { |
| 736 | throw error(422, 'Invalid patch object') |
| 737 | } |
| 738 | |
| 739 | try { |
| 740 | return await serialize(patchedGraph, uri, contentType) |
| 741 | } catch (err) { |
| 742 | throw error(500, 'Cannot serialize patched file: ' + uri) |
| 743 | } |
| 744 | } |
| 745 | |
| 746 | async applyPatchUpdate (baseGraph, updates, uri, contentType) { |
| 747 | const patchedGraph = baseGraph |
no test coverage detected