@DELETE
 @Path("/{eventId}")
 @ApiOperation(value = "Delete an existing Event.")
 @ApiResponses(
     value = {
       @ApiResponse(code = 200, message = "Success, Event deleted."),
       @ApiResponse(code = 500, message = "Internal server error.", response = ApiError.class),
       @ApiResponse(code = 404, message = "Event not found.", response = ApiError.class)
     })
 public Response deleteEvent(
     @ApiParam(required = true, value = "Event id to be deleted.") @PathParam("eventId")
         final String eventId) {
   try {
     EventsCriteria criteria = new EventsCriteria();
     criteria.setEventId(eventId);
     int numDeleted = alertsService.deleteEvents(tenantId, criteria);
     if (1 == numDeleted) {
       if (log.isDebugEnabled()) {
         log.debug("EventId: " + eventId);
       }
       return ResponseUtil.ok();
     } else {
       return ResponseUtil.notFound("Event " + eventId + " doesn't exist for delete");
     }
   } catch (Exception e) {
     log.debug(e.getMessage(), e);
     return ResponseUtil.internalError(e);
   }
 }
 @PUT
 @Path("/tags")
 @Consumes(APPLICATION_JSON)
 @ApiOperation(value = "Add tags to existing Events.")
 @ApiResponses(
     value = {
       @ApiResponse(code = 200, message = "Success, Events tagged successfully."),
       @ApiResponse(code = 500, message = "Internal server error.", response = ApiError.class),
       @ApiResponse(
           code = 400,
           message = "Bad Request/Invalid Parameters.",
           response = ApiError.class)
     })
 public Response addTags(
     @ApiParam(required = true, value = "Comma separated list of eventIds to tag.")
         @QueryParam("eventIds")
         final String eventIds,
     @ApiParam(
             required = true,
             value = "Comma separated list of tags to add, " + "each tag of format 'name|value'.")
         @QueryParam("tags")
         final String tags) {
   try {
     if (!isEmpty(eventIds) || isEmpty(tags)) {
       // criteria just used for convenient type translation
       EventsCriteria c = buildCriteria(null, null, eventIds, null, null, tags, false);
       alertsService.addEventTags(tenantId, c.getEventIds(), c.getTags());
       if (log.isDebugEnabled()) {
         log.debugf("Tagged alertIds:%s, %s", c.getEventIds(), c.getTags());
       }
       return ResponseUtil.ok();
     } else {
       return ResponseUtil.badRequest("EventIds and Tags required for adding tags");
     }
   } catch (Exception e) {
     log.debug(e.getMessage(), e);
     if (e.getCause() != null && e.getCause() instanceof IllegalArgumentException) {
       return ResponseUtil.badRequest("Bad arguments: " + e.getMessage());
     }
     return ResponseUtil.internalError(e);
   }
 }
  private EventsCriteria buildCriteria(
      Long startTime,
      Long endTime,
      String eventIds,
      String triggerIds,
      String categories,
      String tags,
      Boolean thin) {
    EventsCriteria criteria = new EventsCriteria();
    criteria.setStartTime(startTime);
    criteria.setEndTime(endTime);
    if (!isEmpty(eventIds)) {
      criteria.setEventIds(Arrays.asList(eventIds.split(",")));
    }
    if (!isEmpty(triggerIds)) {
      criteria.setTriggerIds(Arrays.asList(triggerIds.split(",")));
    }
    if (!isEmpty(categories)) {
      criteria.setCategories(Arrays.asList(categories.split(",")));
    }
    if (!isEmpty(tags)) {
      String[] tagTokens = tags.split(",");
      Map<String, String> tagsMap = new HashMap<>(tagTokens.length);
      for (String tagToken : tagTokens) {
        String[] fields = tagToken.split("\\|");
        if (fields.length == 2) {
          tagsMap.put(fields[0], fields[1]);
        } else {
          if (log.isDebugEnabled()) {
            log.debug("Invalid Tag Criteria " + Arrays.toString(fields));
          }
        }
      }
      criteria.setTags(tagsMap);
    }
    if (null != thin) {
      criteria.setThin(thin.booleanValue());
    }

    return criteria;
  }