Skip to content

Commit

Permalink
replaced base configuration schema with raw schema in EndpointConfigu…
Browse files Browse the repository at this point in the history
…rationDto due to problem with empty_data_schema exception during generation of sdk
  • Loading branch information
Kirill380 committed Jul 6, 2016
1 parent 8c88888 commit fa01bb2
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 233 deletions.
Expand Up @@ -1059,20 +1059,25 @@ public void deleteProfileFilterRecord(String endpointProfileSchemaId, String ser
*/ */
@Override @Override
public FileData generateSdk(SdkProfileDto sdkProfile, SdkPlatform platform) throws ControlServiceException { public FileData generateSdk(SdkProfileDto sdkProfile, SdkPlatform platform) throws ControlServiceException {

EndpointProfileSchemaDto profileSchema = profileService.findProfileSchemaByAppIdAndVersion(sdkProfile.getApplicationId(), EndpointProfileSchemaDto profileSchema = profileService.findProfileSchemaByAppIdAndVersion(sdkProfile.getApplicationId(),
sdkProfile.getProfileSchemaVersion()); sdkProfile.getProfileSchemaVersion());
if (profileSchema == null) { if (profileSchema == null) {
throw new NotFoundException("Profile schema not found!"); throw new NotFoundException("Profile schema not found!");
} }

ConfigurationSchemaDto configurationSchema = configurationService.findConfSchemaByAppIdAndVersion(sdkProfile.getApplicationId(), ConfigurationSchemaDto configurationSchema = configurationService.findConfSchemaByAppIdAndVersion(sdkProfile.getApplicationId(),
sdkProfile.getConfigurationSchemaVersion()); sdkProfile.getConfigurationSchemaVersion());
if (configurationSchema == null) { if (configurationSchema == null) {
throw new NotFoundException("Configuration schema not found!"); throw new NotFoundException("Configuration schema not found!");
} }

ConfigurationDto defaultConfiguration = configurationService.findDefaultConfigurationBySchemaId(configurationSchema.getId()); ConfigurationDto defaultConfiguration = configurationService.findDefaultConfigurationBySchemaId(configurationSchema.getId());
if (defaultConfiguration == null) { if (defaultConfiguration == null) {
throw new NotFoundException("Default configuration not found!"); throw new NotFoundException("Default configuration not found!");
} }


NotificationSchemaDto notificationSchema = notificationService.findNotificationSchemaByAppIdAndTypeAndVersion( NotificationSchemaDto notificationSchema = notificationService.findNotificationSchemaByAppIdAndTypeAndVersion(
sdkProfile.getApplicationId(), NotificationTypeDto.USER, sdkProfile.getNotificationSchemaVersion()); sdkProfile.getApplicationId(), NotificationTypeDto.USER, sdkProfile.getNotificationSchemaVersion());
if (notificationSchema == null) { if (notificationSchema == null) {
Expand All @@ -1085,18 +1090,30 @@ public FileData generateSdk(SdkProfileDto sdkProfile, SdkPlatform platform) thro
throw new NotFoundException("Log schema not found!"); throw new NotFoundException("Log schema not found!");
} }



CTLSchemaDto profileCtlSchema = ctlService.findCTLSchemaById(profileSchema.getCtlSchemaId()); CTLSchemaDto profileCtlSchema = ctlService.findCTLSchemaById(profileSchema.getCtlSchemaId());
if (profileCtlSchema == null) { if (profileCtlSchema == null) {
throw new NotFoundException("Profile CTL schema not found!"); throw new NotFoundException("Profile CTL schema not found!");
} }

CTLSchemaDto confCtlSchema = ctlService.findCTLSchemaById(configurationSchema.getCtlSchemaId());
if (confCtlSchema == null) {
throw new NotFoundException("Configuration CTL schema not found!");
}


String profileSchemaBodyString = ctlService.flatExportAsString(profileCtlSchema); String profileSchemaBodyString = ctlService.flatExportAsString(profileCtlSchema);
String confSchemaBodyString = ctlService.flatExportAsString(confCtlSchema);


DataSchema profileDataSchema = new DataSchema(profileSchemaBodyString); DataSchema profileDataSchema = new DataSchema(profileSchemaBodyString);
DataSchema confDataSchema = new DataSchema(confSchemaBodyString);
DataSchema notificationDataSchema = new DataSchema(notificationSchema.getSchema()); DataSchema notificationDataSchema = new DataSchema(notificationSchema.getSchema());
ProtocolSchema protocolSchema = new ProtocolSchema(configurationSchema.getProtocolSchema()); ProtocolSchema protocolSchema = new ProtocolSchema(configurationSchema.getProtocolSchema());
DataSchema logDataSchema = new DataSchema(logSchema.getSchema()); DataSchema logDataSchema = new DataSchema(logSchema.getSchema());


String profileSchemaBody = profileDataSchema.getRawSchema(); String profileSchemaBody = profileDataSchema.getRawSchema();
String confSchemaBody = confDataSchema.getRawSchema();



byte[] defaultConfigurationData = GenericAvroConverter.toRawData(defaultConfiguration.getBody(), byte[] defaultConfigurationData = GenericAvroConverter.toRawData(defaultConfiguration.getBody(),
configurationSchema.getBaseSchema()); configurationSchema.getBaseSchema());
Expand Down Expand Up @@ -1131,7 +1148,7 @@ public FileData generateSdk(SdkProfileDto sdkProfile, SdkPlatform platform) thro
try { try {
sdkFile = generator.generateSdk(Version.PROJECT_VERSION, controlZKService.getCurrentBootstrapNodes(), sdkProfile, sdkFile = generator.generateSdk(Version.PROJECT_VERSION, controlZKService.getCurrentBootstrapNodes(), sdkProfile,
profileSchemaBody, notificationDataSchema.getRawSchema(), protocolSchema.getRawSchema(), profileSchemaBody, notificationDataSchema.getRawSchema(), protocolSchema.getRawSchema(),
configurationSchema.getBaseSchema(), defaultConfigurationData, eventFamilies, logDataSchema.getRawSchema()); confSchemaBody, defaultConfigurationData, eventFamilies, logDataSchema.getRawSchema());
} catch (Exception e) { } catch (Exception e) {
LOG.error("Unable to generate SDK", e); LOG.error("Unable to generate SDK", e);
throw new ControlServiceException(e); throw new ControlServiceException(e);
Expand Down

0 comments on commit fa01bb2

Please sign in to comment.