Java Code Examples for org.apache.atlas.AtlasErrorCode#TYPE_NAME_INVALID
The following examples show how to use
org.apache.atlas.AtlasErrorCode#TYPE_NAME_INVALID .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AtlasEntityGraphDiscoveryV1.java From incubator-atlas with Apache License 2.0 | 6 votes |
@Override public void validateAndNormalize(AtlasEntity entity) throws AtlasBaseException { List<String> messages = new ArrayList<>(); if (! AtlasTypeUtil.isValidGuid(entity.getGuid())) { throw new AtlasBaseException(AtlasErrorCode.INVALID_OBJECT_ID, "invalid guid " + entity.getGuid()); } AtlasEntityType type = typeRegistry.getEntityTypeByName(entity.getTypeName()); if (type == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.ENTITY.name(), entity.getTypeName()); } type.validateValue(entity, entity.getTypeName(), messages); if (!messages.isEmpty()) { throw new AtlasBaseException(AtlasErrorCode.INSTANCE_CRUD_INVALID_PARAMS, messages); } type.getNormalizedValue(entity); }
Example 2
Source File: AtlasRelationshipStoreV1.java From incubator-atlas with Apache License 2.0 | 6 votes |
private void mapAttributes(AtlasEdge edge, AtlasRelationship relationship) throws AtlasBaseException { AtlasType objType = typeRegistry.getType(relationship.getTypeName()); if (!(objType instanceof AtlasRelationshipType)) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, relationship.getTypeName()); } AtlasRelationshipType relationshipType = (AtlasRelationshipType) objType; for (AtlasAttribute attribute : relationshipType.getAllAttributes().values()) { // mapping only primitive attributes Object attrValue = entityRetriever.mapVertexToPrimitive(edge, attribute.getQualifiedName(), attribute.getAttributeDef()); relationship.setAttribute(attribute.getName(), attrValue); } }
Example 3
Source File: AtlasEntityGraphDiscoveryV2.java From atlas with Apache License 2.0 | 6 votes |
@Override public void validateAndNormalizeForUpdate(AtlasEntity entity) throws AtlasBaseException { List<String> messages = new ArrayList<>(); if (!AtlasTypeUtil.isValidGuid(entity.getGuid())) { throw new AtlasBaseException(AtlasErrorCode.INVALID_OBJECT_ID, "invalid guid " + entity.getGuid()); } AtlasEntityType type = typeRegistry.getEntityTypeByName(entity.getTypeName()); if (type == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.ENTITY.name(), entity.getTypeName()); } validateCustomAttributes(entity); validateLabels(entity.getLabels()); type.validateValueForUpdate(entity, entity.getTypeName(), messages); if (!messages.isEmpty()) { throw new AtlasBaseException(AtlasErrorCode.INSTANCE_CRUD_INVALID_PARAMS, messages); } type.getNormalizedValueForUpdate(entity); }
Example 4
Source File: AtlasInstanceConverter.java From atlas with Apache License 2.0 | 6 votes |
public AtlasEntitiesWithExtInfo toAtlasEntities(String[] jsonEntities) throws AtlasBaseException, AtlasException { Referenceable[] referenceables = new Referenceable[jsonEntities.length]; for (int i = 0; i < jsonEntities.length; i++) { referenceables[i] = AtlasType.fromV1Json(jsonEntities[i], Referenceable.class); } AtlasEntityFormatConverter converter = (AtlasEntityFormatConverter) instanceFormatters.getConverter(TypeCategory.ENTITY); ConverterContext context = new ConverterContext(); for (Referenceable referenceable : referenceables) { AtlasEntityType entityType = typeRegistry.getEntityTypeByName(referenceable.getTypeName()); if (entityType == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.ENTITY.name(), referenceable.getTypeName()); } AtlasEntity entity = converter.fromV1ToV2(referenceable, entityType, context); context.addEntity(entity); } AtlasEntitiesWithExtInfo ret = context.getEntities(); return ret; }
Example 5
Source File: AtlasEntityGraphDiscoveryV1.java From incubator-atlas with Apache License 2.0 | 6 votes |
@Override public void validateAndNormalizeForUpdate(AtlasEntity entity) throws AtlasBaseException { List<String> messages = new ArrayList<>(); if (! AtlasTypeUtil.isValidGuid(entity.getGuid())) { throw new AtlasBaseException(AtlasErrorCode.INVALID_OBJECT_ID, "invalid guid " + entity.getGuid()); } AtlasEntityType type = typeRegistry.getEntityTypeByName(entity.getTypeName()); if (type == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.ENTITY.name(), entity.getTypeName()); } type.validateValueForUpdate(entity, entity.getTypeName(), messages); if (!messages.isEmpty()) { throw new AtlasBaseException(AtlasErrorCode.INSTANCE_CRUD_INVALID_PARAMS, messages); } type.getNormalizedValueForUpdate(entity); }
Example 6
Source File: AtlasRelationshipStoreV2.java From atlas with Apache License 2.0 | 6 votes |
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); }
Example 7
Source File: AtlasRelationshipStoreV1.java From incubator-atlas with Apache License 2.0 | 6 votes |
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); }
Example 8
Source File: EntityGraphRetriever.java From atlas with Apache License 2.0 | 6 votes |
private void mapAttributes(AtlasEdge edge, AtlasRelationshipWithExtInfo relationshipWithExtInfo) throws AtlasBaseException { AtlasRelationship relationship = relationshipWithExtInfo.getRelationship(); AtlasType objType = typeRegistry.getType(relationship.getTypeName()); if (!(objType instanceof AtlasRelationshipType)) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, relationship.getTypeName()); } AtlasRelationshipType relationshipType = (AtlasRelationshipType) objType; for (AtlasAttribute attribute : relationshipType.getAllAttributes().values()) { // mapping only primitive attributes Object attrValue = mapVertexToPrimitive(edge, attribute.getVertexPropertyName(), attribute.getAttributeDef()); relationship.setAttribute(attribute.getName(), attrValue); } }
Example 9
Source File: EntityGraphRetriever.java From atlas with Apache License 2.0 | 5 votes |
private void mapRelationshipAttributes(AtlasVertex entityVertex, AtlasEntity entity, AtlasEntityExtInfo entityExtInfo, boolean isMinExtInfo) throws AtlasBaseException { AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entity.getTypeName()); if (entityType == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, entity.getTypeName()); } for (String attributeName : entityType.getRelationshipAttributes().keySet()) { mapVertexToRelationshipAttribute(entityVertex, entityType, attributeName, entity, entityExtInfo, isMinExtInfo); } }
Example 10
Source File: IDBasedEntityResolver.java From atlas with Apache License 2.0 | 5 votes |
public EntityGraphDiscoveryContext resolveEntityReferences(EntityGraphDiscoveryContext context) throws AtlasBaseException { if (context == null) { throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, "IDBasedEntityResolver.resolveEntityReferences(): context is null"); } EntityStream entityStream = context.getEntityStream(); for (String guid : context.getReferencedGuids()) { boolean isAssignedGuid = AtlasTypeUtil.isAssignedGuid(guid); AtlasVertex vertex = isAssignedGuid ? AtlasGraphUtilsV2.findByGuid(this.graph, guid) : null; if (vertex == null && !RequestContext.get().isImportInProgress()) { // if not found in the store, look if the entity is present in the stream AtlasEntity entity = entityStream.getByGuid(guid); if (entity != null) { // look for the entity in the store using unique-attributes AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entity.getTypeName()); if (entityType == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.ENTITY.name(), entity.getTypeName()); } vertex = AtlasGraphUtilsV2.findByUniqueAttributes(this.graph, entityType, entity.getAttributes()); } else if (!isAssignedGuid) { // for local-guids, entity must be in the stream throw new AtlasBaseException(AtlasErrorCode.REFERENCED_ENTITY_NOT_FOUND, guid); } } if (vertex != null) { context.addResolvedGuid(guid, vertex); } else { if (isAssignedGuid && !RequestContext.get().isImportInProgress()) { throw new AtlasBaseException(AtlasErrorCode.REFERENCED_ENTITY_NOT_FOUND, guid); } else { context.addLocalGuidReference(guid); } } } return context; }
Example 11
Source File: AtlasInstanceConverter.java From incubator-atlas with Apache License 2.0 | 5 votes |
public AtlasClassification getClassification(IStruct classification) throws AtlasBaseException { AtlasFormatConverter converter = instanceFormatters.getConverter(TypeCategory.CLASSIFICATION); AtlasClassificationType classificationType = typeRegistry.getClassificationTypeByName(classification.getTypeName()); if (classificationType == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.CLASSIFICATION.name(), classification.getTypeName()); } AtlasClassification ret = (AtlasClassification)converter.fromV1ToV2(classification, classificationType, new AtlasFormatConverter.ConverterContext()); return ret; }
Example 12
Source File: EntityGraphMapper.java From atlas with Apache License 2.0 | 5 votes |
private AtlasStructType getStructType(String typeName) throws AtlasBaseException { AtlasType objType = typeRegistry.getType(typeName); if (!(objType instanceof AtlasStructType)) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, typeName); } return (AtlasStructType)objType; }
Example 13
Source File: EntityREST.java From incubator-atlas with Apache License 2.0 | 5 votes |
private AtlasClassificationType ensureClassificationType(String typeName) throws AtlasBaseException { AtlasClassificationType ret = typeRegistry.getClassificationTypeByName(typeName); if (ret == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.CLASSIFICATION.name(), typeName); } return ret; }
Example 14
Source File: UniqAttrBasedEntityResolver.java From atlas with Apache License 2.0 | 5 votes |
@Override public EntityGraphDiscoveryContext resolveEntityReferences(EntityGraphDiscoveryContext context) throws AtlasBaseException { if (context == null) { throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, "UniqAttrBasedEntityResolver.resolveEntityReferences(): context is null"); } //Resolve attribute references List<AtlasObjectId> resolvedReferences = new ArrayList<>(); for (AtlasObjectId objId : context.getReferencedByUniqAttribs()) { //query in graph repo that given unique attribute - check for deleted also? AtlasEntityType entityType = typeRegistry.getEntityTypeByName(objId.getTypeName()); if (entityType == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.ENTITY.name(), objId.getTypeName()); } AtlasVertex vertex = AtlasGraphUtilsV2.findByUniqueAttributes(this.graph, entityType, objId.getUniqueAttributes()); if (vertex == null && RequestContext.get().isCreateShellEntityForNonExistingReference()) { vertex = entityGraphMapper.createShellEntityVertex(objId, context); } if (vertex != null) { context.addResolvedIdByUniqAttribs(objId, vertex); resolvedReferences.add(objId); } else { throw new AtlasBaseException(AtlasErrorCode.REFERENCED_ENTITY_NOT_FOUND, objId.toString()); } } return context; }
Example 15
Source File: EntityGraphRetriever.java From incubator-atlas with Apache License 2.0 | 5 votes |
private void mapRelationshipAttributes(AtlasVertex entityVertex, AtlasEntity entity) throws AtlasBaseException { AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entity.getTypeName()); if (entityType == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, entity.getTypeName()); } for (AtlasAttribute attribute : entityType.getRelationshipAttributes().values()) { Object attrValue = mapVertexToRelationshipAttribute(entityVertex, entityType, attribute); entity.setRelationshipAttribute(attribute.getName(), attrValue); } }
Example 16
Source File: UniqAttrBasedEntityResolver.java From incubator-atlas with Apache License 2.0 | 5 votes |
@Override public EntityGraphDiscoveryContext resolveEntityReferences(EntityGraphDiscoveryContext context) throws AtlasBaseException { if (context == null) { throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, "UniqAttrBasedEntityResolver.resolveEntityReferences(): context is null"); } //Resolve attribute references List<AtlasObjectId> resolvedReferences = new ArrayList<>(); for (AtlasObjectId objId : context.getReferencedByUniqAttribs()) { //query in graph repo that given unique attribute - check for deleted also? AtlasEntityType entityType = typeRegistry.getEntityTypeByName(objId.getTypeName()); if (entityType == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.ENTITY.name(), objId.getTypeName()); } AtlasVertex vertex = AtlasGraphUtilsV1.findByUniqueAttributes(entityType, objId.getUniqueAttributes()); if (vertex != null) { context.addResolvedIdByUniqAttribs(objId, vertex); resolvedReferences.add(objId); } else { throw new AtlasBaseException(AtlasErrorCode.REFERENCED_ENTITY_NOT_FOUND, objId.toString()); } } return context; }
Example 17
Source File: EntityGraphMapper.java From incubator-atlas with Apache License 2.0 | 5 votes |
private AtlasEntityType getEntityType(String typeName) throws AtlasBaseException { AtlasType objType = typeRegistry.getType(typeName); if (!(objType instanceof AtlasEntityType)) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, typeName); } return (AtlasEntityType)objType; }
Example 18
Source File: EntityREST.java From atlas with Apache License 2.0 | 5 votes |
private AtlasClassificationType ensureClassificationType(String typeName) throws AtlasBaseException { AtlasClassificationType ret = typeRegistry.getClassificationTypeByName(typeName); if (ret == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.CLASSIFICATION.name(), typeName); } return ret; }
Example 19
Source File: EntityREST.java From atlas with Apache License 2.0 | 5 votes |
private AtlasEntityType ensureEntityType(String typeName) throws AtlasBaseException { AtlasEntityType ret = typeRegistry.getEntityTypeByName(typeName); if (ret == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.ENTITY.name(), typeName); } return ret; }
Example 20
Source File: AtlasEntityStoreV2.java From atlas with Apache License 2.0 | 4 votes |
private EntityMutationContext preCreateOrUpdate(EntityStream entityStream, EntityGraphMapper entityGraphMapper, boolean isPartialUpdate) throws AtlasBaseException { MetricRecorder metric = RequestContext.get().startMetricRecord("preCreateOrUpdate"); EntityGraphDiscovery graphDiscoverer = new AtlasEntityGraphDiscoveryV2(graph, typeRegistry, entityStream, entityGraphMapper); EntityGraphDiscoveryContext discoveryContext = graphDiscoverer.discoverEntities(); EntityMutationContext context = new EntityMutationContext(discoveryContext); RequestContext requestContext = RequestContext.get(); for (String guid : discoveryContext.getReferencedGuids()) { AtlasEntity entity = entityStream.getByGuid(guid); if (entity != null) { // entity would be null if guid is not in the stream but referenced by an entity in the stream AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entity.getTypeName()); if (entityType == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.ENTITY.name(), entity.getTypeName()); } compactAttributes(entity, entityType); AtlasVertex vertex = getResolvedEntityVertex(discoveryContext, entity); if (vertex != null) { if (!isPartialUpdate) { graphDiscoverer.validateAndNormalize(entity); // change entity 'isInComplete' to 'false' during full update if (isEntityIncomplete(vertex)) { vertex.removeProperty(IS_INCOMPLETE_PROPERTY_KEY); entity.setIsIncomplete(FALSE); } } else { graphDiscoverer.validateAndNormalizeForUpdate(entity); } String guidVertex = AtlasGraphUtilsV2.getIdFromVertex(vertex); if (!StringUtils.equals(guidVertex, guid)) { // if entity was found by unique attribute entity.setGuid(guidVertex); requestContext.recordEntityGuidUpdate(entity, guid); } context.addUpdated(guid, entity, entityType, vertex); } else { graphDiscoverer.validateAndNormalize(entity); //Create vertices which do not exist in the repository if (RequestContext.get().isImportInProgress() && AtlasTypeUtil.isAssignedGuid(entity.getGuid())) { vertex = entityGraphMapper.createVertexWithGuid(entity, entity.getGuid()); } else { vertex = entityGraphMapper.createVertex(entity); } discoveryContext.addResolvedGuid(guid, vertex); discoveryContext.addResolvedIdByUniqAttribs(getAtlasObjectId(entity), vertex); String generatedGuid = AtlasGraphUtilsV2.getIdFromVertex(vertex); entity.setGuid(generatedGuid); requestContext.recordEntityGuidUpdate(entity, guid); context.addCreated(guid, entity, entityType, vertex); } // during import, update the system attributes if (RequestContext.get().isImportInProgress()) { Status newStatus = entity.getStatus(); if (newStatus != null) { Status currStatus = AtlasGraphUtilsV2.getState(vertex); if (currStatus == Status.ACTIVE && newStatus == Status.DELETED) { if (LOG.isDebugEnabled()) { LOG.debug("entity-delete via import - guid={}", guid); } context.addEntityToDelete(vertex); } else if (currStatus == Status.DELETED && newStatus == Status.ACTIVE) { LOG.warn("Import is attempting to activate deleted entity (guid={}).", guid); entityGraphMapper.importActivateEntity(vertex, entity); context.addCreated(guid, entity, entityType, vertex); } } entityGraphMapper.updateSystemAttributes(vertex, entity); } } } RequestContext.get().endMetricRecord(metric); return context; }