Java Code Examples for org.apache.atlas.AtlasErrorCode#TYPE_NAME_NOT_FOUND

The following examples show how to use org.apache.atlas.AtlasErrorCode#TYPE_NAME_NOT_FOUND . 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: AtlasClassificationDefStoreV2.java    From atlas with Apache License 2.0 6 votes vote down vote up
@Override
public AtlasClassificationDef getByName(String name) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasClassificationDefStoreV1.getByName({})", name);
    }

    AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.TRAIT);

    if (vertex == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
    }

    vertex.getProperty(Constants.TYPE_CATEGORY_PROPERTY_KEY, TypeCategory.class);

    AtlasClassificationDef ret = toClassificationDef(vertex);

    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasClassificationDefStoreV1.getByName({}): {}", name, ret);
    }

    return ret;
}
 
Example 2
Source File: AtlasBusinessMetadataDefStoreV2.java    From atlas with Apache License 2.0 6 votes vote down vote up
public AtlasVertex preDeleteByName(String name) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasBusinessMetadataDefStoreV2.preDeleteByName({})", name);
    }

    AtlasBusinessMetadataDef existingDef = typeRegistry.getBusinessMetadataDefByName(name);

    AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_DELETE, existingDef), "delete businessMetadata-def ", name);

    AtlasVertex ret = typeDefStore.findTypeVertexByNameAndCategory(name, DataTypes.TypeCategory.BUSINESS_METADATA);

    if (ret == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasBusinessMetadataDefStoreV2.preDeleteByName({}): {}", name, ret);
    }

    return ret;
}
 
Example 3
Source File: AtlasEntityDefStoreV1.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
@Override
public AtlasEntityDef getByName(String name) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasEntityDefStoreV1.getByName({})", name);
    }

    AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.CLASS);

    if (vertex == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
    }

    vertex.getProperty(Constants.TYPE_CATEGORY_PROPERTY_KEY, TypeCategory.class);

    AtlasEntityDef ret = toEntityDef(vertex);

    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasEntityDefStoreV1.getByName({}): {}", name, ret);
    }

    return ret;
}
 
Example 4
Source File: AtlasStructDefStoreV1.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
@Override
public AtlasVertex preDeleteByName(String name) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasStructDefStoreV1.preDeleteByName({})", name);
    }

    AtlasVertex ret = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.STRUCT);

    if (AtlasGraphUtilsV1.typeHasInstanceVertex(name)) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, name);
    }

    if (ret == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
    }

    typeDefStore.deleteTypeVertexOutEdges(ret);

    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasStructDefStoreV1.preDeleteByName({}): {}", name, ret);
    }

    return ret;
}
 
Example 5
Source File: DefaultTypeSystem.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
private void createTraitType(AtlasClassificationDef classificationDef) throws AtlasBaseException {
    try {
        typeDefStore.getClassificationDefByName(classificationDef.getName());
    } catch (AtlasBaseException tne) {
        //Type not found . Create
        if (tne.getAtlasErrorCode() == AtlasErrorCode.TYPE_NAME_NOT_FOUND) {
            AtlasTypesDef typesDef = new AtlasTypesDef(ImmutableList.<AtlasEnumDef>of(), ImmutableList.<AtlasStructDef>of(),
                ImmutableList.of(classificationDef),
                ImmutableList.<AtlasEntityDef>of());

            typeDefStore.createTypesDef(typesDef);
        } else {
            throw tne;
        }
    }
}
 
Example 6
Source File: AtlasInstanceConverter.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
public static AtlasBaseException toAtlasBaseException(AtlasException e) {
    if (e instanceof EntityExistsException) {
        return new AtlasBaseException(AtlasErrorCode.INSTANCE_ALREADY_EXISTS, e.getMessage());
    }

    if ( e instanceof EntityNotFoundException || e instanceof TraitNotFoundException) {
        return new AtlasBaseException(AtlasErrorCode.INSTANCE_NOT_FOUND, e.getMessage());
    }

    if ( e instanceof TypeNotFoundException) {
        return new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, e.getMessage());
    }

    if (e instanceof ValueConversionException) {
        return new AtlasBaseException(AtlasErrorCode.INVALID_VALUE, e, e.getMessage());
    }

    return new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, e.getMessage());
}
 
