@Override public CompatibilityResult checkForCompatibility(SchemaMetadata schemaMetadata, String toSchemaText, String existingSchemaText) { return checkCompatibility(schemaMetadata.getType(), toSchemaText, existingSchemaText, schemaMetadata.getCompatibility()); }
public SchemaVersionInfo getSchemaVersionInfo(String schemaName, String schemaText) throws SchemaNotFoundException, InvalidSchemaException, SchemaBranchNotFoundException { SchemaMetadataInfo schemaMetadataInfo = getSchemaMetadataInfo(schemaName); if (schemaMetadataInfo == null) { throw new SchemaNotFoundException("No schema found for schema metadata key: " + schemaName); } return findSchemaVersion(SchemaBranch.MASTER_BRANCH, schemaMetadataInfo.getSchemaMetadata() .getType(), schemaText, schemaName); }
schemaMetadata.trim(); checkValueAsNullOrEmpty("Schema name", schemaMetadata.getName()); checkValueAsNullOrEmpty("Schema type", schemaMetadata.getType()); checkValidNames(schemaMetadata.getName());
public Builder(SchemaMetadata schemaMetadata) { name = schemaMetadata.getName(); type = schemaMetadata.getType(); schemaGroup = schemaMetadata.getSchemaGroup(); description = schemaMetadata.getDescription(); compatibility = schemaMetadata.getCompatibility(); validationLevel = schemaMetadata.getValidationLevel(); evolve = schemaMetadata.isEvolve(); }
public Builder(SchemaMetadata schemaMetadata) { name = schemaMetadata.getName(); type = schemaMetadata.getType(); schemaGroup = schemaMetadata.getSchemaGroup(); description = schemaMetadata.getDescription(); compatibility = schemaMetadata.getCompatibility(); validationLevel = schemaMetadata.getValidationLevel(); evolve = schemaMetadata.isEvolve(); }
schemaMetadata.trim(); checkValueAsNullOrEmpty("Schema name", schemaMetadata.getName()); checkValueAsNullOrEmpty("Schema type", schemaMetadata.getType()); checkValidNames(schemaMetadata.getName());
public Long addSchemaMetadata(SchemaMetadata schemaMetadata, boolean throwErrorIfExists) throws UnsupportedSchemaTypeException { SchemaMetadataStorable givenSchemaMetadataStorable = SchemaMetadataStorable.fromSchemaMetadataInfo(new SchemaMetadataInfo(schemaMetadata)); String type = schemaMetadata.getType(); if (schemaTypeWithProviders.get(type) == null) { throw new UnsupportedSchemaTypeException("Given schema type " + type + " not supported"); } if (!throwErrorIfExists) { Storable schemaMetadataStorable = storageManager.get(givenSchemaMetadataStorable.getStorableKey()); if (schemaMetadataStorable != null) { return schemaMetadataStorable.getId(); } } final Long nextId = storageManager.nextId(givenSchemaMetadataStorable.getNameSpace()); givenSchemaMetadataStorable.setId(nextId); givenSchemaMetadataStorable.setTimestamp(System.currentTimeMillis()); storageManager.add(givenSchemaMetadataStorable); // Add a schema branch for this metadata SchemaBranchStorable schemaBranchStorable = new SchemaBranchStorable(SchemaBranch.MASTER_BRANCH, schemaMetadata.getName(), String.format(SchemaBranch.MASTER_BRANCH_DESC, schemaMetadata.getName()), System.currentTimeMillis()); schemaBranchStorable.setId(storageManager.nextId(SchemaBranchStorable.NAME_SPACE)); storageManager.add(schemaBranchStorable); storageManager.add(new SchemaLockStorable(givenSchemaMetadataStorable.getNameSpace(), givenSchemaMetadataStorable.getName(), System.currentTimeMillis())); return givenSchemaMetadataStorable.getId(); }
SchemaVersionInfo latestSchemaVersionInfo = getLatestEnabledSchemaVersionInfo(schemaBranchName, schemaName); if (latestSchemaVersionInfo != null) { compatibilityResult = checkCompatibility(schemaMetadata.getType(), toSchema, latestSchemaVersionInfo.getSchemaText(), for (SchemaVersionInfo schemaVersionInfo : schemaVersionInfos) { if (SchemaVersionLifecycleStates.ENABLED.getId().equals(schemaVersionInfo.getStateId())) { compatibilityResult = checkCompatibility(schemaMetadata.getType(), toSchema, schemaVersionInfo.getSchemaText(),
SchemaVersionInfo existingSchemaVersionInfo = findSchemaVersion(SchemaBranch.MASTER_BRANCH, schemaMetadataInfo.getSchemaMetadata() .getType(), schemaVersionInfo.getSchemaText(), schemaMetadataInfo.getSchemaMetadata()
public SchemaIdVersion addSchemaVersion(String schemaBranchName, SchemaMetadataInfo schemaMetadataInfo, SchemaVersion schemaVersion) throws SchemaNotFoundException, IncompatibleSchemaException, InvalidSchemaException, SchemaBranchNotFoundException { Preconditions.checkNotNull(schemaBranchName, "Schema branch name can't be null"); checkSchemaText(schemaVersion.getSchemaText()); SchemaVersionInfo schemaVersionInfo; // check whether there exists schema-metadata for schema-metadata-key SchemaMetadata schemaMetadata = schemaMetadataInfo.getSchemaMetadata(); // check whether the same schema text exists schemaVersionInfo = findSchemaVersion(schemaBranchName, schemaMetadata.getType(), schemaVersion.getSchemaText(), schemaMetadataInfo .getSchemaMetadata().getName()); if (schemaVersionInfo == null) { schemaVersionInfo = createSchemaVersion(schemaBranchName, schemaMetadata, schemaMetadataInfo.getId(), schemaVersion); } return new SchemaIdVersion(schemaMetadataInfo.getId(), schemaVersionInfo.getVersion(), schemaVersionInfo.getId()); }
public static SchemaMetadataStorable updateSchemaMetadata(SchemaMetadataStorable schemaMetadataStorable, SchemaMetadata schemaMetadata) { schemaMetadataStorable.setType(schemaMetadata.getType()); schemaMetadataStorable.setSchemaGroup(schemaMetadata.getSchemaGroup()); schemaMetadataStorable.setName(schemaMetadata.getName()); schemaMetadataStorable.setDescription(schemaMetadata.getDescription()); schemaMetadataStorable.setCompatibility(schemaMetadata.getCompatibility()); schemaMetadataStorable.setValidationLevel(schemaMetadata.getValidationLevel()); schemaMetadataStorable.setEvolve(schemaMetadata.isEvolve()); return schemaMetadataStorable; }
Preconditions.checkNotNull(schemaMetadataId, "schemaMetadataId must not be null"); String type = schemaMetadata.getType(); if (getSchemaProvider(type) == null) { throw new UnsupportedSchemaTypeException("Given schema type " + type + " not supported");