Java Code Examples for org.apache.atlas.AtlasErrorCode#INTERNAL_ERROR
The following examples show how to use
org.apache.atlas.AtlasErrorCode#INTERNAL_ERROR .
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: EntityGraphMapper.java From incubator-atlas with Apache License 2.0 | 6 votes |
private AtlasEdge updateEdge(AtlasAttributeDef attributeDef, Object value, AtlasEdge currentEdge, final AtlasVertex entityVertex) throws AtlasBaseException { LOG.debug("Updating entity reference {} for reference attribute {}", attributeDef.getName()); // Update edge if it exists AtlasVertex currentVertex = currentEdge.getInVertex(); String currentEntityId = getIdFromVertex(currentVertex); String newEntityId = getIdFromVertex(entityVertex); AtlasEdge newEdge = currentEdge; if (!currentEntityId.equals(newEntityId)) { // add an edge to the class vertex from the instance if (entityVertex != null) { try { newEdge = graphHelper.getOrCreateEdge(currentEdge.getOutVertex(), entityVertex, currentEdge.getLabel()); } catch (RepositoryException e) { throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, e); } } } return newEdge; }
Example 2
Source File: EntityGraphMapper.java From incubator-atlas with Apache License 2.0 | 6 votes |
private AtlasEdge createInverseReference(AtlasAttribute inverseAttribute, AtlasStructType inverseAttributeType, AtlasVertex inverseVertex, AtlasVertex vertex) throws AtlasBaseException { String propertyName = AtlasGraphUtilsV1.getQualifiedAttributePropertyKey(inverseAttributeType, inverseAttribute.getName()); String inverseEdgeLabel = AtlasGraphUtilsV1.getEdgeLabel(propertyName); AtlasEdge ret; try { ret = graphHelper.getOrCreateEdge(inverseVertex, vertex, inverseEdgeLabel); } catch (RepositoryException e) { throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, e); } return ret; }
Example 3
Source File: EntityGraphMapper.java From atlas with Apache License 2.0 | 6 votes |
private AtlasEdge createInverseReference(AtlasAttribute inverseAttribute, AtlasStructType inverseAttributeType, AtlasVertex inverseVertex, AtlasVertex vertex) throws AtlasBaseException { String propertyName = AtlasGraphUtilsV2.getQualifiedAttributePropertyKey(inverseAttributeType, inverseAttribute.getName()); String inverseEdgeLabel = AtlasGraphUtilsV2.getEdgeLabel(propertyName); AtlasEdge ret; try { ret = graphHelper.getOrCreateEdge(inverseVertex, vertex, inverseEdgeLabel); } catch (RepositoryException e) { throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, e); } return ret; }
Example 4
Source File: AtlasAbstractDefStoreV1.java From incubator-atlas with Apache License 2.0 | 6 votes |
public void validateType(AtlasBaseTypeDef typeDef) throws AtlasBaseException { if (!isValidName(typeDef.getName())) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID_FORMAT, typeDef.getName(), typeDef.getCategory().name()); } try { final boolean allowReservedKeywords = ApplicationProperties.get().getBoolean(ALLOW_RESERVED_KEYWORDS, true); if (!allowReservedKeywords && typeDef instanceof AtlasStructDef) { final List<AtlasStructDef.AtlasAttributeDef> attributeDefs = ((AtlasStructDef) typeDef).getAttributeDefs(); for (AtlasStructDef.AtlasAttributeDef attrDef : attributeDefs) { if (QueryParser.isKeyword(attrDef.getName())) { throw new AtlasBaseException(AtlasErrorCode.ATTRIBUTE_NAME_INVALID, attrDef.getName(), typeDef.getCategory().name()); } } } } catch (AtlasException e) { LOG.error("Exception while loading configuration ", e); throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, "Could not load configuration"); } }
Example 5
Source File: EntityGraphMapper.java From atlas with Apache License 2.0 | 6 votes |
private AtlasEdge updateEdge(AtlasAttributeDef attributeDef, Object value, AtlasEdge currentEdge, final AtlasVertex entityVertex) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("Updating entity reference {} for reference attribute {}", attributeDef.getName()); } AtlasVertex currentVertex = currentEdge.getInVertex(); String currentEntityId = getIdFromVertex(currentVertex); String newEntityId = getIdFromVertex(entityVertex); AtlasEdge newEdge = currentEdge; if (!currentEntityId.equals(newEntityId) && entityVertex != null) { try { newEdge = graphHelper.getOrCreateEdge(currentEdge.getOutVertex(), entityVertex, currentEdge.getLabel()); } catch (RepositoryException e) { throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, e); } } return newEdge; }
Example 6
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 7
Source File: AtlasRelationshipStoreV1.java From incubator-atlas with Apache License 2.0 | 5 votes |
private AtlasRelationship createRelationship(AtlasRelationship relationship, AtlasVertex end1Vertex, AtlasVertex end2Vertex) throws AtlasBaseException { AtlasRelationship ret; try { AtlasEdge relationshipEdge = getRelationshipEdge(end1Vertex, end2Vertex, relationship); if (relationshipEdge == null) { relationshipEdge = createRelationshipEdge(end1Vertex, end2Vertex, relationship); AtlasRelationshipType relationType = typeRegistry.getRelationshipTypeByName(relationship.getTypeName()); if (MapUtils.isNotEmpty(relationType.getAllAttributes())) { for (AtlasAttribute attr : relationType.getAllAttributes().values()) { String attrName = attr.getName(); String attrVertexProperty = attr.getVertexPropertyName(); Object attrValue = relationship.getAttribute(attrName); AtlasGraphUtilsV1.setProperty(relationshipEdge, attrVertexProperty, attrValue); } } ret = mapEdgeToAtlasRelationship(relationshipEdge); } else { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_ALREADY_EXISTS, relationship.getTypeName(), relationship.getEnd1().getGuid(), relationship.getEnd2().getGuid()); } } catch (RepositoryException e) { throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, e); } return ret; }
Example 8
Source File: IDBasedEntityResolver.java From incubator-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 ? AtlasGraphUtilsV1.findByGuid(guid) : null; if (vertex == null && !(entityStream instanceof EntityImportStream)) { // 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 = AtlasGraphUtilsV1.findByUniqueAttributes(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 && !(entityStream instanceof EntityImportStream)) { throw new AtlasBaseException(AtlasErrorCode.REFERENCED_ENTITY_NOT_FOUND, guid); } else { context.addLocalGuidReference(guid); } } } return context; }
Example 9
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 10
Source File: EntityGraphMapper.java From atlas with Apache License 2.0 | 5 votes |
private AtlasEdge createVertex(AtlasStruct struct, AtlasVertex referringVertex, String edgeLabel, EntityMutationContext context) throws AtlasBaseException { AtlasVertex vertex = createStructVertex(struct); mapAttributes(struct, vertex, CREATE, context); try { //TODO - Map directly in AtlasGraphUtilsV1 return graphHelper.getOrCreateEdge(referringVertex, vertex, edgeLabel); } catch (RepositoryException e) { throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, e); } }
Example 11
Source File: EntityGraphMapper.java From incubator-atlas with Apache License 2.0 | 5 votes |
private AtlasEdge mapClassification(EntityOperation operation, final EntityMutationContext context, AtlasClassification classification, AtlasEntityType entityType, AtlasVertex parentInstanceVertex, AtlasVertex traitInstanceVertex) throws AtlasBaseException { // map all the attributes to this newly created AtlasVertex mapAttributes(classification, traitInstanceVertex, operation, context); // add an edge to the newly created AtlasVertex from the parent String relationshipLabel = GraphHelper.getTraitLabel(entityType.getTypeName(), classification.getTypeName()); try { return graphHelper.getOrCreateEdge(parentInstanceVertex, traitInstanceVertex, relationshipLabel); } catch (RepositoryException e) { throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, e); } }
Example 12
Source File: AtlasBaseException.java From atlas with Apache License 2.0 | 4 votes |
public AtlasBaseException() { this(AtlasErrorCode.INTERNAL_ERROR); }
Example 13
Source File: AtlasBaseException.java From atlas with Apache License 2.0 | 4 votes |
public AtlasBaseException(String message) { super(message); this.atlasErrorCode = AtlasErrorCode.INTERNAL_ERROR; }
Example 14
Source File: AtlasBaseException.java From incubator-atlas with Apache License 2.0 | 4 votes |
public AtlasBaseException() { this(AtlasErrorCode.INTERNAL_ERROR); }
Example 15
Source File: AtlasBaseException.java From atlas with Apache License 2.0 | 4 votes |
public AtlasBaseException(Throwable cause) { super(cause); this.atlasErrorCode = AtlasErrorCode.INTERNAL_ERROR; }
Example 16
Source File: AtlasBaseException.java From atlas with Apache License 2.0 | 4 votes |
public AtlasBaseException(AtlasErrorCode errorCode, Throwable cause, boolean enableSuppression, boolean writableStackTrace, String ... params) { super(errorCode.getFormattedErrorMessage(params), cause, enableSuppression, writableStackTrace); this.atlasErrorCode = AtlasErrorCode.INTERNAL_ERROR; }
Example 17
Source File: EntityGraphMapper.java From atlas with Apache License 2.0 | 4 votes |
private AtlasEdge mapObjectIdValue(AttributeMutationContext ctx, EntityMutationContext context) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> mapObjectIdValue({})", ctx); } AtlasEdge ret = null; String guid = getGuid(ctx.getValue()); AtlasVertex entityVertex = context.getDiscoveryContext().getResolvedEntityVertex(guid); if (entityVertex == null) { if (AtlasTypeUtil.isAssignedGuid(guid)) { entityVertex = context.getVertex(guid); } if (entityVertex == null) { AtlasObjectId objId = getObjectId(ctx.getValue()); if (objId != null) { entityVertex = context.getDiscoveryContext().getResolvedEntityVertex(objId); } } } if (entityVertex == null) { throw new AtlasBaseException(AtlasErrorCode.INVALID_OBJECT_ID, (ctx.getValue() == null ? null : ctx.getValue().toString())); } if (ctx.getCurrentEdge() != null) { ret = updateEdge(ctx.getAttributeDef(), ctx.getValue(), ctx.getCurrentEdge(), entityVertex); } else if (ctx.getValue() != null) { String edgeLabel = AtlasGraphUtilsV2.getEdgeLabel(ctx.getVertexProperty()); try { ret = graphHelper.getOrCreateEdge(ctx.getReferringVertex(), entityVertex, edgeLabel); } catch (RepositoryException e) { throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, e); } } if (LOG.isDebugEnabled()) { LOG.debug("<== mapObjectIdValue({})", ctx); } return ret; }
Example 18
Source File: AtlasBaseException.java From incubator-atlas with Apache License 2.0 | 4 votes |
public AtlasBaseException(String message, Throwable cause) { super(message, cause); this.atlasErrorCode = AtlasErrorCode.INTERNAL_ERROR; }
Example 19
Source File: AtlasRelationshipStoreV2.java From atlas with Apache License 2.0 | 4 votes |
public AtlasEdge createRelationship(AtlasVertex end1Vertex, AtlasVertex end2Vertex, AtlasRelationship relationship, boolean existingRelationshipCheck) throws AtlasBaseException { AtlasEdge ret; try { validateRelationship(end1Vertex, end2Vertex, relationship); String relationshipLabel = getRelationshipEdgeLabel(end1Vertex, end2Vertex, relationship.getTypeName()); if (existingRelationshipCheck) { ret = getRelationshipEdge(end1Vertex, end2Vertex, relationshipLabel); if (ret != null) { throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_ALREADY_EXISTS, relationship.getTypeName(), AtlasGraphUtilsV2.getIdFromVertex(end1Vertex), AtlasGraphUtilsV2.getIdFromVertex(end2Vertex)); } } AtlasRelationshipType relationType = typeRegistry.getRelationshipTypeByName(relationship.getTypeName()); if (!relationType.hasLegacyAttributeEnd()) { // skip authorization for legacy attributes, as these would be covered as entity-update AtlasEntityHeader end1Entity = entityRetriever.toAtlasEntityHeaderWithClassifications(end1Vertex); AtlasEntityHeader end2Entity = entityRetriever.toAtlasEntityHeaderWithClassifications(end2Vertex); AtlasAuthorizationUtils.verifyAccess(new AtlasRelationshipAccessRequest(typeRegistry, AtlasPrivilege.RELATIONSHIP_ADD, relationship.getTypeName(), end1Entity, end2Entity)); } if (existingRelationshipCheck) { ret = graphHelper.getOrCreateEdge(end1Vertex, end2Vertex, relationshipLabel); } else { ret = graphHelper.addEdge(end1Vertex, end2Vertex, relationshipLabel); if (LOG.isDebugEnabled()) { LOG.debug("Created relationship edge from [{}] --> [{}] using edge label: [{}]", getTypeName(end1Vertex), getTypeName(end2Vertex), relationshipLabel); } } // map additional properties to relationship edge if (ret != null) { // Accept a valid (assigned) guid from the supplied relationship, or generate one. String relationshipGuid = relationship.getGuid(); PropagateTags tagPropagation = getRelationshipTagPropagation(end1Vertex, end2Vertex, relationship); final String guid = AtlasTypeUtil.isAssignedGuid(relationshipGuid) ? relationshipGuid : UUID.randomUUID().toString(); AtlasGraphUtilsV2.setEncodedProperty(ret, ENTITY_TYPE_PROPERTY_KEY, relationship.getTypeName()); AtlasGraphUtilsV2.setEncodedProperty(ret, RELATIONSHIP_GUID_PROPERTY_KEY, guid); AtlasGraphUtilsV2.setEncodedProperty(ret, HOME_ID_KEY, relationship.getHomeId()); AtlasGraphUtilsV2.setEncodedProperty(ret, VERSION_PROPERTY_KEY, getRelationshipVersion(relationship)); AtlasGraphUtilsV2.setEncodedProperty(ret, PROVENANCE_TYPE_KEY, relationship.getProvenanceType()); AtlasGraphUtilsV2.setEncodedProperty(ret, RELATIONSHIPTYPE_TAG_PROPAGATION_KEY, tagPropagation.name()); // blocked propagated classifications handleBlockedClassifications(ret, relationship.getBlockedPropagatedClassifications()); // propagate tags deleteDelegate.getHandler().addTagPropagation(ret, tagPropagation); } if (MapUtils.isNotEmpty(relationType.getAllAttributes())) { for (AtlasAttribute attr : relationType.getAllAttributes().values()) { String attrName = attr.getName(); String attrVertexProperty = attr.getVertexPropertyName(); Object attrValue = relationship.getAttribute(attrName); AtlasGraphUtilsV2.setEncodedProperty(ret, attrVertexProperty, attrValue); } } } catch (RepositoryException e) { throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, e); } sendNotifications(entityRetriever.mapEdgeToAtlasRelationship(ret), OperationType.RELATIONSHIP_CREATE); return ret; }
Example 20
Source File: EntityGraphMapper.java From incubator-atlas with Apache License 2.0 | 4 votes |
private AtlasEdge mapObjectIdValue(AttributeMutationContext ctx, EntityMutationContext context) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> mapObjectIdValue({})", ctx); } AtlasEdge ret = null; String guid = getGuid(ctx.getValue()); AtlasVertex entityVertex = context.getDiscoveryContext().getResolvedEntityVertex(guid); if (entityVertex == null) { AtlasObjectId objId = getObjectId(ctx.getValue()); if (objId != null) { entityVertex = context.getDiscoveryContext().getResolvedEntityVertex(objId); } } if (entityVertex == null) { throw new AtlasBaseException(AtlasErrorCode.INVALID_OBJECT_ID, (ctx.getValue() == null ? null : ctx.getValue().toString())); } if (ctx.getCurrentEdge() != null) { ret = updateEdge(ctx.getAttributeDef(), ctx.getValue(), ctx.getCurrentEdge(), entityVertex); } else if (ctx.getValue() != null) { String edgeLabel = AtlasGraphUtilsV1.getEdgeLabel(ctx.getVertexProperty()); try { ret = graphHelper.getOrCreateEdge(ctx.getReferringVertex(), entityVertex, edgeLabel); } catch (RepositoryException e) { throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, e); } } if (LOG.isDebugEnabled()) { LOG.debug("<== mapObjectIdValue({})", ctx); } return ret; }