use of alien4cloud.exception.IndexingServiceException in project alien4cloud by alien4cloud.
the class IndexedModelUtils method orderByDerivedFromHierarchy.
/**
* This utility method returns an ordered {@link AbstractInheritableToscaType} collection. The parent elements will be before
* the children elements
* This utility method returns an ordered {@link AbstractInheritableToscaType} collection. The parent elements will be before the children elements
*
* @param elementsByIdMap map of {@link AbstractInheritableToscaType} by id
* @return
*/
public static <T extends AbstractInheritableToscaType> List<T> orderByDerivedFromHierarchy(final Map<String, T> elementsByIdMap) {
if (elementsByIdMap == null) {
return null;
}
List<T> orderedElements = new ArrayList<T>(elementsByIdMap.values());
final Map<String, Integer> elementsLevelMap = Maps.newHashMap();
for (AbstractInheritableToscaType element : orderedElements) {
AbstractInheritableToscaType parent = element;
int levelCount = 0;
while (true) {
if (parent.getDerivedFrom() == null || parent.getDerivedFrom().isEmpty()) {
break;
}
AbstractInheritableToscaType oldParent = parent;
parent = elementsByIdMap.get(parent.getDerivedFrom().get(0));
if (parent == null) {
break;
}
if (oldParent.equals(parent)) {
// This error must have been normally detected in the validation phase and so here it means that it's a bug in our code of validation
throw new IndexingServiceException(parent.getElementId() + " is parent of it-self, bug in csar validation service");
}
levelCount++;
}
elementsLevelMap.put(element.getElementId(), levelCount);
}
Collections.sort(orderedElements, (left, right) -> elementsLevelMap.get(left.getElementId()).compareTo(elementsLevelMap.get(right.getElementId())));
return orderedElements;
}
use of alien4cloud.exception.IndexingServiceException in project alien4cloud by alien4cloud.
the class AuditESDAO method init.
@PostConstruct
public void init() {
try {
getMappingBuilder().initialize("alien4cloud.audit.model");
} catch (IntrospectionException | IOException e) {
throw new IndexingServiceException("Could not initialize elastic search mapping builder", e);
}
// Audit trace index
initIndices(ALIEN_AUDIT_INDEX, auditTtl, AuditTrace.class, AuditConfiguration.class);
initCompleted();
}
use of alien4cloud.exception.IndexingServiceException in project alien4cloud by alien4cloud.
the class ElasticSearchGroupDao method initEnvironment.
@PostConstruct
public void initEnvironment() {
// init ES annotation scanning
try {
mappingBuilder.initialize(Group.class.getPackage().getName());
} catch (IntrospectionException | IOException e) {
throw new IndexingServiceException("Could not initialize elastic search mapping builder", e);
}
// init indexes and mapped classes
initIndices(Group.class.getSimpleName().toLowerCase(), null, new Class<?>[] { Group.class });
initCompleted();
}
Aggregations