@Override public Result update(DocumentUpdate update, DocumentProtocol.Priority pri) { long req = getNextRequestId(); if (syncSession.update(update, pri)) { addResponse(new UpdateResponse(req, true)); } else { addResponse(new DocumentUpdateResponse(req, update, "Document not found.", false)); } return new Result(req); }
@Override public void update(RestUri restUri, VespaXMLFeedReader.Operation data, Optional<String> route) throws RestApiException { SyncSession syncSession = syncSessions.alloc(); Response response; try { Instant startTime = Instant.now(); setRoute(syncSession, route); syncSession.update(data.getDocumentUpdate()); metricsHelper.reportSuccessful(DocumentOperationType.UPDATE, startTime); return; } catch (DocumentAccessException documentException) { response = createErrorResponse(documentException, restUri); } catch (Exception e) { response = Response.createErrorResponse(500, ExceptionUtils.getStackTrace(e), restUri, RestUri.apiErrorCodes.INTERNAL_EXCEPTION); } finally { syncSessions.free(syncSession); } metricsHelper.reportFailure(DocumentOperationType.UPDATE, DocumentOperationStatus.fromHttpStatusCode(response.getStatus())); throw new RestApiException(response); }