Skip to content

Commit

Permalink
KAA-1144: Quick fix for 'CtlSchemaActivity' class
Browse files Browse the repository at this point in the history
  • Loading branch information
vchizhevsky committed Jul 20, 2016
1 parent bd5dc8c commit 6c039f3
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 27 deletions.
Expand Up @@ -252,11 +252,13 @@ public ServerProfileSchemaDto saveServerProfileSchema(ServerProfileSchemaDto ser
} }


public NotificationSchemaDto createNotificationSchema(NotificationSchemaDto notificationSchema) throws Exception { public NotificationSchemaDto createNotificationSchema(NotificationSchemaDto notificationSchema) throws Exception {
return restTemplate.postForObject(restTemplate.getUrl() + "createNotificationSchema", notificationSchema, NotificationSchemaDto.class); MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
params.add("notificationSchema", notificationSchema);
return restTemplate.postForObject(restTemplate.getUrl() + "createNotificationSchema", params, NotificationSchemaDto.class);
} }


public NotificationSchemaDto saveNotificationSchema(NotificationSchemaDto notificationSchema) throws Exception { public NotificationSchemaDto editNotificationSchema(NotificationSchemaDto notificationSchema) throws Exception {
return restTemplate.postForObject(restTemplate.getUrl() + "saveNotificationSchema", notificationSchema, NotificationSchemaDto.class); return restTemplate.postForObject(restTemplate.getUrl() + "editNotificationSchema", notificationSchema, NotificationSchemaDto.class);
} }


