// @Override public Capture saveCapture(final String sessionId, final Capture capture) { UserDetails userDetails = JarvisContextHolder.getContext().getUserDetails(); if (userDetails == null) { ResponseBuilderImpl builder = new ResponseBuilderImpl(); builder.status(Response.Status.UNAUTHORIZED); Response response = builder.build(); throw new WebApplicationException(response); } Annotation annotation = new Annotation(); annotation.setAuthor(userDetails.getUsername()); annotation.setAnnotatorSchemaVersion(capture.getAnnotator_schema_version()); annotation.setCreated(new Date().getTime()); annotation.setOfflineId(capture.getOfflineId()); annotation.setQuote(capture.getQuote()); annotation.setRanges(capture.getRanges()); annotation.setResearchSession(capture.getResearchSession()); annotation.setText(capture.getText()); annotation.setUri(capture.getUri()); annotatorDao.insertAnnotation(annotation); capture.setId(annotation.getId()); capture.setCreated(new Date(annotation.getCreated())); return capture; }
// @Override public Capture updateCapture( final String sessionId, final String captureId, final Capture capture) { if (captureId != null) { Annotation annotation = annotatorDao.getAnnotationById(Long.valueOf(captureId)); annotation.setText(capture.getText()); annotatorDao.updateAnnotation(annotation); } return capture; }