use of org.apache.atlas.authorize.AtlasTypeAccessRequest in project atlas by apache.
the class AtlasEnumDefStoreV1 method preDeleteByName.
@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;
}
use of org.apache.atlas.authorize.AtlasTypeAccessRequest in project atlas by apache.
the class AtlasRelationshipDefStoreV1 method updateByName.
@Override
public AtlasRelationshipDef updateByName(String name, AtlasRelationshipDef relationshipDef) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasRelationshipDefStoreV1.updateByName({}, {})", name, relationshipDef);
}
AtlasRelationshipDef existingDef = typeRegistry.getRelationshipDefByName(name);
AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_UPDATE, existingDef), "update relationship-def ", name);
validateType(relationshipDef);
AtlasType type = typeRegistry.getType(relationshipDef.getName());
if (type.getTypeCategory() != org.apache.atlas.model.TypeCategory.RELATIONSHIP) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, relationshipDef.getName(), TypeCategory.RELATIONSHIP.name());
}
AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.RELATIONSHIP);
if (vertex == null) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
}
preUpdateCheck(relationshipDef, (AtlasRelationshipType) type, vertex);
AtlasRelationshipDef ret = toRelationshipDef(vertex);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasRelationshipDefStoreV1.updateByName({}, {}): {}", name, relationshipDef, ret);
}
return ret;
}
use of org.apache.atlas.authorize.AtlasTypeAccessRequest in project atlas by apache.
the class AtlasRelationshipDefStoreV1 method create.
@Override
public AtlasRelationshipDef create(AtlasRelationshipDef relationshipDef, AtlasVertex preCreateResult) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasRelationshipDefStoreV1.create({}, {})", relationshipDef, preCreateResult);
}
AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_CREATE, relationshipDef), "create relationship-def ", relationshipDef.getName());
AtlasVertex vertex = (preCreateResult == null) ? preCreate(relationshipDef) : preCreateResult;
AtlasRelationshipDef ret = toRelationshipDef(vertex);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasRelationshipDefStoreV1.create({}, {}): {}", relationshipDef, preCreateResult, ret);
}
return ret;
}
use of org.apache.atlas.authorize.AtlasTypeAccessRequest in project atlas by apache.
the class AtlasClassificationDefStoreV1 method updateByName.
@Override
public AtlasClassificationDef updateByName(String name, AtlasClassificationDef classificationDef) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasClassificationDefStoreV1.updateByName({}, {})", name, classificationDef);
}
AtlasClassificationDef existingDef = typeRegistry.getClassificationDefByName(name);
AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_UPDATE, existingDef), "update classification-def ", name);
validateType(classificationDef);
AtlasType type = typeRegistry.getType(classificationDef.getName());
if (type.getTypeCategory() != org.apache.atlas.model.TypeCategory.CLASSIFICATION) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, classificationDef.getName(), TypeCategory.TRAIT.name());
}
AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.TRAIT);
if (vertex == null) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
}
updateVertexPreUpdate(classificationDef, (AtlasClassificationType) type, vertex);
updateVertexAddReferences(classificationDef, vertex);
AtlasClassificationDef ret = toClassificationDef(vertex);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasClassificationDefStoreV1.updateByName({}, {}): {}", name, classificationDef, ret);
}
return ret;
}
use of org.apache.atlas.authorize.AtlasTypeAccessRequest in project atlas by apache.
the class AtlasClassificationDefStoreV1 method updateByGuid.
@Override
public AtlasClassificationDef updateByGuid(String guid, AtlasClassificationDef classificationDef) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasClassificationDefStoreV1.updateByGuid({})", guid);
}
AtlasClassificationDef existingDef = typeRegistry.getClassificationDefByGuid(guid);
AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_UPDATE, existingDef), "update classification-def ", (existingDef != null ? existingDef.getName() : guid));
validateType(classificationDef);
AtlasType type = typeRegistry.getTypeByGuid(guid);
if (type.getTypeCategory() != org.apache.atlas.model.TypeCategory.CLASSIFICATION) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, classificationDef.getName(), TypeCategory.TRAIT.name());
}
AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.TRAIT);
if (vertex == null) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
}
updateVertexPreUpdate(classificationDef, (AtlasClassificationType) type, vertex);
updateVertexAddReferences(classificationDef, vertex);
AtlasClassificationDef ret = toClassificationDef(vertex);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasClassificationDefStoreV1.updateByGuid({}): {}", guid, ret);
}
return ret;
}
Aggregations