-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Julien Ruaux
committed
Aug 5, 2022
1 parent
f3ffae7
commit cbee5a7
Showing
84 changed files
with
1,204 additions
and
678 deletions.
There are no files selected for viewing
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
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
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
21 changes: 0 additions & 21 deletions
21
connectors/riot-file/src/main/java/com/redis/riot/file/DumpFileImportOptions.java
This file was deleted.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
connectors/riot-file/src/main/java/com/redis/riot/file/DumpFileOptions.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,47 @@ | ||
package com.redis.riot.file; | ||
|
||
import java.util.Optional; | ||
|
||
import org.springframework.core.io.Resource; | ||
|
||
import picocli.CommandLine.Option; | ||
|
||
public class DumpFileOptions extends FileOptions { | ||
|
||
@Option(names = { "-t", "--filetype" }, description = "File type: ${COMPLETION-CANDIDATES}", paramLabel = "<type>") | ||
protected Optional<DumpFileType> type = Optional.empty(); | ||
|
||
public Optional<DumpFileType> getType() { | ||
return type; | ||
} | ||
|
||
public void setType(DumpFileType type) { | ||
this.type = Optional.of(type); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "DumpFileOptions [type=" + type + ", encoding=" + encoding + ", gzip=" + gzip + ", s3=" + s3 + ", gcs=" | ||
+ gcs + "]"; | ||
} | ||
|
||
public DumpFileType type(Resource resource) { | ||
if (type.isPresent()) { | ||
return type.get(); | ||
} | ||
Optional<FileExtension> extension = FileUtils.extension(resource); | ||
if (extension.isEmpty()) { | ||
throw new UnknownFileTypeException("Unknown file extension"); | ||
} | ||
switch (extension.get()) { | ||
case XML: | ||
return DumpFileType.XML; | ||
case JSON: | ||
return DumpFileType.JSON; | ||
default: | ||
throw new UnsupportedOperationException("Unsupported file extension: " + extension.get()); | ||
} | ||
|
||
} | ||
|
||
} |
14 changes: 1 addition & 13 deletions
14
connectors/riot-file/src/main/java/com/redis/riot/file/DumpFileType.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 |
---|---|---|
@@ -1,19 +1,7 @@ | ||
package com.redis.riot.file; | ||
|
||
import java.util.Optional; | ||
|
||
public enum DumpFileType { | ||
|
||
JSON, XML; | ||
JSON, XML | ||
|
||
public static DumpFileType of(String file, Optional<DumpFileType> type) { | ||
if (type.isPresent()) { | ||
return type.get(); | ||
} | ||
Optional<String> extension = FileUtils.extension(file); | ||
if (extension.isPresent() && extension.get().equalsIgnoreCase(FileUtils.EXTENSION_XML)) { | ||
return XML; | ||
} | ||
return JSON; | ||
} | ||
} |
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
Oops, something went wrong.