@POST
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    @Path("/annotations")
    @Description("Submits externally collected annotation data.")
    public Map<String, Object> submitAnnotations(@Context HttpServletRequest req, final List<AnnotationDto> annotationDtos) {
        PrincipalUser remoteUser = getRemoteUser(req);

        SystemAssert.requireArgument(annotationDtos != null, "Cannot submit null annotations list.");

        List<Annotation> legalAnnotations = new ArrayList<>();
        List<AnnotationDto> illegalAnnotations = new ArrayList<>();
        List<String> errorMessages = new ArrayList<>();

        for (AnnotationDto annotationDto : annotationDtos) {
            try {
                Annotation annotation = new Annotation(annotationDto.getSource(), annotationDto.getId(), annotationDto.getType(),
                    annotationDto.getScope(), annotationDto.getMetric(), annotationDto.getTimestamp());

                copyProperties(annotation, annotationDto);
                legalAnnotations.add(annotation);
            } catch (Exception e) {
                illegalAnnotations.add(annotationDto);
                errorMessages.add(e.getMessage());
            }
        }
        _collectionService.submitAnnotations(remoteUser, legalAnnotations);

        Map<String, Object> result = new HashMap<>();

        result.put("Success", legalAnnotations.size() + " annotations");
        result.put("Error", illegalAnnotations.size() + " annotations");
        result.put("Error Messages", errorMessages);
        return result;
    }
@ POST @ Consumes ( MediaType . APPLICATION_JSON ) @ Produces ( MediaType . APPLICATION_JSON ) @ Path ( "/annotations" ) @ Description ( "Submits externally collected annotation data." ) public Map < String , Object > submitAnnotations ( @ Context HttpServletRequest req , final List < AnnotationDto > annotationDtos ) { PrincipalUser remoteUser = getRemoteUser ( req ) ; SystemAssert . requireArgument ( annotationDtos != null , "Cannot submit null annotations list." ) ; List < Annotation > legalAnnotations = new ArrayList < > ( ) ; List < AnnotationDto > illegalAnnotations = new ArrayList < > ( ) ; List < String > errorMessages = new ArrayList < > ( ) ; for ( AnnotationDto annotationDto : annotationDtos ) { try { Annotation annotation = new Annotation ( annotationDto . getSource ( ) , annotationDto . getId ( ) , annotationDto . getType ( ) , annotationDto . getScope ( ) , annotationDto . getMetric ( ) , annotationDto . getTimestamp ( ) ) ; copyProperties ( annotation , annotationDto ) ; legalAnnotations . add ( annotation ) ; } catch ( Exception e ) { illegalAnnotations . add ( annotationDto ) ; errorMessages . add ( e . getMessage ( ) ) ; } } _collectionService . submitAnnotations ( remoteUser , legalAnnotations ) ; Map < String , Object > result = new HashMap < > ( ) ; result . put ( "Success" , legalAnnotations . size ( ) + " annotations" ) ; result . put ( "Error" , illegalAnnotations . size ( ) + " annotations" ) ; result . put ( "Error Messages" , errorMessages ) ; return result ; }
Submits externally collected annotation data.

@param   req             The HTTP request.
@param   annotationDtos  The annotation DTOs to submit.

@return  The number of annotations that were submitted, and the number of errors encountered.