Skip to content

Commit

Permalink
Fix style in ControlService and related classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill380 committed Sep 29, 2016
1 parent f6e8bf4 commit 2b50b71
Show file tree
Hide file tree
Showing 13 changed files with 763 additions and 426 deletions.
Expand Up @@ -292,8 +292,8 @@ Schema validateSchema(String avroSchema, boolean isCtl) throws KaaAdminServiceEx
RecordField createRecordFieldFromCtlSchemaAndBody(String ctlSchemaId, String body) throws KaaAdminServiceException { RecordField createRecordFieldFromCtlSchemaAndBody(String ctlSchemaId, String body) throws KaaAdminServiceException {
try { try {
RecordField recordField; RecordField recordField;
CTLSchemaDto ctlSchema = controlService.getCTLSchemaById(ctlSchemaId); CTLSchemaDto ctlSchema = controlService.getCtlSchemaById(ctlSchemaId);
Schema schema = controlService.exportCTLSchemaFlatAsSchema(ctlSchema); Schema schema = controlService.exportCtlSchemaFlatAsSchema(ctlSchema);
if (!isEmpty(body)) { if (!isEmpty(body)) {
GenericAvroConverter<GenericRecord> converter = new GenericAvroConverter<>(schema); GenericAvroConverter<GenericRecord> converter = new GenericAvroConverter<>(schema);
GenericRecord record = converter.decodeJson(body); GenericRecord record = converter.decodeJson(body);
Expand Down Expand Up @@ -417,7 +417,7 @@ CtlSchemaFormDto toCtlSchemaForm(CTLSchemaDto ctlSchema, ConverterType converter
ctlSchemaForm.getMetaInfo().getApplicationId(), converterType); ctlSchemaForm.getMetaInfo().getApplicationId(), converterType);
RecordField form = converter.createSchemaFormFromSchema(ctlSchema.getBody()); RecordField form = converter.createSchemaFormFromSchema(ctlSchema.getBody());
ctlSchemaForm.setSchema(form); ctlSchemaForm.setSchema(form);
List<Integer> availableVersions = controlService.getAllCTLSchemaVersionsByFqnTenantIdAndApplicationId( List<Integer> availableVersions = controlService.getAllCtlSchemaVersionsByFqnTenantIdAndApplicationId(
ctlSchema.getMetaInfo().getFqn(), ctlSchema.getMetaInfo().getTenantId(), ctlSchema.getMetaInfo().getApplicationId()); ctlSchema.getMetaInfo().getFqn(), ctlSchema.getMetaInfo().getTenantId(), ctlSchema.getMetaInfo().getApplicationId());
availableVersions = availableVersions == null ? Collections.<Integer>emptyList() : availableVersions; availableVersions = availableVersions == null ? Collections.<Integer>emptyList() : availableVersions;
Collections.sort(availableVersions); Collections.sort(availableVersions);
Expand All @@ -444,23 +444,23 @@ SchemaFormAvroConverter getCtlSchemaConverterForScope(String tenantId, String ap


private SchemaFormAvroConverter getCtlSchemaConverterForSystem(ConverterType converterType) throws KaaAdminServiceException { private SchemaFormAvroConverter getCtlSchemaConverterForSystem(ConverterType converterType) throws KaaAdminServiceException {
try { try {
return createSchemaConverterFromCtlTypes(controlService.getAvailableCTLSchemaVersionsForSystem(), converterType); return createSchemaConverterFromCtlTypes(controlService.getAvailableCtlSchemaVersionsForSystem(), converterType);
} catch (Exception cause) { } catch (Exception cause) {
throw Utils.handleException(cause); throw Utils.handleException(cause);
} }
} }


private SchemaFormAvroConverter getCtlSchemaConverterForTenant(String tenantId, ConverterType converterType) throws KaaAdminServiceException { private SchemaFormAvroConverter getCtlSchemaConverterForTenant(String tenantId, ConverterType converterType) throws KaaAdminServiceException {
try { try {
return createSchemaConverterFromCtlTypes(controlService.getAvailableCTLSchemaVersionsForTenant(tenantId), converterType); return createSchemaConverterFromCtlTypes(controlService.getAvailableCtlSchemaVersionsForTenant(tenantId), converterType);
} catch (Exception cause) { } catch (Exception cause) {
throw Utils.handleException(cause); throw Utils.handleException(cause);
} }
} }


private SchemaFormAvroConverter getCtlSchemaConverterForApplication(String tenantId, String applicationId, ConverterType converterType) throws KaaAdminServiceException { private SchemaFormAvroConverter getCtlSchemaConverterForApplication(String tenantId, String applicationId, ConverterType converterType) throws KaaAdminServiceException {
try { try {
return createSchemaConverterFromCtlTypes(controlService.getAvailableCTLSchemaVersionsForApplication(tenantId, applicationId), converterType); return createSchemaConverterFromCtlTypes(controlService.getAvailableCtlSchemaVersionsForApplication(tenantId, applicationId), converterType);
} catch (Exception cause) { } catch (Exception cause) {
throw Utils.handleException(cause); throw Utils.handleException(cause);
} }
Expand Down
Expand Up @@ -122,17 +122,17 @@ public FileData getRecordData(RecordKey key) throws KaaAdminServiceException {
public FileData getExportedCtlSchema(CtlSchemaExportKey key) public FileData getExportedCtlSchema(CtlSchemaExportKey key)
throws KaaAdminServiceException { throws KaaAdminServiceException {
try { try {
CTLSchemaDto schemaFound = controlService.getCTLSchemaById(key.getCtlSchemaId()); CTLSchemaDto schemaFound = controlService.getCtlSchemaById(key.getCtlSchemaId());
Utils.checkNotNull(schemaFound); Utils.checkNotNull(schemaFound);
switch (key.getExportMethod()) { switch (key.getExportMethod()) {
case SHALLOW: case SHALLOW:
return controlService.exportCTLSchemaShallow(schemaFound); return controlService.exportCtlSchemaShallow(schemaFound);
case FLAT: case FLAT:
return controlService.exportCTLSchemaFlat(schemaFound); return controlService.exportCtlSchemaFlat(schemaFound);
case DEEP: case DEEP:
return controlService.exportCTLSchemaDeep(schemaFound); return controlService.exportCtlSchemaDeep(schemaFound);
case LIBRARY: case LIBRARY:
return controlService.exportCTLSchemaFlatAsLibrary(schemaFound); return controlService.exportCtlSchemaFlatAsLibrary(schemaFound);
default: default:
throw new IllegalArgumentException("The export method " + key.getExportMethod().name() + " is not currently supported!"); throw new IllegalArgumentException("The export method " + key.getExportMethod().name() + " is not currently supported!");
} }
Expand Down
Expand Up @@ -166,7 +166,7 @@ public ConfigurationSchemaViewDto getConfigurationSchemaView(String configuratio
checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER); checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER);
try { try {
ConfigurationSchemaDto confSchema = getConfigurationSchema(configurationSchemaId); ConfigurationSchemaDto confSchema = getConfigurationSchema(configurationSchemaId);
CTLSchemaDto ctlSchemaDto = controlService.getCTLSchemaById(confSchema.getCtlSchemaId()); CTLSchemaDto ctlSchemaDto = controlService.getCtlSchemaById(confSchema.getCtlSchemaId());
return new ConfigurationSchemaViewDto(confSchema, toCtlSchemaForm(ctlSchemaDto, ConverterType.CONFIGURATION_FORM_AVRO_CONVERTER)); return new ConfigurationSchemaViewDto(confSchema, toCtlSchemaForm(ctlSchemaDto, ConverterType.CONFIGURATION_FORM_AVRO_CONVERTER));
} catch (Exception e) { } catch (Exception e) {
throw Utils.handleException(e); throw Utils.handleException(e);
Expand Down
Expand Up @@ -71,7 +71,7 @@ public CTLSchemaDto saveCTLSchema(CTLSchemaDto schema) throws KaaAdminServiceExc
if (schema.getDependencySet() != null) { if (schema.getDependencySet() != null) {
for (CTLSchemaDto dependency : schema.getDependencySet()) { for (CTLSchemaDto dependency : schema.getDependencySet()) {
CTLSchemaDto schemaFound = CTLSchemaDto schemaFound =
controlService.getAnyCTLSchemaByFqnVersionTenantIdAndApplicationId( controlService.getAnyCtlSchemaByFqnVersionTenantIdAndApplicationId(
dependency.getMetaInfo().getFqn(), dependency.getVersion(), dependency.getMetaInfo().getFqn(), dependency.getVersion(),
schema.getMetaInfo().getTenantId(), schema.getMetaInfo().getApplicationId()); schema.getMetaInfo().getTenantId(), schema.getMetaInfo().getApplicationId());
if (schemaFound == null) { if (schemaFound == null) {
Expand All @@ -90,7 +90,7 @@ public CTLSchemaDto saveCTLSchema(CTLSchemaDto schema) throws KaaAdminServiceExc
CTLSchemaParser parser = new CTLSchemaParser(controlService, schema.getMetaInfo().getTenantId()); CTLSchemaParser parser = new CTLSchemaParser(controlService, schema.getMetaInfo().getTenantId());
parser.validate(schema); parser.validate(schema);


CTLSchemaDto result = controlService.saveCTLSchema(schema); CTLSchemaDto result = controlService.saveCtlSchema(schema);
return result; return result;
} catch (Exception cause) { } catch (Exception cause) {
throw Utils.handleException(cause); throw Utils.handleException(cause);
Expand All @@ -116,7 +116,7 @@ public CTLSchemaDto saveCTLSchema(String body, String tenantId, String applicati
checkCTLSchemaVersion(schema.getVersion()); checkCTLSchemaVersion(schema.getVersion());
// Check if the schema body is valid // Check if the schema body is valid
parser.validate(schema); parser.validate(schema);
CTLSchemaDto result = controlService.saveCTLSchema(schema); CTLSchemaDto result = controlService.saveCtlSchema(schema);
return result; return result;
} catch (Exception cause) { } catch (Exception cause) {
throw Utils.handleException(cause); throw Utils.handleException(cause);
Expand All @@ -141,17 +141,17 @@ public void deleteCTLSchemaByFqnVersionTenantIdAndApplicationId(String fqn, Inte
if (!isEmpty(applicationId)) { if (!isEmpty(applicationId)) {
this.checkApplicationId(applicationId); this.checkApplicationId(applicationId);
} }
CTLSchemaDto schemaFound = controlService.getCTLSchemaByFqnVersionTenantIdAndApplicationId(fqn, version, tenantId, applicationId); CTLSchemaDto schemaFound = controlService.getCtlSchemaByFqnVersionTenantIdAndApplicationId(fqn, version, tenantId, applicationId);
Utils.checkNotNull(schemaFound); Utils.checkNotNull(schemaFound);
checkCTLSchemaEditScope(schemaFound.getMetaInfo().getTenantId(), schemaFound.getMetaInfo().getApplicationId()); checkCTLSchemaEditScope(schemaFound.getMetaInfo().getTenantId(), schemaFound.getMetaInfo().getApplicationId());
List<CTLSchemaDto> schemaDependents = controlService.getCTLSchemaDependents(fqn, version, tenantId, applicationId); List<CTLSchemaDto> schemaDependents = controlService.getCtlSchemaDependents(fqn, version, tenantId, applicationId);
if (schemaDependents != null && !schemaDependents.isEmpty()) { if (schemaDependents != null && !schemaDependents.isEmpty()) {
String message = "Can't delete the common type version as it is referenced by the following common type(s): " String message = "Can't delete the common type version as it is referenced by the following common type(s): "
+ this.asText(schemaDependents); + this.asText(schemaDependents);
throw new IllegalArgumentException(message); throw new IllegalArgumentException(message);
} }


controlService.deleteCTLSchemaByFqnAndVersionTenantIdAndApplicationId(fqn, version, tenantId, applicationId); controlService.deleteCtlSchemaByFqnAndVersionTenantIdAndApplicationId(fqn, version, tenantId, applicationId);
} catch (Exception cause) { } catch (Exception cause) {
throw Utils.handleException(cause); throw Utils.handleException(cause);
} }
Expand All @@ -177,7 +177,7 @@ public CTLSchemaDto getCTLSchemaByFqnVersionTenantIdAndApplicationId(String fqn,
if (!isEmpty(applicationId)) { if (!isEmpty(applicationId)) {
this.checkApplicationId(applicationId); this.checkApplicationId(applicationId);
} }
CTLSchemaDto schemaFound = controlService.getCTLSchemaByFqnVersionTenantIdAndApplicationId(fqn, version, tenantId, applicationId); CTLSchemaDto schemaFound = controlService.getCtlSchemaByFqnVersionTenantIdAndApplicationId(fqn, version, tenantId, applicationId);
Utils.checkNotNull(schemaFound); Utils.checkNotNull(schemaFound);
checkCTLSchemaReadScope(schemaFound.getMetaInfo().getTenantId(), schemaFound.getMetaInfo().getApplicationId()); checkCTLSchemaReadScope(schemaFound.getMetaInfo().getTenantId(), schemaFound.getMetaInfo().getApplicationId());
return schemaFound; return schemaFound;
Expand All @@ -191,7 +191,7 @@ public CTLSchemaDto getCTLSchemaById(String schemaId) throws KaaAdminServiceExce
this.checkAuthority(KaaAuthorityDto.values()); this.checkAuthority(KaaAuthorityDto.values());
try { try {
this.checkCTLSchemaId(schemaId); this.checkCTLSchemaId(schemaId);
CTLSchemaDto schemaFound = controlService.getCTLSchemaById(schemaId); CTLSchemaDto schemaFound = controlService.getCtlSchemaById(schemaId);
Utils.checkNotNull(schemaFound); Utils.checkNotNull(schemaFound);
checkCTLSchemaReadScope(schemaFound.getMetaInfo().getTenantId(), schemaFound.getMetaInfo().getApplicationId()); checkCTLSchemaReadScope(schemaFound.getMetaInfo().getTenantId(), schemaFound.getMetaInfo().getApplicationId());
return schemaFound; return schemaFound;
Expand Down Expand Up @@ -249,19 +249,19 @@ public CTLSchemaMetaInfoDto promoteScopeToTenant(String applicationId, String fq


try { try {
Set<CTLSchemaDto> dependencies = new HashSet<>(); Set<CTLSchemaDto> dependencies = new HashSet<>();
List<Integer> versions = controlService.getAllCTLSchemaVersionsByFqnTenantIdAndApplicationId(fqn, tenantId, applicationId); List<Integer> versions = controlService.getAllCtlSchemaVersionsByFqnTenantIdAndApplicationId(fqn, tenantId, applicationId);


if (versions.isEmpty()) { if (versions.isEmpty()) {
throw new KaaAdminServiceException("The requested item was not found!", ServiceErrorCode.ITEM_NOT_FOUND); throw new KaaAdminServiceException("The requested item was not found!", ServiceErrorCode.ITEM_NOT_FOUND);
} }


// meta info same for all versions // meta info same for all versions
CTLSchemaMetaInfoDto ctlSchemaMetaInfo = controlService.getCTLSchemaByFqnVersionTenantIdAndApplicationId(fqn, versions.get(0), tenantId, applicationId).getMetaInfo(); CTLSchemaMetaInfoDto ctlSchemaMetaInfo = controlService.getCtlSchemaByFqnVersionTenantIdAndApplicationId(fqn, versions.get(0), tenantId, applicationId).getMetaInfo();
ctlSchemaMetaInfo.setApplicationId(null); //promote to tenant ctlSchemaMetaInfo.setApplicationId(null); //promote to tenant


// get dep of all versions // get dep of all versions
for (Integer version : versions) { for (Integer version : versions) {
CTLSchemaDto schema = controlService.getCTLSchemaByFqnVersionTenantIdAndApplicationId(fqn, version, tenantId, applicationId); CTLSchemaDto schema = controlService.getCtlSchemaByFqnVersionTenantIdAndApplicationId(fqn, version, tenantId, applicationId);
Set<CTLSchemaDto> schemaDependents = schema.getDependencySet(); Set<CTLSchemaDto> schemaDependents = schema.getDependencySet();
dependencies.addAll(schemaDependents.stream() dependencies.addAll(schemaDependents.stream()
.filter(dep -> dep.getMetaInfo().getScope() == CTLSchemaScopeDto.APPLICATION) .filter(dep -> dep.getMetaInfo().getScope() == CTLSchemaScopeDto.APPLICATION)
Expand All @@ -275,7 +275,7 @@ public CTLSchemaMetaInfoDto promoteScopeToTenant(String applicationId, String fq
throw new KaaAdminServiceException(message, ServiceErrorCode.CONFLICT); throw new KaaAdminServiceException(message, ServiceErrorCode.CONFLICT);
} }


return controlService.updateCTLSchemaMetaInfoScope(ctlSchemaMetaInfo); return controlService.updateCtlSchemaMetaInfoScope(ctlSchemaMetaInfo);
} catch (Exception cause) { } catch (Exception cause) {
throw Utils.handleException(cause); throw Utils.handleException(cause);
} }
Expand All @@ -285,7 +285,7 @@ public CTLSchemaMetaInfoDto promoteScopeToTenant(String applicationId, String fq
public List<CTLSchemaMetaInfoDto> getSystemLevelCTLSchemas() throws KaaAdminServiceException { public List<CTLSchemaMetaInfoDto> getSystemLevelCTLSchemas() throws KaaAdminServiceException {
checkAuthority(KaaAuthorityDto.values()); checkAuthority(KaaAuthorityDto.values());
try { try {
return controlService.getSystemCTLSchemasMetaInfo(); return controlService.getSystemCtlSchemasMetaInfo();
} catch (Exception cause) { } catch (Exception cause) {
throw Utils.handleException(cause); throw Utils.handleException(cause);
} }
Expand All @@ -296,7 +296,7 @@ public List<CTLSchemaMetaInfoDto> getTenantLevelCTLSchemas() throws KaaAdminServ
checkAuthority(KaaAuthorityDto.TENANT_ADMIN, KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER); checkAuthority(KaaAuthorityDto.TENANT_ADMIN, KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER);
try { try {
AuthUserDto currentUser = getCurrentUser(); AuthUserDto currentUser = getCurrentUser();
return controlService.getAvailableCTLSchemasMetaInfoForTenant(currentUser.getTenantId()); return controlService.getAvailableCtlSchemasMetaInfoForTenant(currentUser.getTenantId());
} catch (Exception cause) { } catch (Exception cause) {
throw Utils.handleException(cause); throw Utils.handleException(cause);
} }
Expand All @@ -307,8 +307,8 @@ public List<CtlSchemaReferenceDto> getTenantLevelCTLSchemaReferenceForECF(String
checkAuthority(KaaAuthorityDto.TENANT_ADMIN); checkAuthority(KaaAuthorityDto.TENANT_ADMIN);
try { try {
AuthUserDto currentUser = getCurrentUser(); AuthUserDto currentUser = getCurrentUser();
List<CTLSchemaMetaInfoDto> ctlSchemaReferenceDtoListForTenant = controlService.getAvailableCTLSchemasMetaInfoForTenant(currentUser.getTenantId()); List<CTLSchemaMetaInfoDto> ctlSchemaReferenceDtoListForTenant = controlService.getAvailableCtlSchemasMetaInfoForTenant(currentUser.getTenantId());
Set<String> fqnListOfCurrentECF = controlService.getFqnSetForECF(ecfId); Set<String> fqnListOfCurrentECF = controlService.getFqnSetForEcf(ecfId);
if (eventClassViewDtoList != null) { if (eventClassViewDtoList != null) {
for (EventClassViewDto eventClassViewDto : eventClassViewDtoList) { for (EventClassViewDto eventClassViewDto : eventClassViewDtoList) {
String fqn = eventClassViewDto.getCtlSchemaForm().getMetaInfo().getFqn(); String fqn = eventClassViewDto.getCtlSchemaForm().getMetaInfo().getFqn();
Expand Down Expand Up @@ -340,7 +340,7 @@ public List<CTLSchemaMetaInfoDto> getApplicationLevelCTLSchemas(String applicati
try { try {
this.checkApplicationId(applicationId); this.checkApplicationId(applicationId);
AuthUserDto currentUser = getCurrentUser(); AuthUserDto currentUser = getCurrentUser();
return controlService.getAvailableCTLSchemasMetaInfoForApplication(currentUser.getTenantId(), applicationId); return controlService.getAvailableCtlSchemasMetaInfoForApplication(currentUser.getTenantId(), applicationId);
} catch (Exception cause) { } catch (Exception cause) {
throw Utils.handleException(cause); throw Utils.handleException(cause);
} }
Expand All @@ -361,16 +361,16 @@ public FileData exportCTLSchema(String fqn, int version, String applicationId, C
this.checkCTLSchemaFqn(fqn); this.checkCTLSchemaFqn(fqn);
this.checkCTLSchemaVersion(version); this.checkCTLSchemaVersion(version);
String tenantId = getCurrentUser().getTenantId(); String tenantId = getCurrentUser().getTenantId();
CTLSchemaDto schemaFound = controlService.getCTLSchemaByFqnVersionTenantIdAndApplicationId(fqn, version, tenantId, applicationId); CTLSchemaDto schemaFound = controlService.getCtlSchemaByFqnVersionTenantIdAndApplicationId(fqn, version, tenantId, applicationId);
Utils.checkNotNull(schemaFound); Utils.checkNotNull(schemaFound);
checkCTLSchemaReadScope(schemaFound.getMetaInfo().getTenantId(), schemaFound.getMetaInfo().getApplicationId()); checkCTLSchemaReadScope(schemaFound.getMetaInfo().getTenantId(), schemaFound.getMetaInfo().getApplicationId());
switch (method) { switch (method) {
case SHALLOW: case SHALLOW:
return controlService.exportCTLSchemaShallow(schemaFound); return controlService.exportCtlSchemaShallow(schemaFound);
case FLAT: case FLAT:
return controlService.exportCTLSchemaFlat(schemaFound); return controlService.exportCtlSchemaFlat(schemaFound);
case DEEP: case DEEP:
return controlService.exportCTLSchemaDeep(schemaFound); return controlService.exportCtlSchemaDeep(schemaFound);
default: default:
throw new IllegalArgumentException("The export method " + method.name() + " is not currently supported!"); throw new IllegalArgumentException("The export method " + method.name() + " is not currently supported!");
} }
Expand Down Expand Up @@ -406,7 +406,7 @@ public CtlSchemaFormDto saveCTLSchemaForm(CtlSchemaFormDto ctlSchemaForm, Conver
Set<CTLSchemaDto> dependencies = new HashSet<>(); Set<CTLSchemaDto> dependencies = new HashSet<>();
List<FqnVersion> missingDependencies = new ArrayList<>(); List<FqnVersion> missingDependencies = new ArrayList<>();
for (FqnVersion fqnVersion : dependenciesList) { for (FqnVersion fqnVersion : dependenciesList) {
CTLSchemaDto dependency = controlService.getAnyCTLSchemaByFqnVersionTenantIdAndApplicationId( CTLSchemaDto dependency = controlService.getAnyCtlSchemaByFqnVersionTenantIdAndApplicationId(
fqnVersion.getFqnString(), fqnVersion.getVersion(), fqnVersion.getFqnString(), fqnVersion.getVersion(),
ctlSchema.getMetaInfo().getTenantId(), ctlSchema.getMetaInfo().getApplicationId()); ctlSchema.getMetaInfo().getTenantId(), ctlSchema.getMetaInfo().getApplicationId());
if (dependency != null) { if (dependency != null) {
Expand Down Expand Up @@ -444,7 +444,7 @@ public List<CtlSchemaReferenceDto> getAvailableApplicationCTLSchemaReferences(St
try { try {
AuthUserDto currentUser = getCurrentUser(); AuthUserDto currentUser = getCurrentUser();
List<CtlSchemaReferenceDto> result = new ArrayList<>(); List<CtlSchemaReferenceDto> result = new ArrayList<>();
List<CTLSchemaMetaInfoDto> availableMetaInfo = controlService.getAvailableCTLSchemasMetaInfoForApplication(currentUser.getTenantId(), applicationId); List<CTLSchemaMetaInfoDto> availableMetaInfo = controlService.getAvailableCtlSchemasMetaInfoForApplication(currentUser.getTenantId(), applicationId);
for (CTLSchemaMetaInfoDto metaInfo : availableMetaInfo) { for (CTLSchemaMetaInfoDto metaInfo : availableMetaInfo) {
for (int version : metaInfo.getVersions()) { for (int version : metaInfo.getVersions()) {
result.add(new CtlSchemaReferenceDto(metaInfo, version)); result.add(new CtlSchemaReferenceDto(metaInfo, version));
Expand All @@ -462,7 +462,7 @@ public CtlSchemaFormDto getLatestCTLSchemaForm(String metaInfoId) throws KaaAdmi
checkAuthority(KaaAuthorityDto.values()); checkAuthority(KaaAuthorityDto.values());
try { try {
this.checkCTLSchemaMetaInfoId(metaInfoId); this.checkCTLSchemaMetaInfoId(metaInfoId);
CTLSchemaDto ctlSchema = controlService.getLatestCTLSchemaByMetaInfoId(metaInfoId); CTLSchemaDto ctlSchema = controlService.getLatestCtlSchemaByMetaInfoId(metaInfoId);
Utils.checkNotNull(ctlSchema); Utils.checkNotNull(ctlSchema);
checkCTLSchemaReadScope(ctlSchema.getMetaInfo().getTenantId(), ctlSchema.getMetaInfo().getApplicationId()); checkCTLSchemaReadScope(ctlSchema.getMetaInfo().getTenantId(), ctlSchema.getMetaInfo().getApplicationId());
return toCtlSchemaForm(ctlSchema, ConverterType.FORM_AVRO_CONVERTER); return toCtlSchemaForm(ctlSchema, ConverterType.FORM_AVRO_CONVERTER);
Expand All @@ -477,7 +477,7 @@ public CtlSchemaFormDto getCTLSchemaFormByMetaInfoIdAndVer(String metaInfoId, in
try { try {
this.checkCTLSchemaMetaInfoId(metaInfoId); this.checkCTLSchemaMetaInfoId(metaInfoId);
this.checkCTLSchemaVersion(version); this.checkCTLSchemaVersion(version);
CTLSchemaDto schemaFound = controlService.getCTLSchemaByMetaInfoIdAndVer(metaInfoId, version); CTLSchemaDto schemaFound = controlService.getCtlSchemaByMetaInfoIdAndVer(metaInfoId, version);
Utils.checkNotNull(schemaFound); Utils.checkNotNull(schemaFound);
checkCTLSchemaReadScope(schemaFound.getMetaInfo().getTenantId(), schemaFound.getMetaInfo().getApplicationId()); checkCTLSchemaReadScope(schemaFound.getMetaInfo().getTenantId(), schemaFound.getMetaInfo().getApplicationId());
return toCtlSchemaForm(schemaFound, ConverterType.FORM_AVRO_CONVERTER); return toCtlSchemaForm(schemaFound, ConverterType.FORM_AVRO_CONVERTER);
Expand Down Expand Up @@ -545,7 +545,7 @@ public String prepareCTLSchemaExport(String ctlSchemaId,
CTLSchemaExportMethod method) throws KaaAdminServiceException { CTLSchemaExportMethod method) throws KaaAdminServiceException {
checkAuthority(KaaAuthorityDto.values()); checkAuthority(KaaAuthorityDto.values());
try { try {
CTLSchemaDto schemaFound = controlService.getCTLSchemaById(ctlSchemaId); CTLSchemaDto schemaFound = controlService.getCtlSchemaById(ctlSchemaId);
Utils.checkNotNull(schemaFound); Utils.checkNotNull(schemaFound);
checkCTLSchemaReadScope(schemaFound.getMetaInfo().getTenantId(), schemaFound.getMetaInfo().getApplicationId()); checkCTLSchemaReadScope(schemaFound.getMetaInfo().getTenantId(), schemaFound.getMetaInfo().getApplicationId());
CtlSchemaExportKey key = new CtlSchemaExportKey(ctlSchemaId, method); CtlSchemaExportKey key = new CtlSchemaExportKey(ctlSchemaId, method);
Expand Down Expand Up @@ -686,7 +686,7 @@ private String asText(Collection<CTLSchemaDto> types) {
public CtlSchemaReferenceDto getLastCtlSchemaReferenceDto(String ctlSchemaId) throws KaaAdminServiceException { public CtlSchemaReferenceDto getLastCtlSchemaReferenceDto(String ctlSchemaId) throws KaaAdminServiceException {
try { try {
if (!isEmpty(ctlSchemaId)) { if (!isEmpty(ctlSchemaId)) {
CTLSchemaDto ctlSchemaDto = controlService.getCTLSchemaById(ctlSchemaId); CTLSchemaDto ctlSchemaDto = controlService.getCtlSchemaById(ctlSchemaId);
CtlSchemaReferenceDto ctlSchemaReference = getAvailableApplicationCTLSchemaReferences(null).stream(). CtlSchemaReferenceDto ctlSchemaReference = getAvailableApplicationCTLSchemaReferences(null).stream().
filter(ctlSchemaReferenceDto -> ctlSchemaReferenceDto.getMetaInfo().getId().equals(ctlSchemaDto.getMetaInfo().getId())).findFirst().get(); filter(ctlSchemaReferenceDto -> ctlSchemaReferenceDto.getMetaInfo().getId().equals(ctlSchemaDto.getMetaInfo().getId())).findFirst().get();
return ctlSchemaReference; return ctlSchemaReference;
Expand Down
Expand Up @@ -137,8 +137,8 @@ private ServerProfileSchemaDto getServerProfileSchema(String applicationId, Inte
} }


private void validateServerProfile(ServerProfileSchemaDto serverProfileSchema, String serverProfileBody) throws Exception { private void validateServerProfile(ServerProfileSchemaDto serverProfileSchema, String serverProfileBody) throws Exception {
CTLSchemaDto commonType = this.controlService.getCTLSchemaById(serverProfileSchema.getCtlSchemaId()); CTLSchemaDto commonType = this.controlService.getCtlSchemaById(serverProfileSchema.getCtlSchemaId());
Schema typeSchema = this.controlService.exportCTLSchemaFlatAsSchema(commonType); Schema typeSchema = this.controlService.exportCtlSchemaFlatAsSchema(commonType);
try { try {
new GenericAvroConverter<GenericRecord>(typeSchema).decodeJson(serverProfileBody); new GenericAvroConverter<GenericRecord>(typeSchema).decodeJson(serverProfileBody);
} catch (Exception cause) { } catch (Exception cause) {
Expand Down

0 comments on commit 2b50b71

Please sign in to comment.