Skip to content

Commit b19b877

Browse files
committed
devonfw#103: fixed write json bug, and more
- changed pom.xml - getCpeEdition now has argument, since there is only a single UrlUpdater for multiple editions of a tool - some cleanup
1 parent fe9109f commit b19b877

File tree

6 files changed

+13
-31
lines changed

6 files changed

+13
-31
lines changed

cli/src/main/java/com/devonfw/tools/ide/url/model/file/UrlSecurityJsonFile.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
import java.util.Objects;
1111
import java.util.Set;
1212

13-
import com.devonfw.tools.ide.context.IdeContext;
14-
import com.devonfw.tools.ide.url.model.file.json.UrlSecurityWarning;
15-
import com.devonfw.tools.ide.url.model.file.json.UrlSecurityWarningsJson;
1613
import org.slf4j.Logger;
1714
import org.slf4j.LoggerFactory;
1815

16+
import com.devonfw.tools.ide.context.IdeContext;
1917
import com.devonfw.tools.ide.json.mapping.JsonMapping;
18+
import com.devonfw.tools.ide.url.model.file.json.UrlSecurityWarning;
19+
import com.devonfw.tools.ide.url.model.file.json.UrlSecurityWarningsJson;
2020
import com.devonfw.tools.ide.url.model.folder.UrlEdition;
2121
import com.devonfw.tools.ide.version.VersionIdentifier;
2222
import com.devonfw.tools.ide.version.VersionRange;
@@ -177,7 +177,7 @@ protected void doSave() {
177177

178178
String jsonString;
179179
try {
180-
jsonString = mapper.writeValueAsString(this.urlSecurityWarningsJson.getWarnings());
180+
jsonString = mapper.writeValueAsString(this.urlSecurityWarningsJson);
181181
} catch (JsonProcessingException e) {
182182
throw new RuntimeException(e);
183183
}

cli/src/main/java/com/devonfw/tools/ide/url/updater/AbstractUrlUpdater.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,10 @@ public String getCpeProduct() {
114114
}
115115

116116
/**
117-
* @return the edition of the tool as specified in the CPE (Common Platform Enumeration)
117+
* @param urlEdition the {@link UrlEdition} to get the CPE (Common Platform Enumeration) edition for.
118+
* @return the edition as specified in the CPE.
118119
*/
119-
public String getCpeEdition() {
120+
public String getCpeEdition(String urlEdition) {
120121

121122
return null;
122123
}

cli/src/main/java/com/devonfw/tools/ide/util/MapUtil.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import java.util.Map;
77

88
/**
9-
* Utility class for operations on maps.
9+
* Utility class for operations with maps.
1010
*/
1111
public class MapUtil {
1212

security/pom.xml

+1-15
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
<artifactId>security</artifactId>
1414

1515
<properties>
16-
<maven.compiler.source>17</maven.compiler.source>
17-
<maven.compiler.target>17</maven.compiler.target>
18-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16+
<java.version>17</java.version>
1917
</properties>
2018
<dependencies>
2119
<!-- Other configurations and properties -->
@@ -31,17 +29,5 @@
3129
<scope>compile</scope>
3230
</dependency>
3331
</dependencies>
34-
<build>
35-
<plugins>
36-
<plugin>
37-
<groupId>org.apache.maven.plugins</groupId>
38-
<artifactId>maven-compiler-plugin</artifactId>
39-
<configuration>
40-
<source>9</source>
41-
<target>9</target>
42-
</configuration>
43-
</plugin>
44-
</plugins>
45-
</build>
4632

4733
</project>

security/src/main/java/com/devonfw/tools/security/BuildSecurityJsonFiles.java

+3-8
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
import java.util.Set;
1414
import java.util.stream.Collectors;
1515

16-
import com.devonfw.tools.ide.url.model.folder.UrlVersion;
17-
import com.devonfw.tools.ide.util.MapUtil;
18-
import com.devonfw.tools.ide.version.VersionIdentifier;
1916
import org.owasp.dependencycheck.Engine;
2017
import org.owasp.dependencycheck.analyzer.AbstractAnalyzer;
2118
import org.owasp.dependencycheck.analyzer.AnalysisPhase;
@@ -54,8 +51,11 @@
5451
import com.devonfw.tools.ide.context.IdeContextConsole;
5552
import com.devonfw.tools.ide.log.IdeLogLevel;
5653
import com.devonfw.tools.ide.url.model.file.UrlSecurityJsonFile;
54+
import com.devonfw.tools.ide.url.model.folder.UrlVersion;
5755
import com.devonfw.tools.ide.url.updater.AbstractUrlUpdater;
5856
import com.devonfw.tools.ide.url.updater.UpdateManager;
57+
import com.devonfw.tools.ide.util.MapUtil;
58+
import com.devonfw.tools.ide.version.VersionIdentifier;
5959
import com.devonfw.tools.ide.version.VersionRange;
6060

6161
// TODO Doesn't yet work with versions defined like this /<tool>/<edition>/latest
@@ -123,9 +123,6 @@ private static void run() {
123123
String tool = parent.getParent().getParent().getFileName().toString();
124124
String edition = parent.getParent().getFileName().toString();
125125
AbstractUrlUpdater urlUpdater = updateManager.getUrlUpdater(tool);
126-
127-
System.out.println(tool + ", " + edition);
128-
129126
UrlSecurityJsonFile securityFile = context.getUrls().getEdition(tool, edition).getSecurityJsonFile();
130127
boolean newlyAdded = foundToolsAndEditions.add(new Pair<>(tool, edition));
131128
if (newlyAdded) { // to assure that the file is cleared only once per tool and edition
@@ -272,10 +269,8 @@ private static String getUrlVersion(String cpeVersion, AbstractUrlUpdater urlUpd
272269
if (cpeVersion != null) {
273270
if (cpeToUrlVersion.containsKey(cpeVersion)) {
274271
urlVersion = cpeToUrlVersion.get(cpeVersion);
275-
System.out.println("tool mapped using map cpe " + cpeVersion + " -> url " + urlVersion);
276272
} else {
277273
urlVersion = urlUpdater.mapCpeVersionToUrlVersion(cpeVersion);
278-
System.out.println("tool mapped using mapCpeVersionToUrlVersion cpe " + cpeVersion + " -> url " + urlVersion);
279274

280275
}
281276
}

security/src/main/java/com/devonfw/tools/security/UrlAnalyzer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected void analyzeDependency(Dependency dependency, Engine engine) {
4545
// adding vendor evidence
4646
String cpeVendor = urlUpdater.getCpeVendor();
4747
String cpeProduct = urlUpdater.getCpeProduct();
48-
String cpeEdition = urlUpdater.getCpeEdition();
48+
String cpeEdition = urlUpdater.getCpeEdition(edition);
4949
String cpeVersion = urlUpdater.mapUrlVersionToCpeVersion(parent.getFileName().toString());
5050

5151
if (cpeVendor == null || cpeProduct == null) {

0 commit comments

Comments
 (0)