Search in sources :

Example 26 with AtlasTypeAccessRequest

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

the class AtlasEntityDefStoreV1 method updateByName.

@Override
public AtlasEntityDef updateByName(String name, AtlasEntityDef entityDef) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasEntityDefStoreV1.updateByName({}, {})", name, entityDef);
    }
    AtlasEntityDef existingDef = typeRegistry.getEntityDefByName(name);
    AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_UPDATE, existingDef), "update entity-def ", name);
    validateType(entityDef);
    AtlasType type = typeRegistry.getType(entityDef.getName());
    if (type.getTypeCategory() != org.apache.atlas.model.TypeCategory.ENTITY) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, entityDef.getName(), TypeCategory.CLASS.name());
    }
    AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.CLASS);
    if (vertex == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
    }
    updateVertexPreUpdate(entityDef, (AtlasEntityType) type, vertex);
    updateVertexAddReferences(entityDef, vertex);
    AtlasEntityDef ret = toEntityDef(vertex);
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasEntityDefStoreV1.updateByName({}, {}): {}", name, entityDef, ret);
    }
    return ret;
}
Also used : AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) 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)

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