/** * Updates the current context into the schema version state storage. * * @throws SchemaLifecycleException when any error occurs while updating the state. * @throws SchemaNotFoundException when there is no schema/version found with the given {@code schemaVersionId}. */ public void updateSchemaVersionState() throws SchemaLifecycleException, SchemaNotFoundException { schemaVersionService.updateSchemaVersionState(this); }
SchemaVersionService schemaVersionService = context.getSchemaVersionService(); SchemaMetadataInfo schemaMetadataInfo = schemaVersionService.getSchemaMetadata(schemaVersionId); SchemaMetadata schemaMetadata = schemaMetadataInfo.getSchemaMetadata(); String schemaName = schemaMetadata.getName(); SchemaValidationLevel validationLevel = schemaMetadata.getValidationLevel(); SchemaVersionInfo schemaVersionInfo = schemaVersionService.getSchemaVersionInfo(schemaVersionId); int schemaVersion = schemaVersionInfo.getVersion(); String schemaText = schemaVersionInfo.getSchemaText(); List<SchemaVersionInfo> allEnabledSchemaVersions = schemaVersionService.getAllSchemaVersions(SchemaBranch.MASTER_BRANCH, schemaName) .stream() .filter(x -> SchemaVersionLifecycleStates.ENABLED.getId().equals(x.getStateId()))
private static void transitionToDeleteState(SchemaVersionLifecycleContext context) throws SchemaLifecycleException, SchemaNotFoundException { context.setState(DELETED); context.updateSchemaVersionState(); context.getSchemaVersionService().deleteSchemaVersion(context.getSchemaVersionId()); }
private static void checkCompatibility(SchemaVersionService schemaVersionService, SchemaMetadata schemaMetadata, String toSchemaText, String fromSchemaText) throws IncompatibleSchemaException { CompatibilityResult compatibilityResult = schemaVersionService.checkForCompatibility(schemaMetadata, toSchemaText, fromSchemaText); if (!compatibilityResult.isCompatible()) { String errMsg = String.format("Given schema is not compatible with latest schema versions. \n" + "Error location: [%s] \n" + "Error encountered is: [%s]", compatibilityResult.getErrorLocation(), compatibilityResult.getErrorMessage()); throw new IncompatibleSchemaException(errMsg); } }
SchemaVersionService schemaVersionService = context.getSchemaVersionService(); SchemaMetadataInfo schemaMetadataInfo = schemaVersionService.getSchemaMetadata(schemaVersionId); SchemaMetadata schemaMetadata = schemaMetadataInfo.getSchemaMetadata(); String schemaName = schemaMetadata.getName(); SchemaValidationLevel validationLevel = schemaMetadata.getValidationLevel(); SchemaVersionInfo schemaVersionInfo = schemaVersionService.getSchemaVersionInfo(schemaVersionId); int schemaVersion = schemaVersionInfo.getVersion(); String schemaText = schemaVersionInfo.getSchemaText(); List<SchemaVersionInfo> allEnabledSchemaVersions = schemaVersionService.getAllSchemaVersions(SchemaBranch.MASTER_BRANCH, schemaName) .stream() .filter(x -> SchemaVersionLifecycleStates.ENABLED.getId().equals(x.getStateId()))
private static void transitionToDeleteState(SchemaVersionLifecycleContext context) throws SchemaLifecycleException, SchemaNotFoundException { context.setState(DELETED); context.updateSchemaVersionState(); context.getSchemaVersionService().deleteSchemaVersion(context.getSchemaVersionId()); }
private static void checkCompatibility(SchemaVersionService schemaVersionService, SchemaMetadata schemaMetadata, String toSchemaText, String fromSchemaText) throws IncompatibleSchemaException { CompatibilityResult compatibilityResult = schemaVersionService.checkForCompatibility(schemaMetadata, toSchemaText, fromSchemaText); if (!compatibilityResult.isCompatible()) { String errMsg = String.format("Given schema is not compatible with latest schema versions. \n" + "Error location: [%s] \n" + "Error encountered is: [%s]", compatibilityResult.getErrorLocation(), compatibilityResult.getErrorMessage()); throw new IncompatibleSchemaException(errMsg); } }
/** * Updates the current context into the schema version state storage. * * @throws SchemaLifecycleException when any error occurs while updating the state. * @throws SchemaNotFoundException when there is no schema/version found with the given {@code schemaVersionId}. */ public void updateSchemaVersionState() throws SchemaLifecycleException, SchemaNotFoundException { schemaVersionService.updateSchemaVersionState(this); }