Пример #1
0
 @GET("/backend/config/alerts/([0-9a-f]{40})")
 String getAlert(String version) throws JsonProcessingException {
   AlertConfig alertConfig = configRepository.getAlertConfig(version);
   if (alertConfig == null) {
     throw new JsonServiceException(HttpResponseStatus.NOT_FOUND);
   }
   return mapper.writeValueAsString(AlertConfigDto.fromConfig(alertConfig));
 }
Пример #2
0
 @POST("/backend/config/alerts/update")
 String updateAlert(String content) throws IOException {
   AlertConfigDto alertConfigDto = mapper.readValue(content, ImmutableAlertConfigDto.class);
   AlertConfig alertConfig = alertConfigDto.toConfig();
   String version = alertConfigDto.version();
   checkNotNull(version, "Missing required request property: version");
   configRepository.updateAlertConfig(alertConfig, version);
   return mapper.writeValueAsString(AlertConfigDto.fromConfig(alertConfig));
 }
Пример #3
0
 @GET("/backend/config/alerts")
 String getAlertList() throws JsonProcessingException {
   List<AlertConfigDto> alertConfigDtos = Lists.newArrayList();
   List<AlertConfig> alertConfigs = configRepository.getAlertConfigs();
   alertConfigs = orderingByName.immutableSortedCopy(alertConfigs);
   for (AlertConfig alertConfig : alertConfigs) {
     alertConfigDtos.add(AlertConfigDto.fromConfig(alertConfig));
   }
   return mapper.writeValueAsString(alertConfigDtos);
 }
Пример #4
0
 @POST("/backend/config/alerts/add")
 String addAlert(String content) throws Exception {
   AlertConfigDto alertConfigDto = mapper.readValue(content, ImmutableAlertConfigDto.class);
   AlertConfig alertConfig = alertConfigDto.toConfig();
   try {
     configRepository.insertAlertConfig(alertConfig);
   } catch (DuplicateMBeanObjectNameException e) {
     // log exception at debug level
     logger.debug(e.getMessage(), e);
     throw new JsonServiceException(CONFLICT, "mbeanObjectName");
   }
   return mapper.writeValueAsString(AlertConfigDto.fromConfig(alertConfig));
 }
Пример #5
0
 @POST("/backend/config/alerts/remove")
 void removeAlert(String content) throws IOException {
   String version = mapper.readValue(content, String.class);
   checkNotNull(version);
   configRepository.deleteAlertConfig(version);
 }