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

Bump com.apicatalog:iridium-cbor-ld from 0.1.3 to 0.2.0 #96

Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/executables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
uses: graalvm/setup-graalvm@v1
with:
version: 'latest'
java-version: '17'
java-version: '21'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v1
with:
java-version: 17
java-version: 21
- name: Build with Maven
env:
GITHUB_ACTOR: ${{ github.actor }}
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.apicatalog</groupId>
<artifactId>ld-cli</artifactId>
<version>0.8.0</version>
<version>0.9.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>A Command Line Processor for Linked Data Processing</name>

<url>https://github.com/filip26/ld-cli</url>

<properties>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -26,7 +26,7 @@
<command.name>ld-cli</command.name>

<titanium.version>1.4.1</titanium.version>
<iridium.version>0.1.3</iridium.version>
<iridium.version>0.2.0</iridium.version>
<jakarta.json-p.version>2.0.1</jakarta.json-p.version>

<graal.version>24.0.2</graal.version>
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/apicatalog/cli/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
optionListHeading = "%nOptions:%n",
commandListHeading = "%nCommands:%n",
version = {
"ld-cli 0.8.0 https://github.com/filip26/ld-cli",
"titanium-json-ld 1.3.1 https://github.com/filip26/titanium-json-ld",
"iridium-cbor-ld 0.1.1 https://github.com/filip26/iridium-cbor-ld",
"ld-cli 0.9.0 https://github.com/filip26/ld-cli",
"titanium-json-ld 1.4.1 https://github.com/filip26/titanium-json-ld",
"iridium-cbor-ld 0.2.0 https://github.com/filip26/iridium-cbor-ld",
}
)
public final class App {
Expand All @@ -49,7 +49,7 @@ public final class App {
boolean version;

static {
((HttpLoader) HttpLoader.defaultInstance()).setFallbackContentType(MediaType.JSON);
((HttpLoader) HttpLoader.defaultInstance()).fallbackContentType(MediaType.JSON);
}

public static void main(String[] args) {
Expand Down
58 changes: 26 additions & 32 deletions src/main/java/com/apicatalog/cli/command/CompressCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import java.util.concurrent.Callable;

import com.apicatalog.cborld.CborLd;
import com.apicatalog.cborld.barcode.BarcodesConfig;
import com.apicatalog.cborld.config.DefaultConfig;
import com.apicatalog.cborld.db.DbConfig;
import com.apicatalog.cborld.config.V05Config;
import com.apicatalog.cborld.encoder.EncoderConfig;
import com.apicatalog.jsonld.document.Document;
import com.apicatalog.jsonld.document.JsonDocument;
Expand All @@ -22,15 +23,7 @@
import picocli.CommandLine.Parameters;
import picocli.CommandLine.Spec;

@Command(
name = "compress",
mixinStandardHelpOptions = false,
description = "Compress JSON-LD document into CBOR-LD",
sortOptions = true,
descriptionHeading = "%n",
parameterListHeading = "%nParameters:%n",
optionListHeading = "%nOptions:%n"
)
@Command(name = "compress", mixinStandardHelpOptions = false, description = "Compress JSON-LD document into CBOR-LD", sortOptions = true, descriptionHeading = "%n", parameterListHeading = "%nParameters:%n", optionListHeading = "%nOptions:%n")
public final class CompressCmd implements Callable<Integer> {

@Option(names = { "-h", "--help" }, hidden = true, usageHelp = true)
Expand All @@ -39,22 +32,23 @@ public final class CompressCmd implements Callable<Integer> {
@Option(names = { "-i", "--input" }, description = "input document IRI")
URI input = null;

@Parameters(index = "0", arity = "1", description = "output document filename" )
@Parameters(index = "0", arity = "1", description = "output document filename")
String output = null;

@Option(names = { "-b", "--base" }, description = "input document base IRI")
URI base = null;

@Option(names = { "-a", "--keep-arrays" }, description = "keep arrays with just one element")
boolean keepArrays = false;
@Option(names = { "-m", "--mode" }, description = "processing mode", paramLabel = "default|digitalbazaar")

@Option(names = { "-m", "--mode" }, description = "processing mode", paramLabel = "default|barcodes|v05")
String mode = "default";

@Spec
CommandSpec spec;

private CompressCmd() {}
private CompressCmd() {
}

@Override
public Integer call() throws Exception {
Expand All @@ -64,35 +58,35 @@ public Integer call() throws Exception {
if (input != null) {
final DocumentLoader loader = SchemeRouter.defaultInstance();
document = loader.loadDocument(input, new DocumentLoaderOptions());

} else {
document = JsonDocument.of(System.in);
document = JsonDocument.of(System.in);
}

final JsonStructure json = document.getJsonContent().orElseThrow(() -> new IllegalArgumentException("Invalid input document. JSON document expected but got [" + document.getContentType() + "]."));

final JsonStructure json = document.getJsonContent()
.orElseThrow(() -> new IllegalArgumentException("Invalid input document. JSON document expected but got [" + document.getContentType() + "]."));

if (JsonUtils.isNotObject(json)) {
throw new IllegalArgumentException("The input docunent root is not JSON object but [" + json.getValueType() + "].");
}

EncoderConfig config = DefaultConfig.INSTANCE;

if ("digitalbazaar".equalsIgnoreCase(mode)) {
config = DbConfig.INSTANCE;
}
final EncoderConfig config = switch (mode) {
case "barcodes" -> BarcodesConfig.INSTANCE;
case "v05" -> V05Config.INSTANCE;
default -> DefaultConfig.INSTANCE;
};

final byte[] encoded = CborLd.encoder(json.asJsonObject())
.config(config)
.base(base)
.compactArray(!keepArrays)
.encode();

final byte[] encoded = CborLd.createEncoder(config)
.base(base)
.compactArray(!keepArrays)
.build()
.encode(json.asJsonObject());

try (FileOutputStream os = new FileOutputStream(output)) {
os.write(encoded);
os.flush();
}
return spec.exitCodeOnSuccess();

return spec.exitCodeOnSuccess();
}
}
52 changes: 23 additions & 29 deletions src/main/java/com/apicatalog/cli/command/DecompressCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
import java.util.concurrent.Callable;

import com.apicatalog.cborld.CborLd;
import com.apicatalog.cborld.barcode.BarcodesConfig;
import com.apicatalog.cborld.config.DefaultConfig;
import com.apicatalog.cborld.db.DbConfig;
import com.apicatalog.cborld.config.V05Config;
import com.apicatalog.cborld.decoder.DecoderConfig;
import com.apicatalog.cli.JsonOutput;

Expand All @@ -19,15 +20,7 @@
import picocli.CommandLine.Parameters;
import picocli.CommandLine.Spec;

@Command(
name = "decompress",
mixinStandardHelpOptions = false,
description = "Decompress CBOR-LD document into JSON-LD",
sortOptions = true,
descriptionHeading = "%n",
parameterListHeading = "%nParameters:%n",
optionListHeading = "%nOptions:%n"
)
@Command(name = "decompress", mixinStandardHelpOptions = false, description = "Decompress CBOR-LD document into JSON-LD", sortOptions = true, descriptionHeading = "%n", parameterListHeading = "%nParameters:%n", optionListHeading = "%nOptions:%n")
public final class DecompressCmd implements Callable<Integer> {

@Option(names = { "-h", "--help" }, hidden = true, usageHelp = true)
Expand All @@ -41,36 +34,37 @@ public final class DecompressCmd implements Callable<Integer> {

@Option(names = { "-b", "--base" }, description = "input document base IRI")
URI base = null;

@Option(names = { "-a", "--keep-arrays" }, description = "keep arrays with just one element")
boolean keepArrays = false;
@Option(names = { "-m", "--mode" }, description = "processing mode", paramLabel = "default|digitalbazaar")

@Option(names = { "-m", "--mode" }, description = "processing mode", paramLabel = "default|barcodes|v05")
String mode = "default";

@Spec
CommandSpec spec;

private DecompressCmd() {}
private DecompressCmd() {
}

@Override
public Integer call() throws Exception {

byte[] encoded = Files.readAllBytes(input.toPath());
DecoderConfig config = DefaultConfig.INSTANCE;

if ("digitalbazaar".equalsIgnoreCase(mode)) {
config = DbConfig.INSTANCE;
}
final JsonValue output = CborLd.decoder(encoded)
.config(config)
.base(base)
.compactArray(!keepArrays)
.decode();

JsonOutput.print((JsonStructure)output, pretty);
final byte[] encoded = Files.readAllBytes(input.toPath());

final DecoderConfig config = switch (mode) {
case "barcodes" -> BarcodesConfig.INSTANCE;
case "v05" -> V05Config.INSTANCE;
default -> DefaultConfig.INSTANCE;
};

final JsonValue output = CborLd.createDecoder(config)
.base(base)
.compactArray(!keepArrays)
.build()
.decode(encoded);

JsonOutput.print((JsonStructure) output, pretty);

return spec.exitCodeOnSuccess();
}
Expand Down
Loading