/** * Returns the set of nodes for the project * * @return an instance of {@link INodeSet} */ @Override public INodeSet getNodeSet() { // iterate through sources, and add nodes final NodeSetMerge list = getNodeSetMerge(); Map<String, Exception> exceptions = Collections.synchronizedMap(new HashMap<String, Exception>()); int index = 1; Set<String> validSources = new HashSet<>(); for (final ResourceModelSource nodesSource : getResourceModelSources()) { try { INodeSet nodes = nodesSource.getNodes(); if (null == nodes) { logger.warn("Empty nodes result from [" + nodesSource.toString() + "]"); } else { list.addNodeSet(nodes); } boolean hasErrors = false; if (nodesSource instanceof ResourceModelSourceErrors) { ResourceModelSourceErrors nodeerrors = (ResourceModelSourceErrors) nodesSource; List<String> modelSourceErrors = nodeerrors.getModelSourceErrors(); if (modelSourceErrors != null && modelSourceErrors.size() > 0) { hasErrors = true; logger.error( "Some errors getting nodes from [" + nodesSource.toString() + "]: " + modelSourceErrors); exceptions.put( index + ".source", new ResourceModelSourceException( TextUtils.join( modelSourceErrors.toArray(new String[modelSourceErrors.size()]), ';'))); } } if (!hasErrors) { validSources.add(index + ".source"); } } catch (ResourceModelSourceException | RuntimeException e) { logger.error("Cannot get nodes from [" + nodesSource.toString() + "]: " + e.getMessage()); logger.debug( "Cannot get nodes from [" + nodesSource.toString() + "]: " + e.getMessage(), e); exceptions.put(index + ".source", new ResourceModelSourceException(e.getMessage(), e)); } catch (Throwable e) { logger.error("Cannot get nodes from [" + nodesSource.toString() + "]: " + e.getMessage()); logger.debug( "Cannot get nodes from [" + nodesSource.toString() + "]: " + e.getMessage(), e); exceptions.put(index + ".source", new ResourceModelSourceException(e.getMessage())); } index++; } synchronized (nodesSourceExceptions) { nodesSourceExceptions.putAll(exceptions); for (String validSource : validSources) { nodesSourceExceptions.remove(validSource); } } return list; }