- ModuleNodeImpl to = null;
-
- if (moduleGraph.get(toName) == null || !moduleGraph.get(toName).containsKey(toRevision)) {
- // If revision is not specified in import, but module exists
- // with different revisions, take first
- if (moduleGraph.get(toName) != null && !moduleGraph.get(toName).isEmpty()
- && toRevision.equals(DEFAULT_REVISION)) {
- to = moduleGraph.get(toName).values().iterator().next();
- LOGGER.trace(String
- .format("Import:%s:%s by module:%s:%s does not specify revision, using:%s:%s for module dependency sort",
- toName, formatRevDate(toRevision), fromName, formatRevDate(fromRevision), to.getName(),
- formatRevDate(to.getRevision())));
- } else {
- LOGGER.warn(String.format("Not existing module imported:%s:%s by:%s:%s", toName,
- formatRevDate(toRevision), fromName, formatRevDate(fromRevision)));
- LOGGER.warn("Available models: {}", moduleGraph);
- ex(String.format("Not existing module imported:%s:%s by:%s:%s", toName, formatRevDate(toRevision),
- fromName, formatRevDate(fromRevision)));
+
+ final Map<Date, ModuleNodeImpl> modulerevs = moduleGraph.get(toName);
+ if (modulerevs != null) {
+ final ModuleNodeImpl exact = modulerevs.get(toRevision);
+ if (exact != null) {
+ return exact;
+ }
+
+ // If revision is not specified in import, but module exists with different revisions, take first one
+ if (DEFAULT_REVISION.equals(toRevision) && !modulerevs.isEmpty()) {
+ final ModuleNodeImpl first = modulerevs.values().iterator().next();
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Import:{}:{} by module:{}:{} does not specify revision, using:{}:{}"
+ + " for module dependency sort", toName, formatRevDate(toRevision), fromName,
+ formatRevDate(fromRevision), first.getName(), formatRevDate(first.getRevision()));
+ }
+ return first;