Search in sources :

Example 16 with AtlasException

use of org.apache.atlas.AtlasException in project atlas by apache.

the class AtlasSimpleAuthorizer method init.

@Override
public void init() {
    LOG.info("==> SimpleAtlasAuthorizer.init()");
    InputStream inputStream = null;
    try {
        inputStream = ApplicationProperties.getFileAsInputStream(ApplicationProperties.get(), "atlas.authorizer.simple.authz.policy.file", "atlas-simple-authz-policy.json");
        authzPolicy = AtlasJson.fromJson(inputStream, AtlasSimpleAuthzPolicy.class);
    } catch (IOException | AtlasException e) {
        LOG.error("SimpleAtlasAuthorizer.init(): initialization failed", e);
        throw new RuntimeException(e);
    } finally {
        if (inputStream != null) {
            try {
                inputStream.close();
            } catch (IOException excp) {
            // ignore
            }
        }
    }
    LOG.info("<== SimpleAtlasAuthorizer.init()");
}
Also used : AtlasSimpleAuthzPolicy(org.apache.atlas.authorize.simple.AtlasSimpleAuthzPolicy) InputStream(java.io.InputStream) IOException(java.io.IOException) AtlasException(org.apache.atlas.AtlasException)

Example 17 with AtlasException

use of org.apache.atlas.AtlasException in project atlas by apache.

the class AtlasJanusGraphDatabase method isEmbeddedSolr.

public static boolean isEmbeddedSolr() {
    boolean ret = false;
    try {
        Configuration conf = ApplicationProperties.get();
        Object property = conf.getProperty("atlas.graph.index.search.solr.embedded");
        if (property != null && property instanceof String) {
            ret = Boolean.valueOf((String) property);
        }
    } catch (AtlasException ignored) {
    }
    return ret;
}
Also used : Configuration(org.apache.commons.configuration.Configuration) AtlasException(org.apache.atlas.AtlasException)

Example 18 with AtlasException

use of org.apache.atlas.AtlasException in project atlas by apache.

the class GraphSandboxUtil method create.

public static void create(String sandboxName) {
    Configuration configuration;
    try {
        configuration = ApplicationProperties.get();
        configuration.setProperty("atlas.graph.storage.directory", getStorageDir(sandboxName, "storage"));
        configuration.setProperty("atlas.graph.index.search.directory", getStorageDir(sandboxName, "index"));
        LOG.debug("New Storage dir : {}", configuration.getProperty("atlas.graph.storage.directory"));
        LOG.debug("New Indexer dir : {}", configuration.getProperty("atlas.graph.index.search.directory"));
    } catch (AtlasException ignored) {
        throw new SkipException("Failure to setup Sandbox: " + sandboxName);
    }
}
Also used : Configuration(org.apache.commons.configuration.Configuration) SkipException(org.testng.SkipException) AtlasException(org.apache.atlas.AtlasException)

Example 19 with AtlasException

use of org.apache.atlas.AtlasException in project atlas by apache.

the class GraphSandboxUtil method useLocalSolr.

public static boolean useLocalSolr() {
    boolean ret = false;
    try {
        Configuration conf = ApplicationProperties.get();
        Object property = conf.getProperty("atlas.graph.index.search.solr.embedded");
        if (property != null && property instanceof String) {
            ret = Boolean.valueOf((String) property);
        }
    } catch (AtlasException ignored) {
        throw new SkipException("useLocalSolr: failed! ", ignored);
    }
    return ret;
}
Also used : Configuration(org.apache.commons.configuration.Configuration) SkipException(org.testng.SkipException) AtlasException(org.apache.atlas.AtlasException)

Example 20 with AtlasException

use of org.apache.atlas.AtlasException in project atlas by apache.

the class OnAtlasPropertyCondition method matches.

@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
    boolean matches = false;
    String propertyName = (String) metadata.getAnnotationAttributes(ConditionalOnAtlasProperty.class.getName()).get("property");
    boolean isDefault = (Boolean) metadata.getAnnotationAttributes(ConditionalOnAtlasProperty.class.getName()).get("isDefault");
    String className = ((AnnotationMetadataReadingVisitor) metadata).getClassName();
    try {
        Configuration configuration = ApplicationProperties.get();
        String configuredProperty = configuration.getString(propertyName);
        if (StringUtils.isNotEmpty(configuredProperty)) {
            matches = configuredProperty.equals(className);
        } else if (isDefault)
            matches = true;
    } catch (AtlasException e) {
        LOG.error("Unable to load atlas properties. Dependent bean configuration may fail");
    }
    return matches;
}
Also used : ConditionalOnAtlasProperty(org.apache.atlas.annotation.ConditionalOnAtlasProperty) Configuration(org.apache.commons.configuration.Configuration) AnnotationMetadataReadingVisitor(org.springframework.core.type.classreading.AnnotationMetadataReadingVisitor) AtlasException(org.apache.atlas.AtlasException)

Aggregations

AtlasException (org.apache.atlas.AtlasException)139 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)36 IOException (java.io.IOException)27 AttributeInfo (org.apache.atlas.typesystem.types.AttributeInfo)26 Configuration (org.apache.commons.configuration.Configuration)19 CreateUpdateEntitiesResult (org.apache.atlas.CreateUpdateEntitiesResult)14 EntityMutationResponse (org.apache.atlas.model.instance.EntityMutationResponse)13 ITypedReferenceableInstance (org.apache.atlas.typesystem.ITypedReferenceableInstance)13 ArrayList (java.util.ArrayList)12 RepositoryException (org.apache.atlas.repository.RepositoryException)12 JSONObject (org.codehaus.jettison.json.JSONObject)12 AtlasPerfTracer (org.apache.atlas.utils.AtlasPerfTracer)10 EntityNotFoundException (org.apache.atlas.typesystem.exception.EntityNotFoundException)9 HashMap (java.util.HashMap)8 AtlasEntitiesWithExtInfo (org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo)8 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)8 Properties (java.util.Properties)7 File (java.io.File)6 InputStream (java.io.InputStream)6 EntityChangeListener (org.apache.atlas.listener.EntityChangeListener)6