Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isExpectedFolder(): log level now generic with default being WARNING #1118

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cli/src/main/java/com/devonfw/tools/ide/io/FileAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import java.util.function.Function;
import java.util.function.Predicate;

import com.devonfw.tools.ide.log.IdeLogLevel;

/**
* Interface that gives access to various operations on files.
*/
Expand Down Expand Up @@ -50,6 +52,13 @@ public interface FileAccess {
*/
boolean isExpectedFolder(Path folder);

/**
* @param folder the {@link Path} to check.
* @param logLevel the {@link IdeLogLevel} to use in case the folder does not exist
* @return {@code true} if the given {@code folder} points to an existing directory, {@code false} otherwise.
*/
boolean isExpectedFolder(Path folder, IdeLogLevel logLevel);

/**
* @param file the {@link Path} to compute the checksum of.
* @param hashAlgorithm the hash algorithm (e.g. SHA-266).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import com.devonfw.tools.ide.cli.CliException;
import com.devonfw.tools.ide.cli.CliOfflineException;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.log.IdeLogLevel;
import com.devonfw.tools.ide.os.SystemInfoImpl;
import com.devonfw.tools.ide.process.ProcessContext;
import com.devonfw.tools.ide.util.DateTimeUtil;
Expand Down Expand Up @@ -223,10 +224,16 @@ public boolean isFile(Path file) {
@Override
public boolean isExpectedFolder(Path folder) {

return isExpectedFolder(folder, IdeLogLevel.WARNING);
}

@Override
public boolean isExpectedFolder(Path folder, IdeLogLevel logLevel) {

if (Files.isDirectory(folder)) {
return true;
}
this.context.warning("Expected folder was not found at {}", folder);
this.context.level(logLevel).log("Expected folder was not found at {}", folder);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.devonfw.tools.ide.common.Tag;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.io.FileAccess;
import com.devonfw.tools.ide.log.IdeLogLevel;
import com.devonfw.tools.ide.process.ProcessMode;
import com.devonfw.tools.ide.step.Step;
import com.devonfw.tools.ide.tool.ToolCommandlet;
Expand Down Expand Up @@ -62,7 +63,7 @@ protected void configureWorkspace() {

FileAccess fileAccess = this.context.getFileAccess();
Path workspaceFolder = this.context.getWorkspacePath();
if (!fileAccess.isExpectedFolder(workspaceFolder)) {
if (!fileAccess.isExpectedFolder(workspaceFolder, IdeLogLevel.DEBUG)) {
this.context.warning("Current workspace does not exist: {}", workspaceFolder);
return; // should actually never happen...
}
Expand Down