Example 7
Source File: AtlasEntityDefStoreV1.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
@Override
public AtlasVertex preDeleteByName(String name) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasEntityDefStoreV1.preDeleteByName({})", name);
    }

    AtlasVertex ret = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.CLASS);

    if (AtlasGraphUtilsV1.typeHasInstanceVertex(name)) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, name);
    }

    if (ret == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
    }

    // error if we are trying to delete an entityDef that has a relationshipDef
    if (typeDefStore.hasIncomingEdgesWithLabel(ret, AtlasGraphUtilsV1.RELATIONSHIPTYPE_EDGE_LABEL)){
        throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_RELATIONSHIPS, name);
    }

    typeDefStore.deleteTypeVertexOutEdges(ret);

    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasEntityDefStoreV1.preDeleteByName({}): {}", name, ret);
    }

    return ret;
}
 
Example 8
Source File: AtlasStructDefStoreV2.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Override
public AtlasVertex preDeleteByName(String name) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasStructDefStoreV1.preDeleteByName({})", name);
    }

    AtlasStructDef existingDef = typeRegistry.getStructDefByName(name);

    AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_DELETE, existingDef), "delete struct-def ", name);

    AtlasVertex ret = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.STRUCT);

    if (AtlasGraphUtilsV2.typeHasInstanceVertex(name)) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, name);
    }

    if (ret == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
    }

    typeDefStore.deleteTypeVertexOutEdges(ret);

    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasStructDefStoreV1.preDeleteByName({}): {}", name, ret);
    }

    return ret;
}
 
Example 9
Source File: AtlasEnumDefStoreV2.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Override
public AtlasVertex preDeleteByName(String name) throws AtlasBaseException {
    AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.ENUM);

    if (vertex == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
    }

    AtlasEnumDef existingDef = typeRegistry.getEnumDefByName(name);

    AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_DELETE, existingDef), "delete enum-def ", (existingDef != null ? existingDef.getName() : name));

    return vertex;
}
 
Example 10
Source File: AtlasEntityDefStoreV2.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Override
public AtlasVertex preDeleteByName(String name) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasEntityDefStoreV1.preDeleteByName({})", name);
    }

    AtlasEntityDef existingDef = typeRegistry.getEntityDefByName(name);

    AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_DELETE, existingDef), "delete entity-def ", name);

    AtlasVertex ret = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.CLASS);

    if (AtlasGraphUtilsV2.typeHasInstanceVertex(name)) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, name);
    }

    if (ret == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
    }

    // error if we are trying to delete an entityDef that has a relationshipDef
    if (typeDefStore.hasIncomingEdgesWithLabel(ret, AtlasGraphUtilsV2.RELATIONSHIPTYPE_EDGE_LABEL)){
        throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_RELATIONSHIPS, name);
    }

    typeDefStore.deleteTypeVertexOutEdges(ret);

    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasEntityDefStoreV1.preDeleteByName({}): {}", name, ret);
    }

    return ret;
}
 
Example 11
Source File: AtlasRelationshipDefStoreV2.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Override
public AtlasVertex preDeleteByName(String name) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasRelationshipDefStoreV1.preDeleteByName({})", name);
    }

    AtlasRelationshipDef existingDef = typeRegistry.getRelationshipDefByName(name);

    AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_DELETE, existingDef), "delete relationship-def ", name);

    AtlasVertex ret = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.RELATIONSHIP);

    if (ret == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
    }

    if (AtlasGraphUtilsV2.relationshipTypeHasInstanceEdges(name)) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, name);
    }

    typeDefStore.deleteTypeVertexOutEdges(ret);

    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasRelationshipDefStoreV1.preDeleteByName({}): {}", name, ret);
    }

    return ret;
}
 
Example 12
Source File: AtlasTypeDefGraphStore.java    From atlas with Apache License 2.0 5 votes vote down vote up
private void tryTypeCreation(AtlasTypesDef typesDef, AtlasTransientTypeRegistry ttr) throws AtlasBaseException {
    // Translate any NOT FOUND errors to BAD REQUEST
    try {
        ttr.addTypes(typesDef);
    } catch (AtlasBaseException e) {
        if (AtlasErrorCode.TYPE_NAME_NOT_FOUND == e.getAtlasErrorCode() ||
                AtlasErrorCode.TYPE_GUID_NOT_FOUND == e.getAtlasErrorCode()) {
            throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, e.getMessage());
        } else {
            throw e;
        }
    }
}
 
