Search in sources :

Example 1 with TypeNotFoundException

use of org.apache.atlas.typesystem.exception.TypeNotFoundException in project incubator-atlas by apache.

the class DefaultMetadataServiceTest method setUp.

@BeforeTest
public void setUp() throws Exception {
    typeDefChangeListener = (DefaultMetadataService) metadataService;
    metadataService = TestUtils.addSessionCleanupWrapper(metadataService);
    if (auditRepository instanceof HBaseBasedAuditRepository) {
        HBaseTestUtils.startCluster();
        ((HBaseBasedAuditRepository) auditRepository).start();
    }
    TestUtils.resetRequestContext();
    RequestContext.get().setUser("testuser");
    TypesDef typesDef = TestUtils.defineHiveTypes();
    try {
        metadataService.getTypeDefinition(TestUtils.TABLE_TYPE);
    } catch (TypeNotFoundException e) {
        metadataService.createType(TypesSerialization.toJson(typesDef));
    }
    String dbGUid = TestUtils.createInstance(metadataService, db);
    table = createTableEntity(dbGUid);
    String tableGuid = TestUtils.createInstance(metadataService, table);
    String tableDefinitionJson = metadataService.getEntityDefinition(TestUtils.TABLE_TYPE, NAME, (String) table.get(NAME));
    table = InstanceSerialization.fromJsonReferenceable(tableDefinitionJson, true);
    tableId = new Id(tableGuid, 0, TestUtils.TABLE_TYPE);
}
Also used : HBaseBasedAuditRepository(org.apache.atlas.repository.audit.HBaseBasedAuditRepository) TypesDef(org.apache.atlas.typesystem.TypesDef) TypeNotFoundException(org.apache.atlas.typesystem.exception.TypeNotFoundException) Id(org.apache.atlas.typesystem.persistence.Id) BeforeTest(org.testng.annotations.BeforeTest)

Example 2 with TypeNotFoundException

use of org.apache.atlas.typesystem.exception.TypeNotFoundException in project incubator-atlas by apache.

the class GraphHelper method deserializeClassInstances.

public static ITypedReferenceableInstance[] deserializeClassInstances(TypeSystem typeSystem, String entityInstanceDefinition) throws AtlasException {
    try {
        JSONArray referableInstances = new JSONArray(entityInstanceDefinition);
        ITypedReferenceableInstance[] instances = new ITypedReferenceableInstance[referableInstances.length()];
        for (int index = 0; index < referableInstances.length(); index++) {
            Referenceable entityInstance = InstanceSerialization.fromJsonReferenceable(referableInstances.getString(index), true);
            ITypedReferenceableInstance typedInstrance = getTypedReferenceableInstance(typeSystem, entityInstance);
            instances[index] = typedInstrance;
        }
        return instances;
    } catch (ValueConversionException | TypeNotFoundException e) {
        throw e;
    } catch (Exception e) {
        // exception from deserializer
        LOG.error("Unable to deserialize json={}", entityInstanceDefinition, e);
        throw new IllegalArgumentException("Unable to deserialize json", e);
    }
}
Also used : Referenceable(org.apache.atlas.typesystem.Referenceable) ITypedReferenceableInstance(org.apache.atlas.typesystem.ITypedReferenceableInstance) TypeNotFoundException(org.apache.atlas.typesystem.exception.TypeNotFoundException) JSONArray(org.codehaus.jettison.json.JSONArray) ValueConversionException(org.apache.atlas.typesystem.types.ValueConversionException) RepositoryException(org.apache.atlas.repository.RepositoryException) EntityNotFoundException(org.apache.atlas.typesystem.exception.EntityNotFoundException) TypeNotFoundException(org.apache.atlas.typesystem.exception.TypeNotFoundException) AtlasException(org.apache.atlas.AtlasException) ValueConversionException(org.apache.atlas.typesystem.types.ValueConversionException)

Example 3 with TypeNotFoundException

use of org.apache.atlas.typesystem.exception.TypeNotFoundException in project incubator-atlas by apache.

the class DefaultMetadataService method createTraitInstance.

@Override
public ITypedStruct createTraitInstance(Struct traitInstance) throws AtlasException {
    try {
        final String entityTypeName = ParamChecker.notEmpty(traitInstance.getTypeName(), "entity type");
        TraitType traitType = typeSystem.getDataType(TraitType.class, entityTypeName);
        return traitType.convert(traitInstance, Multiplicity.REQUIRED);
    } catch (TypeNotFoundException e) {
        throw e;
    } catch (Exception e) {
        throw new AtlasException("Error deserializing trait instance", e);
    }
}
Also used : TypeNotFoundException(org.apache.atlas.typesystem.exception.TypeNotFoundException) AtlasException(org.apache.atlas.AtlasException) RepositoryException(org.apache.atlas.repository.RepositoryException) EntityNotFoundException(org.apache.atlas.typesystem.exception.EntityNotFoundException) TypeNotFoundException(org.apache.atlas.typesystem.exception.TypeNotFoundException) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) JSONException(org.codehaus.jettison.json.JSONException) AtlasException(org.apache.atlas.AtlasException)

Example 4 with TypeNotFoundException

use of org.apache.atlas.typesystem.exception.TypeNotFoundException in project incubator-atlas by apache.

the class GraphHelperTest method setUp.

@BeforeClass
public void setUp() throws Exception {
    typeSystem = TypeSystem.getInstance();
    typeSystem.reset();
    new GraphBackedSearchIndexer(typeRegistry);
    TypesDef typesDef = TestUtils.defineHiveTypes();
    try {
        metadataService.getTypeDefinition(TestUtils.TABLE_TYPE);
    } catch (TypeNotFoundException e) {
        metadataService.createType(TypesSerialization.toJson(typesDef));
    }
    TestUtils.defineDeptEmployeeTypes(typeSystem);
}
Also used : TypesDef(org.apache.atlas.typesystem.TypesDef) TypeNotFoundException(org.apache.atlas.typesystem.exception.TypeNotFoundException) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

TypeNotFoundException (org.apache.atlas.typesystem.exception.TypeNotFoundException)4 AtlasException (org.apache.atlas.AtlasException)2 RepositoryException (org.apache.atlas.repository.RepositoryException)2 TypesDef (org.apache.atlas.typesystem.TypesDef)2 EntityNotFoundException (org.apache.atlas.typesystem.exception.EntityNotFoundException)2 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)1 HBaseBasedAuditRepository (org.apache.atlas.repository.audit.HBaseBasedAuditRepository)1 ITypedReferenceableInstance (org.apache.atlas.typesystem.ITypedReferenceableInstance)1 Referenceable (org.apache.atlas.typesystem.Referenceable)1 Id (org.apache.atlas.typesystem.persistence.Id)1 ValueConversionException (org.apache.atlas.typesystem.types.ValueConversionException)1 JSONArray (org.codehaus.jettison.json.JSONArray)1 JSONException (org.codehaus.jettison.json.JSONException)1 BeforeClass (org.testng.annotations.BeforeClass)1 BeforeTest (org.testng.annotations.BeforeTest)1