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

The following examples show how to use org.apache.atlas.AtlasErrorCode#TYPE_HAS_REFERENCES . 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: AtlasClassificationDefStoreV1.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("==> AtlasClassificationDefStoreV1.preDeleteByName({})", name);
    }

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

    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("<== AtlasClassificationDefStoreV1.preDeleteByName({}): ret=", name, ret);
    }

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

    AtlasVertex ret = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.STRUCT);

    String typeName = AtlasGraphUtilsV1.getProperty(ret, Constants.TYPENAME_PROPERTY_KEY, String.class);

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

    if (ret == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
    }

    typeDefStore.deleteTypeVertexOutEdges(ret);

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

    return ret;
}
 
Example 3
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 4
Source File: AtlasRelationshipDefStoreV1.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
@Override
public AtlasVertex preDeleteByGuid(String guid) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasRelationshipDefStoreV1.preDeleteByGuid({})", 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;
}
 
Example 5
Source File: AtlasRelationshipDefStoreV1.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("==> AtlasRelationshipDefStoreV1.preDeleteByName({})", 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;
}
 
Example 6
Source File: AtlasClassificationDefStoreV1.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
@Override
public AtlasVertex preDeleteByGuid(String guid) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasClassificationDefStoreV1.preDeleteByGuid({})", guid);
    }

    AtlasVertex ret = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.TRAIT);

    String typeName = AtlasGraphUtilsV1.getProperty(ret, Constants.TYPENAME_PROPERTY_KEY, String.class);

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

    if (ret == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
    }

    typeDefStore.deleteTypeVertexOutEdges(ret);

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

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

    AtlasStructDef existingDef = typeRegistry.getStructDefByGuid(guid);

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

    AtlasVertex ret = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.STRUCT);

    String typeName = AtlasGraphUtilsV2.getEncodedProperty(ret, Constants.TYPENAME_PROPERTY_KEY, String.class);

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

    if (ret == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
    }

    typeDefStore.deleteTypeVertexOutEdges(ret);

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

    return ret;
}
 
Example 8
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 9
Source File: AtlasEntityDefStoreV2.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Override
public AtlasVertex preDeleteByGuid(String guid) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasEntityDefStoreV1.preDeleteByGuid({})", guid);
    }

    AtlasEntityDef existingDef = typeRegistry.getEntityDefByGuid(guid);

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

    AtlasVertex ret = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.CLASS);

    String typeName = AtlasGraphUtilsV2.getEncodedProperty(ret, Constants.TYPENAME_PROPERTY_KEY, String.class);

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

    if (ret == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
    }

    // 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, typeName);
    }

    typeDefStore.deleteTypeVertexOutEdges(ret);

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

    return ret;
}
 
Example 10
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 11
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 12
Source File: AtlasClassificationDefStoreV2.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Override
public AtlasVertex preDeleteByGuid(String guid) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasClassificationDefStoreV1.preDeleteByGuid({})", guid);
    }

    AtlasClassificationDef existingDef = typeRegistry.getClassificationDefByGuid(guid);

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

    AtlasVertex ret = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.TRAIT);

    String typeName = AtlasGraphUtilsV2.getEncodedProperty(ret, TYPENAME_PROPERTY_KEY, String.class);

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

    if (ret == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
    }

    typeDefStore.deleteTypeVertexOutEdges(ret);

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

    return ret;
}
 
Example 13
Source File: AtlasClassificationDefStoreV2.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("==> AtlasClassificationDefStoreV1.preDeleteByName({})", name);
    }

    AtlasClassificationDef existingDef = typeRegistry.getClassificationDefByName(name);

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

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

    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("<== AtlasClassificationDefStoreV1.preDeleteByName({}): ret=", name, ret);
    }

    return ret;
}
 
Example 14
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 15
Source File: AtlasEntityDefStoreV1.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
@Override
public AtlasVertex preDeleteByGuid(String guid) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasEntityDefStoreV1.preDeleteByGuid({})", guid);
    }

    AtlasVertex ret = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.CLASS);

    String typeName = AtlasGraphUtilsV1.getProperty(ret, Constants.TYPENAME_PROPERTY_KEY, String.class);

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

    if (ret == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
    }

    // 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, typeName);
    }

    typeDefStore.deleteTypeVertexOutEdges(ret);

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

    return ret;
}
 
Example 16
Source File: AtlasTypeDefGraphStoreV1.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
void deleteTypeVertex(AtlasVertex vertex) throws AtlasBaseException {
    Iterator<AtlasEdge> inEdges = vertex.getEdges(AtlasEdgeDirection.IN).iterator();

    if (inEdges.hasNext()) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES);
    }

    Iterable<AtlasEdge> edges = vertex.getEdges(AtlasEdgeDirection.OUT);

    for (AtlasEdge edge : edges) {
        atlasGraph.removeEdge(edge);
    }
    atlasGraph.removeVertex(vertex);
}
 
Example 17
Source File: AtlasTypeDefGraphStoreV2.java    From atlas with Apache License 2.0 5 votes vote down vote up
void deleteTypeVertex(AtlasVertex vertex) throws AtlasBaseException {
    Iterator<AtlasEdge> inEdges = vertex.getEdges(AtlasEdgeDirection.IN).iterator();

    if (inEdges.hasNext()) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES);
    }

    Iterable<AtlasEdge> edges = vertex.getEdges(AtlasEdgeDirection.OUT);

    for (AtlasEdge edge : edges) {
        atlasGraph.removeEdge(edge);
    }
    atlasGraph.removeVertex(vertex);
}
 
Example 18
Source File: AtlasRelationshipDefStoreV2.java    From atlas with Apache License 2.0 5 votes vote down vote up
@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 = AtlasGraphUtilsV2.getEncodedProperty(ret, Constants.TYPENAME_PROPERTY_KEY, String.class);

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

    typeDefStore.deleteTypeVertexOutEdges(ret);

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

    return ret;
}