Example 13
Source File: AtlasTypeDefGraphStore.java    From atlas with Apache License 2.0 5 votes vote down vote up
private void tryUpdateByName(String name, AtlasBaseTypeDef typeDef, AtlasTransientTypeRegistry ttr) throws AtlasBaseException {
    try {
        ttr.updateTypeByName(name, typeDef);
    } catch (AtlasBaseException e) {
        if (AtlasErrorCode.TYPE_NAME_NOT_FOUND == e.getAtlasErrorCode()) {
            throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, e.getMessage());
        } else {
            throw e;
        }
    }
}
 
Example 14
Source File: AtlasTypeDefGraphStore.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Override
public AtlasEntityDef getEntityDefByName(String name) throws AtlasBaseException {
    AtlasEntityDef ret = typeRegistry.getEntityDefByName(name);

    if (ret == null) {
        ret = StringUtils.equals(name, ALL_ENTITY_TYPES) ? AtlasEntityType.getEntityRoot().getEntityDef() : null;

        if (ret == null) {
            throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
        }
    }

    return ret;
}
 
Example 15
Source File: AtlasStructDefStoreV1.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
@Override
public AtlasStructDef updateByName(String name, AtlasStructDef structDef) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasStructDefStoreV1.updateByName({}, {})", name, structDef);
    }

    validateType(structDef);

    AtlasType type = typeRegistry.getType(structDef.getName());

    if (type.getTypeCategory() != org.apache.atlas.model.TypeCategory.STRUCT) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, structDef.getName(), TypeCategory.STRUCT.name());
    }

    AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.STRUCT);

    if (vertex == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
    }

    AtlasStructDefStoreV1.updateVertexPreUpdate(structDef, (AtlasStructType)type, vertex, typeDefStore);
    AtlasStructDefStoreV1.updateVertexAddReferences(structDef, vertex, typeDefStore);

    AtlasStructDef ret = toStructDef(vertex);

    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasStructDefStoreV1.updateByName({}, {}): {}", name, structDef, ret);
    }

    return ret;
}
 
Example 16
Source File: AtlasTypeDefGraphStore.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Override
public AtlasBusinessMetadataDef getBusinessMetadataDefByName(String name) throws AtlasBaseException {
    AtlasBusinessMetadataDef ret = typeRegistry.getBusinessMetadataDefByName(name);

    if (ret == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
    }

    return ret;
}
 
Example 17
Source File: AtlasTypeDefGraphStore.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Override
public AtlasStructDef getStructDefByName(String name) throws AtlasBaseException {
    AtlasStructDef ret = typeRegistry.getStructDefByName(name);

    if (ret == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
    }

    return ret;
}
 
Example 18
Source File: AtlasTypeDefGraphStore.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
private void tryUpdateByName(String name, AtlasBaseTypeDef typeDef, AtlasTransientTypeRegistry ttr) throws AtlasBaseException {
    try {
        ttr.updateTypeByName(name, typeDef);
    } catch (AtlasBaseException e) {
        if (AtlasErrorCode.TYPE_NAME_NOT_FOUND == e.getAtlasErrorCode()) {
            throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, e.getMessage());
        } else {
            throw e;
        }
    }
}
 
Example 19
Source File: AtlasTypeDefGraphStore.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
@Override
public AtlasRelationshipDef getRelationshipDefByName(String name) throws AtlasBaseException {
    AtlasRelationshipDef ret = typeRegistry.getRelationshipDefByName(name);

    if (ret == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
    }

    return ret;
}
 
Example 20
Source File: AtlasEnumDefStoreV2.java    From atlas with Apache License 2.0 3 votes vote down vote up
@Override
public AtlasEnumDef updateByName(String name, AtlasEnumDef enumDef) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasEnumDefStoreV2.updateByName({}, {})", name, enumDef);
    }

    AtlasEnumDef existingDef = typeRegistry.getEnumDefByName(name);

    AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_UPDATE, existingDef), "update enum-def ", name);

    validateType(enumDef);

    AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.ENUM);

    if (vertex == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
    }

    typeDefStore.updateTypeVertex(enumDef, vertex);

    toVertex(enumDef, vertex);

    AtlasEnumDef ret = toEnumDef(vertex);

    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasEnumDefStoreV2.updateByName({}, {}): {}", name, enumDef, ret);
    }

    return ret;
}