Search in sources :

Example 1 with OriginalNotFoundException

use of org.apache.metron.indexing.dao.update.OriginalNotFoundException in project metron by apache.

the class IndexDao method getPatchedDocument.

default Document getPatchedDocument(PatchRequest request, Optional<Long> timestamp) throws OriginalNotFoundException, IOException {
    Map<String, Object> latest = request.getSource();
    if (latest == null) {
        Document latestDoc = getLatest(request.getGuid(), request.getSensorType());
        if (latestDoc != null && latestDoc.getDocument() != null) {
            latest = latestDoc.getDocument();
        } else {
            throw new OriginalNotFoundException("Unable to patch an document that doesn't exist and isn't specified.");
        }
    }
    Map<String, Object> updated = JSONUtils.INSTANCE.applyPatch(request.getPatch(), latest);
    return new Document(updated, request.getGuid(), request.getSensorType(), timestamp.orElse(System.currentTimeMillis()));
}
Also used : OriginalNotFoundException(org.apache.metron.indexing.dao.update.OriginalNotFoundException) Document(org.apache.metron.indexing.dao.update.Document)

Aggregations

Document (org.apache.metron.indexing.dao.update.Document)1 OriginalNotFoundException (org.apache.metron.indexing.dao.update.OriginalNotFoundException)1