Search in sources :

Example 16 with AtlasTypeAccessRequest

use of org.apache.atlas.authorize.AtlasTypeAccessRequest in project atlas by apache.

the class AtlasStructDefStoreV1 method updateByGuid.

@Override
public AtlasStructDef updateByGuid(String guid, AtlasStructDef structDef) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasStructDefStoreV1.updateByGuid({})", guid);
    }
    AtlasStructDef existingDef = typeRegistry.getStructDefByGuid(guid);
    AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_UPDATE, existingDef), "update struct-def ", (existingDef != null ? existingDef.getName() : guid));
    validateType(structDef);
    AtlasType type = typeRegistry.getTypeByGuid(guid);
    if (type.getTypeCategory() != org.apache.atlas.model.TypeCategory.STRUCT) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, structDef.getName(), TypeCategory.STRUCT.name());
    }
    AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.STRUCT);
    if (vertex == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
    }
    AtlasStructDefStoreV1.updateVertexPreUpdate(structDef, (AtlasStructType) type, vertex, typeDefStore);
    AtlasStructDefStoreV1.updateVertexAddReferences(structDef, vertex, typeDefStore);
    AtlasStructDef ret = toStructDef(vertex);
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasStructDefStoreV1.updateByGuid({}): {}", guid, ret);
    }
    return ret;
}
Also used : AtlasStructDef(org.apache.atlas.model.typedef.AtlasStructDef) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) AtlasTypeAccessRequest(org.apache.atlas.authorize.AtlasTypeAccessRequest) AtlasType(org.apache.atlas.type.AtlasType)

Example 17 with AtlasTypeAccessRequest

use of org.apache.atlas.authorize.AtlasTypeAccessRequest in project atlas by apache.

the class AtlasEnumDefStoreV1 method preDeleteByGuid.

@Override
public AtlasVertex preDeleteByGuid(String guid) throws AtlasBaseException {
    AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.ENUM);
    if (vertex == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
    }
    AtlasEnumDef existingDef = typeRegistry.getEnumDefByGuid(guid);
    AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_DELETE, existingDef), "delete enum-def ", (existingDef != null ? existingDef.getName() : guid));
    return vertex;
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) AtlasTypeAccessRequest(org.apache.atlas.authorize.AtlasTypeAccessRequest) AtlasEnumDef(org.apache.atlas.model.typedef.AtlasEnumDef)

Example 18 with AtlasTypeAccessRequest

use of org.apache.atlas.authorize.AtlasTypeAccessRequest in project atlas by apache.

the class AtlasEnumDefStoreV1 method updateByName.

@Override
public AtlasEnumDef updateByName(String name, AtlasEnumDef enumDef) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasEnumDefStoreV1.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("<== AtlasEnumDefStoreV1.updateByName({}, {}): {}", name, enumDef, ret);
    }
    return ret;
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) AtlasTypeAccessRequest(org.apache.atlas.authorize.AtlasTypeAccessRequest) AtlasEnumDef(org.apache.atlas.model.typedef.AtlasEnumDef)

Example 19 with AtlasTypeAccessRequest

use of org.apache.atlas.authorize.AtlasTypeAccessRequest in project atlas by apache.

the class AtlasRelationshipDefStoreV1 method preDeleteByGuid.

@Override
public AtlasVertex preDeleteByGuid(String guid) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasRelationshipDefStoreV1.preDeleteByGuid({})", guid);
    }
    AtlasRelationshipDef existingDef = typeRegistry.getRelationshipDefByGuid(guid);
    AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_DELETE, existingDef), "delete relationship-def ", (existingDef != null ? existingDef.getName() : guid));
    AtlasVertex ret = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.RELATIONSHIP);
    if (ret == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
    }
    String typeName = AtlasGraphUtilsV1.getProperty(ret, Constants.TYPENAME_PROPERTY_KEY, String.class);
    if (AtlasGraphUtilsV1.relationshipTypeHasInstanceEdges(typeName)) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, typeName);
    }
    typeDefStore.deleteTypeVertexOutEdges(ret);
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasRelationshipDefStoreV1.preDeleteByGuid({}): {}", guid, ret);
    }
    return ret;
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) AtlasRelationshipDef(org.apache.atlas.model.typedef.AtlasRelationshipDef) AtlasTypeAccessRequest(org.apache.atlas.authorize.AtlasTypeAccessRequest)

Example 20 with AtlasTypeAccessRequest

use of org.apache.atlas.authorize.AtlasTypeAccessRequest in project atlas by apache.

the class AtlasRelationshipDefStoreV1 method preDeleteByName.

@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 (AtlasGraphUtilsV1.relationshipTypeHasInstanceEdges(name)) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, name);
    }
    typeDefStore.deleteTypeVertexOutEdges(ret);
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasRelationshipDefStoreV1.preDeleteByName({}): {}", name, ret);
    }
    return ret;
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) AtlasRelationshipDef(org.apache.atlas.model.typedef.AtlasRelationshipDef) AtlasTypeAccessRequest(org.apache.atlas.authorize.AtlasTypeAccessRequest)

Aggregations

AtlasTypeAccessRequest (org.apache.atlas.authorize.AtlasTypeAccessRequest)26 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)25 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)21 AtlasType (org.apache.atlas.type.AtlasType)8 AtlasClassificationDef (org.apache.atlas.model.typedef.AtlasClassificationDef)5 AtlasEntityDef (org.apache.atlas.model.typedef.AtlasEntityDef)5 AtlasEnumDef (org.apache.atlas.model.typedef.AtlasEnumDef)5 AtlasRelationshipDef (org.apache.atlas.model.typedef.AtlasRelationshipDef)5 AtlasStructDef (org.apache.atlas.model.typedef.AtlasStructDef)5 AtlasBaseTypeDef (org.apache.atlas.model.typedef.AtlasBaseTypeDef)1