diff --git a/src/main/java/com/jfrog/ide/common/nodes/DependencyNode.java b/src/main/java/com/jfrog/ide/common/nodes/DependencyNode.java index 567f11ab..6aec1f71 100644 --- a/src/main/java/com/jfrog/ide/common/nodes/DependencyNode.java +++ b/src/main/java/com/jfrog/ide/common/nodes/DependencyNode.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonProperty; -import com.jfrog.ide.common.nodes.subentities.ImpactTreeNode; +import com.jfrog.ide.common.nodes.subentities.ImpactTree; import com.jfrog.ide.common.nodes.subentities.License; import com.jfrog.ide.common.nodes.subentities.Severity; import org.apache.commons.lang3.StringUtils; @@ -22,7 +22,7 @@ public class DependencyNode extends SortableChildrenTreeNode implements Subtitle @JsonProperty() private boolean indirect; @JsonProperty() - private ImpactTreeNode impactPaths; + private ImpactTree impactTree; @JsonProperty() private List licenses; @@ -74,13 +74,13 @@ public Severity getSeverity() { @JsonGetter() @SuppressWarnings("unused") - public ImpactTreeNode getImpactPaths() { - return impactPaths; + public ImpactTree getImpactTree() { + return impactTree; } @SuppressWarnings("unused") - public void setImpactPaths(ImpactTreeNode impactPaths) { - this.impactPaths = impactPaths; + public void setImpactTree(ImpactTree impactTree) { + this.impactTree = impactTree; } public void addIssue(IssueNode issue) { diff --git a/src/main/java/com/jfrog/ide/common/nodes/subentities/ImpactTree.java b/src/main/java/com/jfrog/ide/common/nodes/subentities/ImpactTree.java new file mode 100644 index 00000000..6546a4cb --- /dev/null +++ b/src/main/java/com/jfrog/ide/common/nodes/subentities/ImpactTree.java @@ -0,0 +1,37 @@ +package com.jfrog.ide.common.nodes.subentities; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class ImpactTree { + @JsonProperty + private ImpactTreeNode root; + @JsonProperty + private int impactPathsCount = 0; + + // Empty constructor for deserialization + @SuppressWarnings("unused") + public ImpactTree() { + } + + public ImpactTree(ImpactTreeNode root) { + this.root = root; + } + + public boolean contains(String name) { + return root.contains(name); + } + + public ImpactTreeNode getRoot() { + return root; + } + + @SuppressWarnings("unused") + public int getImpactPathsCount() { + return impactPathsCount; + } + + @SuppressWarnings("unused") + public void incImpactPathsCount() { + this.impactPathsCount++; + } +} diff --git a/src/main/java/com/jfrog/ide/common/persistency/ScanCache.java b/src/main/java/com/jfrog/ide/common/persistency/ScanCache.java index 51a5142b..64f0d1c0 100644 --- a/src/main/java/com/jfrog/ide/common/persistency/ScanCache.java +++ b/src/main/java/com/jfrog/ide/common/persistency/ScanCache.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator; import com.jfrog.ide.common.log.Utils; import com.jfrog.ide.common.nodes.FileTreeNode; +import lombok.Getter; import org.jfrog.build.api.util.Log; import java.io.File; @@ -27,6 +28,7 @@ public class ScanCache { private final File file; private final ObjectMapper objectMapper; + @Getter private ScanCacheObject scanCacheObject; /** @@ -68,10 +70,6 @@ public void cacheNodes(List nodes) throws IOException { objectMapper.writeValue(file, scanCacheObject); } - public ScanCacheObject getScanCacheObject() { - return scanCacheObject; - } - public void deleteScanCacheObject() throws IOException { if (file.exists()) { if (!file.delete()) { @@ -84,7 +82,8 @@ private void readCachedNodes(Log logger) throws IOException { try { scanCacheObject = objectMapper.readValue(file, ScanCacheObject.class); if (scanCacheObject.getVersion() != ScanCacheObject.CACHE_VERSION) { - logger.warn("Invalid cache version " + scanCacheObject.getVersion() + ". Ignoring the old cache and starting a new one."); + logger.info("Invalid cache version " + scanCacheObject.getVersion() + ". Ignoring the old cache and starting a new one."); + scanCacheObject = null; } } catch (JsonParseException | JsonMappingException e) { Utils.logError(logger, "Failed reading cache file. Ignoring the old cache and starting a new one.", e, false); diff --git a/src/main/java/com/jfrog/ide/common/persistency/ScanCacheObject.java b/src/main/java/com/jfrog/ide/common/persistency/ScanCacheObject.java index 6e9e4e5a..1733613e 100644 --- a/src/main/java/com/jfrog/ide/common/persistency/ScanCacheObject.java +++ b/src/main/java/com/jfrog/ide/common/persistency/ScanCacheObject.java @@ -12,7 +12,7 @@ */ @Getter public class ScanCacheObject { - static int CACHE_VERSION = 4; + static int CACHE_VERSION = 5; @JsonProperty("version") int version = CACHE_VERSION;