Skip to content

Commit

Permalink
devonfw#103 implemented requested changes
Browse files Browse the repository at this point in the history
renamed SAFE_LATEST to LATEST
  • Loading branch information
jan-vcapgemini committed Apr 2, 2024
1 parent d794e67 commit 998387d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public enum SecurityRiskInteractionAnswer {
LATEST_SAFE,

/**
* User answer to use the latest safe version.
* User answer to use the latest version.
*/
SAFE_LATEST,
LATEST,

/**
* User answer to use the next safe version.
Expand Down
26 changes: 8 additions & 18 deletions cli/src/main/java/com/devonfw/tools/ide/tool/ToolCommandlet.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.devonfw.tools.ide.tool;

import static com.devonfw.tools.ide.tool.SecurityRiskInteractionAnswer.LATEST;
import static com.devonfw.tools.ide.tool.SecurityRiskInteractionAnswer.LATEST_SAFE;
import static com.devonfw.tools.ide.tool.SecurityRiskInteractionAnswer.NEXT_SAFE;
import static com.devonfw.tools.ide.tool.SecurityRiskInteractionAnswer.SAFE_LATEST;
import static com.devonfw.tools.ide.tool.SecurityRiskInteractionAnswer.STAY;

import java.io.IOException;
Expand All @@ -14,9 +14,7 @@
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.devonfw.tools.ide.cli.CliException;
import com.devonfw.tools.ide.commandlet.Commandlet;
import com.devonfw.tools.ide.common.Tag;
import com.devonfw.tools.ide.common.Tags;
Expand All @@ -30,16 +28,9 @@
import com.devonfw.tools.ide.property.StringListProperty;
import com.devonfw.tools.ide.url.model.file.UrlSecurityJsonFile;
import com.devonfw.tools.ide.url.model.file.json.UrlSecurityWarning;
import com.devonfw.tools.ide.util.FilenameUtil;
import com.devonfw.tools.ide.util.Pair;
import com.devonfw.tools.ide.version.VersionIdentifier;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Set;

/**
* {@link Commandlet} for a tool integrated into the IDE.
*/
Expand Down Expand Up @@ -268,7 +259,7 @@ private VersionIdentifier whichVersionDoYouWantToInstall(VersionIdentifier confi
Map<SecurityRiskInteractionAnswer, Pair<String, VersionIdentifier>> options = new HashMap<>();
options.put(STAY, Pair.of("Stay with the current unsafe version (" + current + ").", configuredVersion));
options.put(LATEST_SAFE, Pair.of("Install the latest of all safe versions (" + latestSafe + ").", latestSafe));
options.put(SAFE_LATEST,
options.put(LATEST,
Pair.of("Install the latest version (" + latest + "). This version is save.", VersionIdentifier.LATEST));
options.put(NEXT_SAFE, Pair.of("Install the next safe version (" + nextSafe + ").", nextSafe));

Expand All @@ -278,13 +269,13 @@ private VersionIdentifier whichVersionDoYouWantToInstall(VersionIdentifier confi
return getAnswer(options, currentIsUnsafe + "All newer versions are also not safe. " + ask, STAY, LATEST_SAFE);
} else if (nextSafe.equals(latest)) {
return getAnswer(options, currentIsUnsafe + "Of the newer versions, only the latest is safe. " + ask, STAY,
SAFE_LATEST);
LATEST);
} else if (nextSafe.equals(latestSafe)) {
return getAnswer(options, currentIsUnsafe + "Of the newer versions, only version " + nextSafe
+ " is safe, which is however not the latest. " + ask, STAY, NEXT_SAFE);
} else {
if (latestSafe.equals(latest)) {
return getAnswer(options, currentIsUnsafe + ask, STAY, NEXT_SAFE, SAFE_LATEST);
return getAnswer(options, currentIsUnsafe + ask, STAY, NEXT_SAFE, LATEST);
} else {
return getAnswer(options, currentIsUnsafe + ask, STAY, NEXT_SAFE, LATEST_SAFE);
}
Expand Down Expand Up @@ -445,11 +436,10 @@ public String getInstalledEdition(Path toolPath) {
}
return edition;
} catch (IOException e) {
throw new IllegalStateException(
"Couldn't determine the edition of " + getName() + " from the directory structure of its software path "
+ toolPath
+ ", assuming the name of the parent directory of the real path of the software path to be the edition "
+ "of the tool.", e);
throw new IllegalStateException("Couldn't determine the edition of " + getName()
+ " from the directory structure of its software path " + toolPath
+ ", assuming the name of the parent directory of the real path of the software path to be the edition "
+ "of the tool.", e);
}

}
Expand Down

0 comments on commit 998387d

Please sign in to comment.