@GET
 @Path("/{triggerId}/conditions/{conditionId}")
 @Produces(APPLICATION_JSON)
 @ApiOperation(value = "@Deprecated : Use GET /alerts/triggers/{triggerId}/conditions")
 @ApiResponses(
     value = {
       @ApiResponse(code = 200, message = "Success, Condition found"),
       @ApiResponse(code = 404, message = "No Condition found"),
       @ApiResponse(code = 500, message = "Internal server error")
     })
 @Deprecated
 public Response getTriggerCondition(
     @ApiParam(value = "Trigger definition id to be retrieved", required = true)
         @PathParam("triggerId")
         final String triggerId,
     @PathParam("conditionId") final String conditionId) {
   try {
     Trigger trigger = definitions.getTrigger(tenantId, triggerId);
     if (trigger == null) {
       return ResponseUtil.notFound("No trigger found for triggerId: " + triggerId);
     }
     Condition found = definitions.getCondition(tenantId, conditionId);
     if (found == null) {
       return ResponseUtil.notFound("No condition found for conditionId: " + conditionId);
     }
     if (!found.getTriggerId().equals(triggerId)) {
       return ResponseUtil.notFound(
           "ConditionId: " + conditionId + " does not belong to triggerId: " + triggerId);
     }
     return ResponseUtil.ok(found);
   } catch (Exception e) {
     log.debug(e.getMessage(), e);
     return ResponseUtil.internalError(e.getMessage());
   }
 }
  @PUT
  @Path("/{triggerId}/conditions/{conditionId}")
  @Produces(APPLICATION_JSON)
  @ApiOperation(
      value =
          "Deprecated : Use PUT /alerts/triggers/{triggerId}/conditions to set the entire "
              + "condition set in one service.")
  @ApiResponses(
      value = {
        @ApiResponse(code = 200, message = "Success, Condition updated"),
        @ApiResponse(code = 404, message = "No Condition found"),
        @ApiResponse(code = 500, message = "Internal server error"),
        @ApiResponse(code = 400, message = "Bad Request/Invalid Parameters")
      })
  @Deprecated
  public Response updateCondition(
      @ApiParam(value = "Trigger definition id to be retrieved", required = true)
          @PathParam("triggerId")
          final String triggerId,
      @PathParam("conditionId") final String conditionId,
      @ApiParam(value = "Json representation of a condition") String jsonCondition) {
    try {
      Trigger trigger = definitions.getTrigger(tenantId, triggerId);
      if (trigger == null) {
        return ResponseUtil.notFound("No trigger found for triggerId: " + triggerId);
      }
      if (isEmpty(jsonCondition) || !jsonCondition.contains("type")) {
        return ResponseUtil.badRequest("json condition empty or without type");
      }

      ObjectMapper om = new ObjectMapper();
      JsonNode rootNode = om.readTree(jsonCondition);
      Condition condition = JacksonDeserializer.deserializeCondition(rootNode);
      if (condition == null) {
        return ResponseUtil.badRequest("Bad json condition");
      }
      condition.setTriggerId(triggerId);
      boolean exists = false;
      if (conditionId.equals(condition.getConditionId())) {
        exists = (definitions.getCondition(tenantId, condition.getConditionId()) != null);
      }
      if (!exists) {
        return ResponseUtil.notFound("Condition not found for conditionId: " + conditionId);
      } else {
        Collection<Condition> conditions = definitions.updateCondition(tenantId, condition);
        if (log.isDebugEnabled()) {
          log.debug("Conditions: " + conditions);
        }
        return ResponseUtil.ok(conditions);
      }
    } catch (Exception e) {
      log.debug(e.getMessage(), e);
      return ResponseUtil.internalError(e.getMessage());
    }
  }
 @DELETE
 @Path("/{triggerId}/conditions/{conditionId}")
 @Produces(APPLICATION_JSON)
 @ApiOperation(
     value =
         "Deprecated : Use PUT /alerts/triggers/{triggerId}/conditions to set the entire "
             + "condition set in one service.")
 @ApiResponses(
     value = {
       @ApiResponse(code = 200, message = "Success, Condition deleted"),
       @ApiResponse(code = 404, message = "No Condition found"),
       @ApiResponse(code = 500, message = "Internal server error"),
       @ApiResponse(code = 400, message = "Bad Request/Invalid Parameters")
     })
 @Deprecated
 public Response deleteCondition(
     @ApiParam(value = "Trigger definition id to be retrieved", required = true)
         @PathParam("triggerId")
         final String triggerId,
     @PathParam("conditionId") final String conditionId) {
   try {
     Trigger trigger = definitions.getTrigger(tenantId, triggerId);
     if (trigger == null) {
       return ResponseUtil.notFound("No trigger found for triggerId: " + triggerId);
     }
     Condition condition = definitions.getCondition(tenantId, conditionId);
     if (condition == null) {
       return ResponseUtil.notFound("No condition found for conditionId: " + conditionId);
     }
     if (!condition.getTriggerId().equals(triggerId)) {
       return ResponseUtil.badRequest(
           "ConditionId: " + conditionId + " does not belong to triggerId: " + triggerId);
     }
     Collection<Condition> conditions = definitions.removeCondition(tenantId, conditionId);
     if (log.isDebugEnabled()) {
       log.debug("Conditions: " + conditions);
     }
     return ResponseUtil.ok(conditions);
   } catch (Exception e) {
     log.debug(e.getMessage(), e);
     return ResponseUtil.internalError(e.getMessage());
   }
 }