コード例 #1
0
  //    @Override
  public List<Capture> getAllCaptures() {
    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);
    }

    List<Capture> result = Lists.newArrayList();
    for (final Annotation annotation :
        annotatorDao.getAnnotationsByUsername(userDetails.getUsername())) {
      Capture capture = new Capture();
      capture.setAnnotator_schema_version(annotation.getAnnotatorSchemaVersion());
      capture.setCreated(new Date(annotation.getCreated()));
      capture.setId(annotation.getId());
      capture.setOfflineId(annotation.getOfflineId());
      capture.setQuote(annotation.getQuote());
      capture.setRanges(annotation.getRanges());
      capture.setResearchSession(annotation.getResearchSession());
      capture.setText(annotation.getText());
      capture.setUri(annotation.getUri());
      result.add(capture);
    }
    return result;
  }