use of org.apache.atlas.AtlasException in project atlas by apache.
the class InMemoryJAASConfiguration method init.
public static void init(org.apache.commons.configuration.Configuration atlasConfiguration) throws AtlasException {
LOG.debug("==> InMemoryJAASConfiguration.init()");
if (atlasConfiguration != null && !atlasConfiguration.isEmpty()) {
Properties properties = ConfigurationConverter.getProperties(atlasConfiguration);
init(properties);
} else {
throw new AtlasException("Failed to load JAAS application properties: configuration NULL or empty!");
}
LOG.debug("<== InMemoryJAASConfiguration.init()");
}
use of org.apache.atlas.AtlasException in project incubator-atlas by apache.
the class DefaultTypeSystem method createTraitInstance.
@Override
public void createTraitInstance(String guid, String typeName, Map<String, Object> properties) throws ResourceAlreadyExistsException {
try {
// not using the constructor with properties argument because it is marked 'InterfaceAudience.Private'
Struct struct = new Struct(typeName);
for (Map.Entry<String, Object> propEntry : properties.entrySet()) {
struct.set(propEntry.getKey(), propEntry.getValue());
}
// add Taxonomy Namespace
struct.set(TaxonomyResourceProvider.NAMESPACE_ATTRIBUTE_NAME, TaxonomyResourceProvider.TAXONOMY_NS);
metadataService.addTrait(guid, metadataService.createTraitInstance(struct));
} catch (IllegalArgumentException e) {
// todo: unfortunately, IllegalArgumentException can be thrown for other reasons
if (e.getMessage().contains("is already defined for entity")) {
throw new ResourceAlreadyExistsException(String.format("Tag '%s' already associated with the entity", typeName));
} else {
throw e;
}
} catch (AtlasException e) {
throw new CatalogRuntimeException(String.format("Unable to create trait instance '%s' in type system: %s", typeName, e), e);
}
}
use of org.apache.atlas.AtlasException in project incubator-atlas by apache.
the class DefaultTypeSystem method deleteEntity.
@Override
public void deleteEntity(ResourceDefinition definition, Request request) throws ResourceNotFoundException {
String typeName = definition.getTypeName();
String cleanIdPropName = definition.getIdPropertyName();
String idValue = request.getProperty(cleanIdPropName);
try {
// transaction handled by atlas repository
metadataService.deleteEntityByUniqueAttribute(typeName, cleanIdPropName, idValue);
} catch (EntityNotFoundException e) {
throw new ResourceNotFoundException(String.format("The specified entity doesn't exist: type=%s, %s=%s", typeName, cleanIdPropName, idValue));
} catch (AtlasException e) {
throw new CatalogRuntimeException(String.format("An unexpected error occurred while attempting to delete entity: type=%s, %s=%s : %s", typeName, cleanIdPropName, idValue, e), e);
}
}
use of org.apache.atlas.AtlasException in project incubator-atlas by apache.
the class TaxonomyResourceProvider method createDefaultTaxonomyIfNeeded.
// must be called from within class monitor
private void createDefaultTaxonomyIfNeeded() {
if (!autoInitializationChecked()) {
try {
LOG.info("Checking if default taxonomy needs to be created.");
// see if any taxonomy exists.
if (doGetResources(new CollectionRequest(null, null)).getPropertyMaps().isEmpty()) {
LOG.info("No taxonomies found - going to create default taxonomy.");
Map<String, Object> requestProperties = new HashMap<>();
String defaultTaxonomyName = DEFAULT_TAXONOMY_NAME;
try {
Configuration configuration = ApplicationProperties.get();
defaultTaxonomyName = configuration.getString("atlas.taxonomy.default.name", defaultTaxonomyName);
} catch (AtlasException e) {
LOG.warn("Unable to read Atlas configuration, will use {} as default taxonomy name", defaultTaxonomyName, e);
}
requestProperties.put("name", defaultTaxonomyName);
requestProperties.put("description", DEFAULT_TAXONOMY_DESCRIPTION);
doCreateResource(new InstanceRequest(requestProperties));
LOG.info("Successfully created default taxonomy {}.", defaultTaxonomyName);
} else {
taxonomyAutoInitializationChecked = true;
LOG.info("Some taxonomy exists, not creating default taxonomy");
}
} catch (InvalidQueryException | ResourceNotFoundException e) {
LOG.error("Unable to query for existing taxonomies due to internal error.", e);
} catch (ResourceAlreadyExistsException e) {
LOG.info("Attempted to create default taxonomy and it already exists.");
}
}
}
use of org.apache.atlas.AtlasException in project incubator-atlas by apache.
the class KafkaNotification method start.
// ----- Service ---------------------------------------------------------
@Override
public void start() throws AtlasException {
if (isHAEnabled()) {
LOG.info("Not starting embedded instances when HA is enabled.");
return;
}
if (isEmbedded()) {
try {
startZk();
startKafka();
} catch (Exception e) {
throw new AtlasException("Failed to start embedded kafka", e);
}
}
}
Aggregations