private void validateAndNormalize(AtlasRelationship relationship) throws AtlasBaseException { List<String> messages = new ArrayList<>(); if (! AtlasTypeUtil.isValidGuid(relationship.getGuid())) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_GUID_NOT_FOUND, relationship.getGuid()); } AtlasRelationshipType type = typeRegistry.getRelationshipTypeByName(relationship.getTypeName()); if (type == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.RELATIONSHIP.name(), relationship.getTypeName()); } type.validateValue(relationship, relationship.getTypeName(), messages); if (!messages.isEmpty()) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_CRUD_INVALID_PARAMS, messages); } type.getNormalizedValue(relationship); }
private void validateAndNormalize(AtlasRelationship relationship) throws AtlasBaseException { List<String> messages = new ArrayList<>(); if (! AtlasTypeUtil.isValidGuid(relationship.getGuid())) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_GUID_NOT_FOUND, relationship.getGuid()); } AtlasRelationshipType type = typeRegistry.getRelationshipTypeByName(relationship.getTypeName()); if (type == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.RELATIONSHIP.name(), relationship.getTypeName()); } type.validateValue(relationship, relationship.getTypeName(), messages); if (!messages.isEmpty()) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_CRUD_INVALID_PARAMS, messages); } type.getNormalizedValue(relationship); }
private void validateRelationship(AtlasVertex end1Vertex, AtlasVertex end2Vertex, String relationshipName, Map<String, Object> attributes) throws AtlasBaseException { AtlasRelationshipType relationshipType = typeRegistry.getRelationshipTypeByName(relationshipName); if (relationshipType == null) { throw new AtlasBaseException(AtlasErrorCode.INVALID_VALUE, "unknown relationship type'" + relationshipName + "'"); } if (end1Vertex == null) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_END_IS_NULL, relationshipType.getEnd1Type().getTypeName()); } if (end2Vertex == null) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_END_IS_NULL, relationshipType.getEnd2Type().getTypeName()); } String end1TypeName = AtlasGraphUtilsV2.getTypeName(end1Vertex); String end2TypeName = AtlasGraphUtilsV2.getTypeName(end2Vertex); boolean validEndTypes = false; if (relationshipType.getEnd1Type().isTypeOrSuperTypeOf(end1TypeName)) { validEndTypes = relationshipType.getEnd2Type().isTypeOrSuperTypeOf(end2TypeName); } else if (relationshipType.getEnd2Type().isTypeOrSuperTypeOf(end1TypeName)) { validEndTypes = relationshipType.getEnd1Type().isTypeOrSuperTypeOf(end2TypeName); } if (!validEndTypes) { throw new AtlasBaseException(AtlasErrorCode.INVALID_RELATIONSHIP_END_TYPE, relationshipName, relationshipType.getEnd2Type().getTypeName(), end1TypeName); } List<String> messages = new ArrayList<>(); AtlasRelationship relationship = new AtlasRelationship(relationshipName, attributes); relationshipType.validateValue(relationship, relationshipName, messages); if (!messages.isEmpty()) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_CRUD_INVALID_PARAMS, messages); } relationshipType.getNormalizedValue(relationship); }
private void validateRelationship(AtlasVertex end1Vertex, AtlasVertex end2Vertex, String relationshipName, Map<String, Object> attributes) throws AtlasBaseException { AtlasRelationshipType relationshipType = typeRegistry.getRelationshipTypeByName(relationshipName); if (relationshipType == null) { throw new AtlasBaseException(AtlasErrorCode.INVALID_VALUE, "unknown relationship type'" + relationshipName + "'"); } if (end1Vertex == null) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_END_IS_NULL, relationshipType.getEnd1Type().getTypeName()); } if (end2Vertex == null) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_END_IS_NULL, relationshipType.getEnd2Type().getTypeName()); } String end1TypeName = AtlasGraphUtilsV2.getTypeName(end1Vertex); String end2TypeName = AtlasGraphUtilsV2.getTypeName(end2Vertex); boolean validEndTypes = false; if (relationshipType.getEnd1Type().isTypeOrSuperTypeOf(end1TypeName)) { validEndTypes = relationshipType.getEnd2Type().isTypeOrSuperTypeOf(end2TypeName); } else if (relationshipType.getEnd2Type().isTypeOrSuperTypeOf(end1TypeName)) { validEndTypes = relationshipType.getEnd1Type().isTypeOrSuperTypeOf(end2TypeName); } if (!validEndTypes) { throw new AtlasBaseException(AtlasErrorCode.INVALID_RELATIONSHIP_END_TYPE, relationshipName, relationshipType.getEnd2Type().getTypeName(), end1TypeName); } List<String> messages = new ArrayList<>(); AtlasRelationship relationship = new AtlasRelationship(relationshipName, attributes); relationshipType.validateValue(relationship, relationshipName, messages); if (!messages.isEmpty()) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_CRUD_INVALID_PARAMS, messages); } relationshipType.getNormalizedValue(relationship); }