@Override public LogSchemaDto getLogSchemaByApplicationIdAndVersion( String applicationId, int version) throws ControlServiceException { return logSchemaService.findLogSchemaByAppIdAndVersion(applicationId, version); }
@Override public LogSchema getLogSchema(String applicationId, int logSchemaVersion) { LOG.debug("Fetching log schema for application {} and version {}", applicationId, logSchemaVersion); LogSchema logSchema = null; LogSchemaDto logSchemaDto = logSchemaService.findLogSchemaByAppIdAndVersion( applicationId, logSchemaVersion); CTLSchemaDto ctlSchema = ctlService.findCtlSchemaById(logSchemaDto.getCtlSchemaId()); String logFlatSchema = ctlService.flatExportAsString(ctlSchema); if (logSchemaDto != null) { logSchema = new LogSchema(logSchemaDto, logFlatSchema); } return logSchema; }
@Override public FileData getRecordStructureSchema(String applicationId, int logSchemaVersion) throws ControlServiceException { ApplicationDto application = applicationService.findAppById(applicationId); if (application == null) { throw new NotFoundException("Application not found!"); } LogSchemaDto logSchema = logSchemaService .findLogSchemaByAppIdAndVersion(applicationId, logSchemaVersion); if (logSchema == null) { throw new NotFoundException("Log schema not found!"); } Schema recordWrapperSchema = null; try { CTLSchemaDto logCtlSchema = getCtlSchemaById(logSchema.getCtlSchemaId()); recordWrapperSchema = RecordWrapperSchemaGenerator .generateRecordWrapperSchema(logCtlSchema.getBody()); } catch (IOException ex) { LOG.error("Unable to get Record Structure Schema", ex); throw new ControlServiceException(ex); } String libraryFileName = MessageFormatter .arrayFormat(SCHEMA_NAME_PATTERN, new Object[] {logSchemaVersion}).getMessage(); String schemaInJson = recordWrapperSchema.toString(true); byte[] schemaData = schemaInJson.getBytes(StandardCharsets.UTF_8); FileData schema = new FileData(); schema.setFileName(libraryFileName); schema.setFileData(schemaData); return schema; }
@Override public FileData generateRecordStructureLibrary(String applicationId, int logSchemaVersion) throws ControlServiceException { ApplicationDto application = applicationService.findAppById(applicationId); if (application == null) { throw new NotFoundException("Application not found!"); } LogSchemaDto logSchema = logSchemaService.findLogSchemaByAppIdAndVersion(applicationId, logSchemaVersion); if (logSchema == null) { throw new NotFoundException("Log schema not found!"); } try { CTLSchemaDto logCtlSchema = getCtlSchemaById(logSchema.getCtlSchemaId()); Schema recordWrapperSchema = RecordWrapperSchemaGenerator .generateRecordWrapperSchema(getFlatSchemaByCtlSchemaId(logCtlSchema.getId())); String fileName = MessageFormatter.arrayFormat(LOG_SCHEMA_LIBRARY_NAME_PATTERN, new Object[] {logSchemaVersion}).getMessage(); return SchemaLibraryGenerator.generateSchemaLibrary(recordWrapperSchema, fileName); } catch (Exception ex) { LOG.error("Unable to generate Record Structure Library", ex); throw new ControlServiceException(ex); } }
.findLogSchemaByAppIdAndVersion(sdkProfile.getApplicationId(), sdkProfile.getLogSchemaVersion());