use of org.apache.atlas.AtlasException in project incubator-atlas by apache.
the class BaseSecurityTest method getSSLClientFile.
private static File getSSLClientFile() throws AtlasException {
File sslDir;
try {
String persistDir = null;
URL resource = BaseSecurityTest.class.getResource("/");
if (resource != null) {
persistDir = resource.toURI().getPath();
}
assert persistDir != null;
sslDir = new File(persistDir);
// LOG.info("ssl-client.xml will be created in {}", sslDir);
} catch (Exception e) {
throw new AtlasException("Failed to find client configuration directory", e);
}
return new File(sslDir, SSL_CLIENT_PROPERTIES);
}
use of org.apache.atlas.AtlasException in project incubator-atlas by apache.
the class AtlasObjectIdConverter method hasAnyAssignedAttribute.
private boolean hasAnyAssignedAttribute(IReferenceableInstance rInstance) {
boolean ret = false;
if (rInstance instanceof StructInstance) {
StructInstance sInstance = (StructInstance) rInstance;
Map<String, Object> attributes = null;
try {
attributes = sInstance.getValuesMap();
} catch (AtlasException e) {
// ignore
}
if (MapUtils.isNotEmpty(attributes)) {
for (String attrName : attributes.keySet()) {
try {
if (sInstance.isValueSet(attrName)) {
ret = true;
break;
}
} catch (AtlasException e) {
// ignore
}
}
}
} else if (rInstance instanceof Referenceable) {
Referenceable referenceable = (Referenceable) rInstance;
ret = MapUtils.isNotEmpty(referenceable.getValuesMap());
}
return ret;
}
use of org.apache.atlas.AtlasException in project incubator-atlas by apache.
the class AtlasClassificationFormatConverter method fromV1ToV2.
@Override
public AtlasClassification fromV1ToV2(Object v1Obj, AtlasType type, ConverterContext ctx) throws AtlasBaseException {
AtlasClassification ret = null;
if (v1Obj != null) {
AtlasClassificationType classificationType = (AtlasClassificationType) type;
if (v1Obj instanceof Map) {
final Map v1Map = (Map) v1Obj;
final Map v1Attribs = (Map) v1Map.get(ATTRIBUTES_PROPERTY_KEY);
if (MapUtils.isNotEmpty(v1Attribs)) {
ret = new AtlasClassification(type.getTypeName(), fromV1ToV2(classificationType, v1Attribs, ctx));
} else {
ret = new AtlasClassification(type.getTypeName());
}
} else if (v1Obj instanceof IStruct) {
IStruct struct = (IStruct) v1Obj;
Map<String, Object> v1Attribs = null;
try {
v1Attribs = struct.getValuesMap();
} catch (AtlasException excp) {
LOG.error("IStruct.getValuesMap() failed", excp);
}
ret = new AtlasClassification(type.getTypeName(), fromV1ToV2(classificationType, v1Attribs, ctx));
} else {
throw new AtlasBaseException(AtlasErrorCode.UNEXPECTED_TYPE, "Map or IStruct", v1Obj.getClass().getCanonicalName());
}
}
return ret;
}
use of org.apache.atlas.AtlasException in project incubator-atlas by apache.
the class AtlasEntityFormatConverter method fromV1ToV2.
@Override
public AtlasEntity fromV1ToV2(Object v1Obj, AtlasType type, ConverterContext context) throws AtlasBaseException {
AtlasEntity entity = null;
if (v1Obj != null) {
AtlasEntityType entityType = (AtlasEntityType) type;
if (v1Obj instanceof IReferenceableInstance) {
IReferenceableInstance entRef = (IReferenceableInstance) v1Obj;
String guid = entRef.getId()._getId();
if (!context.entityExists(guid)) {
Map<String, Object> v1Attribs = null;
try {
v1Attribs = entRef.getValuesMap();
} catch (AtlasException excp) {
LOG.error("IReferenceableInstance.getValuesMap() failed", excp);
}
entity = new AtlasEntity(entRef.getTypeName(), super.fromV1ToV2(entityType, v1Attribs, context));
entity.setGuid(entRef.getId()._getId());
entity.setStatus(convertState(entRef.getId().getState()));
entity.setCreatedBy(entRef.getSystemAttributes().createdBy);
entity.setCreateTime(entRef.getSystemAttributes().createdTime);
entity.setUpdatedBy(entRef.getSystemAttributes().modifiedBy);
entity.setUpdateTime(entRef.getSystemAttributes().modifiedTime);
entity.setVersion((long) entRef.getId().version);
if (CollectionUtils.isNotEmpty(entRef.getTraits())) {
List<AtlasClassification> classifications = new ArrayList<>();
AtlasFormatConverter traitConverter = converterRegistry.getConverter(TypeCategory.CLASSIFICATION);
for (String traitName : entRef.getTraits()) {
IStruct trait = entRef.getTrait(traitName);
AtlasType classifiType = typeRegistry.getType(traitName);
AtlasClassification classification = (AtlasClassification) traitConverter.fromV1ToV2(trait, classifiType, context);
classifications.add(classification);
}
entity.setClassifications(classifications);
}
} else {
entity = context.getById(guid);
}
} else {
throw new AtlasBaseException(AtlasErrorCode.UNEXPECTED_TYPE, "IReferenceableInstance", v1Obj.getClass().getCanonicalName());
}
}
return entity;
}
use of org.apache.atlas.AtlasException in project incubator-atlas by apache.
the class AtlasInstanceConverter method getTrait.
public ITypedStruct getTrait(AtlasClassification classification) throws AtlasBaseException {
AtlasFormatConverter converter = instanceFormatters.getConverter(TypeCategory.CLASSIFICATION);
AtlasType classificationType = typeRegistry.getType(classification.getTypeName());
Struct trait = (Struct) converter.fromV2ToV1(classification, classificationType, new ConverterContext());
try {
return metadataService.createTraitInstance(trait);
} catch (AtlasException e) {
LOG.error("Exception while getting a typed reference for the entity ", e);
throw toAtlasBaseException(e);
}
}
Aggregations