diff --git a/server/common/admin-rest-client/src/main/java/org/kaaproject/kaa/server/common/admin/AdminClient.java b/server/common/admin-rest-client/src/main/java/org/kaaproject/kaa/server/common/admin/AdminClient.java index 4ee09d23b4..1089616a03 100644 --- a/server/common/admin-rest-client/src/main/java/org/kaaproject/kaa/server/common/admin/AdminClient.java +++ b/server/common/admin-rest-client/src/main/java/org/kaaproject/kaa/server/common/admin/AdminClient.java @@ -252,13 +252,11 @@ public ServerProfileSchemaDto saveServerProfileSchema(ServerProfileSchemaDto ser } public NotificationSchemaDto createNotificationSchema(NotificationSchemaDto notificationSchema) throws Exception { - MultiValueMap params = new LinkedMultiValueMap<>(); - params.add("notificationSchema", notificationSchema); - return restTemplate.postForObject(restTemplate.getUrl() + "createNotificationSchema", params, NotificationSchemaDto.class); + return restTemplate.postForObject(restTemplate.getUrl() + "createNotificationSchema", notificationSchema, NotificationSchemaDto.class); } - public NotificationSchemaDto editNotificationSchema(NotificationSchemaDto notificationSchema) throws Exception { - return restTemplate.postForObject(restTemplate.getUrl() + "editNotificationSchema", notificationSchema, NotificationSchemaDto.class); + public NotificationSchemaDto saveNotificationSchema(NotificationSchemaDto notificationSchema) throws Exception { + return restTemplate.postForObject(restTemplate.getUrl() + "saveNotificationSchema", notificationSchema, NotificationSchemaDto.class); } public LogSchemaDto createLogSchema(LogSchemaDto logSchema, String schemaResource) throws Exception { diff --git a/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/ApplicationServiceImpl.java b/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/ApplicationServiceImpl.java index 2fb6d26523..598e262bd1 100644 --- a/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/ApplicationServiceImpl.java +++ b/server/common/dao/src/main/java/org/kaaproject/kaa/server/common/dao/service/ApplicationServiceImpl.java @@ -279,7 +279,7 @@ private NotificationSchemaDto createDefaultNotificationSchema(String appId, Stri notificationSchemaDto.setType(NotificationTypeDto.USER); notificationSchemaDto = notificationService.saveNotificationSchema(notificationSchemaDto); if (notificationSchemaDto == null) { - throw new RuntimeException("Can't save default profile schema "); //NOSONAR + throw new RuntimeException("Can't save default notification schema "); //NOSONAR } return notificationSchemaDto; } diff --git a/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/KaaAdminController.java b/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/KaaAdminController.java index dc93f5d28c..d1bba02e47 100644 --- a/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/KaaAdminController.java +++ b/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/KaaAdminController.java @@ -1157,10 +1157,10 @@ public NotificationSchemaDto getNotificationSchema(@PathVariable String notifica * @throws KaaAdminServiceException * the kaa admin service exception */ - @RequestMapping(value = "createNotificationSchema", method = RequestMethod.POST, consumes = { "multipart/mixed", "multipart/form-data" }) + @RequestMapping(value = "createNotificationSchema", method = RequestMethod.POST) @ResponseBody - public NotificationSchemaDto createNotificationSchema(@RequestPart("notificationSchema") NotificationSchemaDto notificationSchema) throws KaaAdminServiceException { - return kaaAdminService.editNotificationSchema(notificationSchema); + public NotificationSchemaDto createNotificationSchema(@RequestBody NotificationSchemaDto notificationSchema) throws KaaAdminServiceException { + return kaaAdminService.saveNotificationSchema(notificationSchema); } /** @@ -1172,11 +1172,11 @@ public NotificationSchemaDto createNotificationSchema(@RequestPart("notification * @throws KaaAdminServiceException * the kaa admin service exception */ - @RequestMapping(value = "editNotificationSchema", method = RequestMethod.POST) + @RequestMapping(value = "saveNotificationSchema", method = RequestMethod.POST) @ResponseBody - public NotificationSchemaDto editNotificationSchema(@RequestBody NotificationSchemaDto notificationSchema) + public NotificationSchemaDto saveNotificationSchema(@RequestBody NotificationSchemaDto notificationSchema) throws KaaAdminServiceException { - return kaaAdminService.editNotificationSchema(notificationSchema); + return kaaAdminService.saveNotificationSchema(notificationSchema); } /** diff --git a/server/node/src/main/java/org/kaaproject/kaa/server/admin/services/KaaAdminServiceImpl.java b/server/node/src/main/java/org/kaaproject/kaa/server/admin/services/KaaAdminServiceImpl.java index 33c83781b2..29b6800dc3 100644 --- a/server/node/src/main/java/org/kaaproject/kaa/server/admin/services/KaaAdminServiceImpl.java +++ b/server/node/src/main/java/org/kaaproject/kaa/server/admin/services/KaaAdminServiceImpl.java @@ -1506,12 +1506,11 @@ public List getUserNotificationSchemaInfosByApplicationId(String } } + @Override public NotificationSchemaViewDto getNotificationSchemaView(String notificationSchemaId) throws KaaAdminServiceException { checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER); try { - NotificationSchemaDto notificationSchema = controlService.getNotificationSchema(notificationSchemaId); - Utils.checkNotNull(notificationSchema); - checkApplicationId(notificationSchema.getApplicationId()); + NotificationSchemaDto notificationSchema = getNotificationSchema(notificationSchemaId); CTLSchemaDto ctlSchemaDto = controlService.getCTLSchemaById(notificationSchema.getCtlSchemaId()); NotificationSchemaViewDto notificationSchemaViewDto = new NotificationSchemaViewDto(notificationSchema, toCtlSchemaForm(ctlSchemaDto)); return notificationSchemaViewDto; @@ -1520,6 +1519,7 @@ public NotificationSchemaViewDto getNotificationSchemaView(String notificationSc } } + @Override public NotificationSchemaDto getNotificationSchema(String notificationSchemaId) throws KaaAdminServiceException { checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER); try { @@ -1533,7 +1533,7 @@ public NotificationSchemaDto getNotificationSchema(String notificationSchemaId) } @Override - public NotificationSchemaDto editNotificationSchema(NotificationSchemaDto notificationSchema) + public NotificationSchemaDto saveNotificationSchema(NotificationSchemaDto notificationSchema) throws KaaAdminServiceException { checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER); try { @@ -1546,7 +1546,7 @@ public NotificationSchemaDto editNotificationSchema(NotificationSchemaDto notifi checkApplicationId(storedNotificationSchema.getApplicationId()); } notificationSchema.setType(NotificationTypeDto.USER); - return controlService.editNotificationSchema(notificationSchema); + return controlService.saveNotificationSchema(notificationSchema); } catch (Exception e) { throw Utils.handleException(e); } @@ -1573,7 +1573,7 @@ public NotificationSchemaViewDto saveNotificationSchemaView(NotificationSchemaVi notificationSchema.setCtlSchemaId(ctlSchemaForm.getId()); } } - NotificationSchemaDto savedNotificationSchema = editNotificationSchema(notificationSchema); + NotificationSchemaDto savedNotificationSchema = saveNotificationSchema(notificationSchema); return getNotificationSchemaView(savedNotificationSchema.getId()); } catch (Exception e) { throw Utils.handleException(e); @@ -1592,7 +1592,7 @@ public NotificationSchemaViewDto createNotificationSchemaFormCtlSchema(CtlSchema notificationSchema.setDescription(ctlSchemaForm.getSchema().getDescriptionFieldValue()); CtlSchemaFormDto savedCtlSchemaForm = saveCTLSchemaForm(ctlSchemaForm); notificationSchema.setCtlSchemaId(savedCtlSchemaForm.getId()); - NotificationSchemaDto savedNotificationSchema = editNotificationSchema(notificationSchema); + NotificationSchemaDto savedNotificationSchema = saveNotificationSchema(notificationSchema); return getNotificationSchemaView(savedNotificationSchema.getId()); } catch (Exception e) { throw Utils.handleException(e); diff --git a/server/node/src/main/java/org/kaaproject/kaa/server/admin/shared/services/KaaAdminService.java b/server/node/src/main/java/org/kaaproject/kaa/server/admin/shared/services/KaaAdminService.java index 8953992c46..858bf98e5f 100644 --- a/server/node/src/main/java/org/kaaproject/kaa/server/admin/shared/services/KaaAdminService.java +++ b/server/node/src/main/java/org/kaaproject/kaa/server/admin/shared/services/KaaAdminService.java @@ -207,7 +207,7 @@ public interface KaaAdminService extends RemoteService { NotificationSchemaViewDto getNotificationSchemaView(String notificationSchemaId) throws KaaAdminServiceException; - NotificationSchemaDto editNotificationSchema(NotificationSchemaDto notificationSchema) throws KaaAdminServiceException; + NotificationSchemaDto saveNotificationSchema(NotificationSchemaDto notificationSchema) throws KaaAdminServiceException; NotificationSchemaViewDto saveNotificationSchemaView(NotificationSchemaViewDto notificationSchema) throws KaaAdminServiceException; diff --git a/server/node/src/main/java/org/kaaproject/kaa/server/control/service/ControlService.java b/server/node/src/main/java/org/kaaproject/kaa/server/control/service/ControlService.java index 81a4558051..47bf658e49 100644 --- a/server/node/src/main/java/org/kaaproject/kaa/server/control/service/ControlService.java +++ b/server/node/src/main/java/org/kaaproject/kaa/server/control/service/ControlService.java @@ -728,7 +728,7 @@ void deleteProfileFilterRecord(String endpointProfileSchemaId, String serverProf * @throws ControlServiceException * the control service exception */ - NotificationSchemaDto editNotificationSchema(NotificationSchemaDto notificationSchema) throws ControlServiceException; + NotificationSchemaDto saveNotificationSchema(NotificationSchemaDto notificationSchema) throws ControlServiceException; /** * Gets the notification schema. diff --git a/server/node/src/main/java/org/kaaproject/kaa/server/control/service/DefaultControlService.java b/server/node/src/main/java/org/kaaproject/kaa/server/control/service/DefaultControlService.java index d13328d024..91b73a6fbe 100644 --- a/server/node/src/main/java/org/kaaproject/kaa/server/control/service/DefaultControlService.java +++ b/server/node/src/main/java/org/kaaproject/kaa/server/control/service/DefaultControlService.java @@ -1062,7 +1062,7 @@ public FileData generateSdk(SdkProfileDto sdkProfile, SdkPlatform platform) thro CTLSchemaDto notificationCtlSchema = ctlService.findCTLSchemaById(notificationSchema.getCtlSchemaId()); if (notificationCtlSchema == null) { - throw new NotFoundException("Profile CTL schema not found!"); + throw new NotFoundException("Notification CTL schema not found!"); } String notificationSchemaBodyString = ctlService.flatExportAsString(notificationCtlSchema); @@ -1149,7 +1149,7 @@ public FileData generateRecordStructureLibrary(String applicationId, int logSche * (org.kaaproject.kaa.common.dto.NotificationSchemaDto) */ @Override - public NotificationSchemaDto editNotificationSchema(NotificationSchemaDto notificationSchema) throws ControlServiceException { + public NotificationSchemaDto saveNotificationSchema(NotificationSchemaDto notificationSchema) throws ControlServiceException { return notificationService.saveNotificationSchema(notificationSchema); }