-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
36 changed files
with
3,416 additions
and
1,494 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
...gurationserver/src/main/java/rocks/inspectit/ocelot/agentstatus/AgentMetaInformation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
...ot-configurationserver/src/main/java/rocks/inspectit/ocelot/config/BeanConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,5 +18,5 @@ public class DefaultUserSettings { | |
private String name; | ||
|
||
private String password; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...ectit-ocelot-configurationserver/src/main/java/rocks/inspectit/ocelot/error/ApiError.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
...ocelot-configurationserver/src/main/java/rocks/inspectit/ocelot/file/FileInfoVisitor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package rocks.inspectit.ocelot.file; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.FileVisitResult; | ||
import java.nio.file.FileVisitor; | ||
import java.nio.file.Path; | ||
import java.nio.file.attribute.BasicFileAttributes; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Stack; | ||
|
||
/** | ||
* FileVisitor for walking a file tree and creating a {@link FileInfo} representation of it. | ||
*/ | ||
@Slf4j | ||
public class FileInfoVisitor implements FileVisitor<Path> { | ||
|
||
/** | ||
* The directory stack. The latest directory is the current one. | ||
*/ | ||
private Stack<FileInfo> directoryStack = new Stack<>(); | ||
|
||
/** | ||
* The {@link FileInfo} which represents the starting directory of the walk. | ||
*/ | ||
private FileInfo rootDirectory; | ||
|
||
@Override | ||
public FileVisitResult preVisitDirectory(Path directory, BasicFileAttributes attrs) { | ||
FileInfo currentDirectory = FileInfo.builder() | ||
.name(directory.getFileName().toString()) | ||
.type(FileInfo.Type.DIRECTORY) | ||
.build(); | ||
|
||
// add directory as child, otherwise set it as root | ||
if (directoryStack.isEmpty()) { | ||
rootDirectory = currentDirectory; | ||
} else { | ||
directoryStack.peek().addChild(currentDirectory); | ||
} | ||
|
||
directoryStack.add(currentDirectory); | ||
|
||
return FileVisitResult.CONTINUE; | ||
} | ||
|
||
@Override | ||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { | ||
// adding each file to the current directory | ||
FileInfo fileInfo = FileInfo.builder() | ||
.name(file.getFileName().toString()) | ||
.type(FileInfo.Type.FILE) | ||
.build(); | ||
|
||
directoryStack.peek().addChild(fileInfo); | ||
|
||
return FileVisitResult.CONTINUE; | ||
} | ||
|
||
@Override | ||
public FileVisitResult visitFileFailed(Path file, IOException exc) { | ||
log.error("Could not visit file '{}'.", file, exc); | ||
return FileVisitResult.CONTINUE; | ||
} | ||
|
||
@Override | ||
public FileVisitResult postVisitDirectory(Path dir, IOException exc) { | ||
// leaving directory, so set stack to the parent directory | ||
directoryStack.pop(); | ||
return FileVisitResult.CONTINUE; | ||
} | ||
|
||
/** | ||
* @return Returns the list of visited files and directories. | ||
*/ | ||
public List<FileInfo> getFileInfos() { | ||
if (rootDirectory == null) { | ||
return Collections.emptyList(); | ||
} else { | ||
List<FileInfo> children = rootDirectory.getChildren(); | ||
if (children == null) { | ||
return Collections.emptyList(); | ||
} else { | ||
return children; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.