public LogSchemaDto createLogSchema(LogSchemaDto logSchema) throws Exception { public LogSchemaDto createLogSchema(LogSchemaDto logSchema) throws Exception {
Expand Down
Expand Up @@ -279,7 +279,7 @@ private NotificationSchemaDto createDefaultNotificationSchema(String appId, Stri
notificationSchemaDto.setType(NotificationTypeDto.USER); notificationSchemaDto.setType(NotificationTypeDto.USER);
notificationSchemaDto = notificationService.saveNotificationSchema(notificationSchemaDto); notificationSchemaDto = notificationService.saveNotificationSchema(notificationSchemaDto);
if (notificationSchemaDto == null) { if (notificationSchemaDto == null) {
throw new RuntimeException("Can't save default notification schema "); //NOSONAR throw new RuntimeException("Can't save default profile schema "); //NOSONAR
} }
return notificationSchemaDto; return notificationSchemaDto;
} }
Expand Down
Expand Up @@ -252,11 +252,11 @@ public void onSuccessImpl(CtlSchemaFormDto result) {
} else if (place.getSchemaType() != null) { } else if (place.getSchemaType() != null) {
if (place.getSchemaType() == SchemaType.ENDPOINT_PROFILE) { if (place.getSchemaType() == SchemaType.ENDPOINT_PROFILE) {
goTo(new ProfileSchemasPlace(place.getApplicationId())); goTo(new ProfileSchemasPlace(place.getApplicationId()));
} else if (place.getSchemaType() == SchemaType.SERVER_PROFILE){ } else if (place.getSchemaType() == SchemaType.SERVER_PROFILE) {
goTo(new ServerProfileSchemasPlace(place.getApplicationId())); goTo(new ServerProfileSchemasPlace(place.getApplicationId()));
} else if (place.getSchemaType() == SchemaType.NOTIFICATION){ } else if (place.getSchemaType() == SchemaType.NOTIFICATION) {
goTo(new NotificationSchemasPlace(place.getApplicationId())); goTo(new NotificationSchemasPlace(place.getApplicationId()));
} else { } else if (place.getSchemaType() == SchemaType.LOG_SCHEMA) {
goTo(new LogSchemasPlace(place.getApplicationId())); goTo(new LogSchemasPlace(place.getApplicationId()));
} }
} else if (place.getPreviousPlace() != null) { } else if (place.getPreviousPlace() != null) {
Expand Down Expand Up @@ -403,7 +403,7 @@ public void onSuccessImpl(NotificationSchemaViewDto notificationSchemaViewDto) {
callback.onSuccess(null); callback.onSuccess(null);
} }
}); });
} else { } else if (place.getSchemaType() == SchemaType.LOG_SCHEMA) {
KaaAdmin.getDataSource().createLogSchemaFormCtlSchema(entity, new BusyAsyncCallback<LogSchemaViewDto>() { KaaAdmin.getDataSource().createLogSchemaFormCtlSchema(entity, new BusyAsyncCallback<LogSchemaViewDto>() {
@Override @Override
public void onFailureImpl(Throwable caught) { public void onFailureImpl(Throwable caught) {
Expand Down
Expand Up @@ -182,11 +182,11 @@ public TreePlace createDefaultPreviousPlace() {
if (schemaType != null) { if (schemaType != null) {
if (schemaType == SchemaType.ENDPOINT_PROFILE) { if (schemaType == SchemaType.ENDPOINT_PROFILE) {
return new ProfileSchemasPlace(applicationId); return new ProfileSchemasPlace(applicationId);
} else if (schemaType == SchemaType.SERVER_PROFILE){ } else if (schemaType == SchemaType.SERVER_PROFILE) {
return new ServerProfileSchemasPlace(applicationId); return new ServerProfileSchemasPlace(applicationId);
} else if (schemaType == SchemaType.NOTIFICATION) { } else if (schemaType == SchemaType.NOTIFICATION) {
return new NotificationSchemasPlace(applicationId); return new NotificationSchemasPlace(applicationId);
} else { } else if (schemaType == SchemaType.LOG_SCHEMA) {
return new LogSchemasPlace(applicationId); return new LogSchemasPlace(applicationId);
} }
} else { } else {
Expand Down
Expand Up @@ -1157,10 +1157,10 @@ public NotificationSchemaDto getNotificationSchema(@PathVariable String notifica
* @throws KaaAdminServiceException * @throws KaaAdminServiceException
* the kaa admin service exception * the kaa admin service exception
*/ */
@RequestMapping(value = "createNotificationSchema", method = RequestMethod.POST) @RequestMapping(value = "createNotificationSchema", method = RequestMethod.POST, consumes = { "multipart/mixed", "multipart/form-data" })
@ResponseBody @ResponseBody
public NotificationSchemaDto createNotificationSchema(@RequestBody NotificationSchemaDto notificationSchema) throws KaaAdminServiceException { public NotificationSchemaDto createNotificationSchema(@RequestPart("notificationSchema") NotificationSchemaDto notificationSchema) throws KaaAdminServiceException {
return kaaAdminService.saveNotificationSchema(notificationSchema); return kaaAdminService.editNotificationSchema(notificationSchema);
} }


/** /**
Expand All @@ -1172,11 +1172,11 @@ public NotificationSchemaDto createNotificationSchema(@RequestBody NotificationS
* @throws KaaAdminServiceException * @throws KaaAdminServiceException
* the kaa admin service exception * the kaa admin service exception
*/ */
@RequestMapping(value = "saveNotificationSchema", method = RequestMethod.POST) @RequestMapping(value = "editNotificationSchema", method = RequestMethod.POST)
@ResponseBody @ResponseBody
public NotificationSchemaDto saveNotificationSchema(@RequestBody NotificationSchemaDto notificationSchema) public NotificationSchemaDto editNotificationSchema(@RequestBody NotificationSchemaDto notificationSchema)
throws KaaAdminServiceException { throws KaaAdminServiceException {
return kaaAdminService.saveNotificationSchema(notificationSchema); return kaaAdminService.editNotificationSchema(notificationSchema);
} }


/** /**
Expand Down
Expand Up @@ -1506,11 +1506,13 @@ public List<SchemaInfoDto> getUserNotificationSchemaInfosByApplicationId(String
} }
} }


@Override
public NotificationSchemaViewDto getNotificationSchemaView(String notificationSchemaId) throws KaaAdminServiceException { public NotificationSchemaViewDto getNotificationSchemaView(String notificationSchemaId) throws KaaAdminServiceException {
checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER); checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER);
try { try {
NotificationSchemaDto notificationSchema = getNotificationSchema(notificationSchemaId); NotificationSchemaDto notificationSchema = controlService.getNotificationSchema(notificationSchemaId);
Utils.checkNotNull(notificationSchema);
checkApplicationId(notificationSchema.getApplicationId());
CTLSchemaDto ctlSchemaDto = controlService.getCTLSchemaById(notificationSchema.getCtlSchemaId()); CTLSchemaDto ctlSchemaDto = controlService.getCTLSchemaById(notificationSchema.getCtlSchemaId());
NotificationSchemaViewDto notificationSchemaViewDto = new NotificationSchemaViewDto(notificationSchema, toCtlSchemaForm(ctlSchemaDto)); NotificationSchemaViewDto notificationSchemaViewDto = new NotificationSchemaViewDto(notificationSchema, toCtlSchemaForm(ctlSchemaDto));
return notificationSchemaViewDto; return notificationSchemaViewDto;
Expand All @@ -1519,7 +1521,7 @@ public NotificationSchemaViewDto getNotificationSchemaView(String notificationSc
} }
} }


@Override
public NotificationSchemaDto getNotificationSchema(String notificationSchemaId) throws KaaAdminServiceException { public NotificationSchemaDto getNotificationSchema(String notificationSchemaId) throws KaaAdminServiceException {
checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER); checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER);
try { try {
Expand All @@ -1533,7 +1535,7 @@ public NotificationSchemaDto getNotificationSchema(String notificationSchemaId)
} }


@Override @Override
public NotificationSchemaDto saveNotificationSchema(NotificationSchemaDto notificationSchema) public NotificationSchemaDto editNotificationSchema(NotificationSchemaDto notificationSchema)
throws KaaAdminServiceException { throws KaaAdminServiceException {
checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER); checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER);
try { try {
Expand All @@ -1546,7 +1548,7 @@ public NotificationSchemaDto saveNotificationSchema(NotificationSchemaDto notifi
checkApplicationId(storedNotificationSchema.getApplicationId()); checkApplicationId(storedNotificationSchema.getApplicationId());
} }
notificationSchema.setType(NotificationTypeDto.USER); notificationSchema.setType(NotificationTypeDto.USER);
return controlService.saveNotificationSchema(notificationSchema); return controlService.editNotificationSchema(notificationSchema);
} catch (Exception e) { } catch (Exception e) {
throw Utils.handleException(e); throw Utils.handleException(e);
} }
Expand All @@ -1573,7 +1575,7 @@ public NotificationSchemaViewDto saveNotificationSchemaView(NotificationSchemaVi
notificationSchema.setCtlSchemaId(ctlSchemaForm.getId()); notificationSchema.setCtlSchemaId(ctlSchemaForm.getId());
} }
} }
NotificationSchemaDto savedNotificationSchema = saveNotificationSchema(notificationSchema); NotificationSchemaDto savedNotificationSchema = editNotificationSchema(notificationSchema);
return getNotificationSchemaView(savedNotificationSchema.getId()); return getNotificationSchemaView(savedNotificationSchema.getId());
} catch (Exception e) { } catch (Exception e) {
throw Utils.handleException(e); throw Utils.handleException(e);
Expand All @@ -1592,7 +1594,7 @@ public NotificationSchemaViewDto createNotificationSchemaFormCtlSchema(CtlSchema
notificationSchema.setDescription(ctlSchemaForm.getSchema().getDescriptionFieldValue()); notificationSchema.setDescription(ctlSchemaForm.getSchema().getDescriptionFieldValue());
CtlSchemaFormDto savedCtlSchemaForm = saveCTLSchemaForm(ctlSchemaForm); CtlSchemaFormDto savedCtlSchemaForm = saveCTLSchemaForm(ctlSchemaForm);
notificationSchema.setCtlSchemaId(savedCtlSchemaForm.getId()); notificationSchema.setCtlSchemaId(savedCtlSchemaForm.getId());
NotificationSchemaDto savedNotificationSchema = saveNotificationSchema(notificationSchema); NotificationSchemaDto savedNotificationSchema = editNotificationSchema(notificationSchema);
return getNotificationSchemaView(savedNotificationSchema.getId()); return getNotificationSchemaView(savedNotificationSchema.getId());
} catch (Exception e) { } catch (Exception e) {
throw Utils.handleException(e); throw Utils.handleException(e);
Expand Down
Expand Up @@ -207,7 +207,7 @@ public interface KaaAdminService extends RemoteService {


NotificationSchemaViewDto getNotificationSchemaView(String notificationSchemaId) throws KaaAdminServiceException; NotificationSchemaViewDto getNotificationSchemaView(String notificationSchemaId) throws KaaAdminServiceException;


NotificationSchemaDto saveNotificationSchema(NotificationSchemaDto notificationSchema) throws KaaAdminServiceException; NotificationSchemaDto editNotificationSchema(NotificationSchemaDto notificationSchema) throws KaaAdminServiceException;


NotificationSchemaViewDto saveNotificationSchemaView(NotificationSchemaViewDto notificationSchema) throws KaaAdminServiceException; NotificationSchemaViewDto saveNotificationSchemaView(NotificationSchemaViewDto notificationSchema) throws KaaAdminServiceException;


Expand Down
Expand Up @@ -728,7 +728,7 @@ void deleteProfileFilterRecord(String endpointProfileSchemaId, String serverProf
* @throws ControlServiceException * @throws ControlServiceException
* the control service exception * the control service exception
*/ */
NotificationSchemaDto saveNotificationSchema(NotificationSchemaDto notificationSchema) throws ControlServiceException; NotificationSchemaDto editNotificationSchema(NotificationSchemaDto notificationSchema) throws ControlServiceException;


/** /**
* Gets the notification schema. * Gets the notification schema.
Expand Down
Expand Up @@ -1069,7 +1069,7 @@ public FileData generateSdk(SdkProfileDto sdkProfile, SdkPlatform platform) thro


CTLSchemaDto notificationCtlSchema = ctlService.findCTLSchemaById(notificationSchema.getCtlSchemaId()); CTLSchemaDto notificationCtlSchema = ctlService.findCTLSchemaById(notificationSchema.getCtlSchemaId());
if (notificationCtlSchema == null) { if (notificationCtlSchema == null) {
throw new NotFoundException("Notification CTL schema not found!"); throw new NotFoundException("Profile CTL schema not found!");
} }
String notificationSchemaBodyString = ctlService.flatExportAsString(notificationCtlSchema); String notificationSchemaBodyString = ctlService.flatExportAsString(notificationCtlSchema);


Expand Down Expand Up @@ -1160,7 +1160,7 @@ public FileData generateRecordStructureLibrary(String applicationId, int logSche
* (org.kaaproject.kaa.common.dto.NotificationSchemaDto) * (org.kaaproject.kaa.common.dto.NotificationSchemaDto)
*/ */
@Override @Override
public NotificationSchemaDto saveNotificationSchema(NotificationSchemaDto notificationSchema) throws ControlServiceException { public NotificationSchemaDto editNotificationSchema(NotificationSchemaDto notificationSchema) throws ControlServiceException {
return notificationService.saveNotificationSchema(notificationSchema); return notificationService.saveNotificationSchema(notificationSchema);
} }


Expand Down

0 comments on commit 6c039f3

Please sign in to comment.