@Override public List<SchemaInfoDto> getUserNotificationSchemaInfosByApplicationId(String applicationId) throws KaaAdminServiceException { checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER); try { checkApplicationId(applicationId); List<NotificationSchemaDto> notificationSchemas = controlService.findNotificationSchemasByAppIdAndType( applicationId, NotificationTypeDto.USER); List<SchemaInfoDto> schemaInfos = new ArrayList<>(notificationSchemas.size()); for (NotificationSchemaDto notificationSchema : notificationSchemas) { SchemaInfoDto schemaInfo = new SchemaInfoDto(notificationSchema); RecordField schemaForm = createRecordFieldFromCtlSchemaAndBody( notificationSchema.getCtlSchemaId(), null); schemaInfo.setSchemaForm(schemaForm); schemaInfos.add(schemaInfo); } return schemaInfos; } catch (Exception ex) { throw Utils.handleException(ex); } }
@Override public NotificationSchemaViewDto getNotificationSchemaView(String notificationSchemaId) throws KaaAdminServiceException { checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER); try { NotificationSchemaDto notificationSchema = getNotificationSchema(notificationSchemaId); CTLSchemaDto ctlSchemaDto = controlService.getCtlSchemaById(notificationSchema.getCtlSchemaId()); NotificationSchemaViewDto notificationSchemaViewDto = new NotificationSchemaViewDto( notificationSchema, toCtlSchemaForm(ctlSchemaDto, ConverterType.FORM_AVRO_CONVERTER)); return notificationSchemaViewDto; } catch (Exception ex) { throw Utils.handleException(ex); } }
CTLSchemaDto notificationCtlSchema = getCtlSchemaById(notificationSchema.getCtlSchemaId());
@Override public NotificationSchemaViewDto saveNotificationSchemaView( NotificationSchemaViewDto notificationSchemaView) throws KaaAdminServiceException { checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER); try { NotificationSchemaDto notificationSchema = notificationSchemaView.getSchema(); String applicationId = notificationSchema.getApplicationId(); checkApplicationId(applicationId); String ctlSchemaId = notificationSchema.getCtlSchemaId(); if (isEmpty(ctlSchemaId)) { if (notificationSchemaView.useExistingCtlSchema()) { CtlSchemaReferenceDto metaInfo = notificationSchemaView.getExistingMetaInfo(); CTLSchemaDto schema = ctlService.getCtlSchemaByFqnVersionTenantIdAndApplicationId( metaInfo.getMetaInfo().getFqn(), metaInfo.getVersion(), metaInfo.getMetaInfo().getTenantId(), metaInfo.getMetaInfo().getApplicationId()); notificationSchema.setCtlSchemaId(schema.getId()); } else { CtlSchemaFormDto ctlSchemaForm = ctlService.saveCtlSchemaForm( notificationSchemaView.getCtlSchemaForm(), ConverterType.FORM_AVRO_CONVERTER); notificationSchema.setCtlSchemaId(ctlSchemaForm.getId()); } } NotificationSchemaDto savedNotificationSchema = saveNotificationSchema(notificationSchema); return getNotificationSchemaView(savedNotificationSchema.getId()); } catch (Exception ex) { throw Utils.handleException(ex); } }