Skip to content
Open
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ try (OutputStream out = new FileOutputStream("simple.json")) {
```
For additional writing helper methods, check [WorkflowWriter](api/src/main/java/org/openworkflow/sdk/api/WorkflowWriter.java) class.

## Jackson dependency

The `openworkflow-api` module depends heavily on Jackson for loading file content into an in-memory POJO. For users who use a JSON handling library other than Jackson, the `openworkflow-types` module contains Java POJOs generated from the OpenWorkflow schema without any Jackson annotations. Using this module as a dependency, they can build a reader/writer module equivalent to `openworkflow-api` with their preferred JSON library.

### Reference implementation

The reference implementation provides a ready-to-use runtime that supports the Open Workflow Specification. It includes a workflow execution engine, validation utilities, and illustrative examples to help you quickly test and deploy your workflows. For details on usage, configuration, and supported features, see [readme](impl/README.md).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,29 @@
*/
package org.openworkflow.sdk.api;

import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import org.openworkflow.sdk.api.types.Workflow;

class DirectReader implements WorkflowReaderOperations {

@Override
public Workflow read(InputStream input, WorkflowFormat format) throws IOException {
public Workflow read(InputStream input, WorkflowFormat format) {
return format.mapper().readValue(input, Workflow.class);
}

@Override
public Workflow read(Reader input, WorkflowFormat format) throws IOException {
public Workflow read(Reader input, WorkflowFormat format) {
return format.mapper().readValue(input, Workflow.class);
}

@Override
public Workflow read(byte[] input, WorkflowFormat format) throws IOException {
public Workflow read(byte[] input, WorkflowFormat format) {
return format.mapper().readValue(input, Workflow.class);
}

@Override
public Workflow read(String input, WorkflowFormat format) throws IOException {
public Workflow read(String input, WorkflowFormat format) {
return format.mapper().readValue(input, Workflow.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
import java.util.Collection;
import java.util.stream.Collectors;
import org.openworkflow.sdk.api.types.Workflow;
import tools.jackson.core.exc.StreamReadException;
import tools.jackson.databind.DatabindException;
import tools.jackson.databind.JsonNode;

class ValidationReader implements WorkflowReaderOperations {
Expand All @@ -48,27 +46,26 @@ class ValidationReader implements WorkflowReaderOperations {
}

@Override
public Workflow read(InputStream input, WorkflowFormat format) throws IOException {
public Workflow read(InputStream input, WorkflowFormat format) {
return validate(format.mapper().readValue(input, JsonNode.class), format);
}

@Override
public Workflow read(Reader input, WorkflowFormat format) throws IOException {
public Workflow read(Reader input, WorkflowFormat format) {
return validate(format.mapper().readValue(input, JsonNode.class), format);
}

@Override
public Workflow read(byte[] input, WorkflowFormat format) throws IOException {
public Workflow read(byte[] input, WorkflowFormat format) {
return validate(format.mapper().readValue(input, JsonNode.class), format);
}

@Override
public Workflow read(String input, WorkflowFormat format) throws IOException {
public Workflow read(String input, WorkflowFormat format) {
return validate(format.mapper().readValue(input, JsonNode.class), format);
}

private Workflow validate(JsonNode value, WorkflowFormat format)
throws StreamReadException, DatabindException, IOException {
private Workflow validate(JsonNode value, WorkflowFormat format) {
Collection<Error> validationErrors = schemaObject.validate(value);
if (!validationErrors.isEmpty()) {
throw new IllegalArgumentException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ public static Workflow readWorkflow(Reader input, WorkflowFormat format) throws
* @param input the byte array containing the workflow definition
* @param format the workflow format
* @return the parsed {@link Workflow}
* @throws IOException if an I/O error occurs
*/
public static Workflow readWorkflow(byte[] input, WorkflowFormat format) throws IOException {
public static Workflow readWorkflow(byte[] input, WorkflowFormat format) {
return defaultReader().read(input, format);
}

Expand Down Expand Up @@ -91,10 +90,8 @@ public static Workflow readWorkflow(Path path, WorkflowFormat format) throws IOE
* @param input the string containing the workflow definition
* @param format the workflow format
* @return the parsed {@link Workflow}
* @throws IOException if an I/O error occurs
*/
public static Workflow readWorkflowFromString(String input, WorkflowFormat format)
throws IOException {
public static Workflow readWorkflowFromString(String input, WorkflowFormat format) {
return defaultReader().read(input, format);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@
*/
package org.openworkflow.sdk.api;

import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import org.openworkflow.sdk.api.types.Workflow;

public interface WorkflowReaderOperations {
Workflow read(InputStream input, WorkflowFormat format) throws IOException;
Workflow read(InputStream input, WorkflowFormat format);

Workflow read(Reader input, WorkflowFormat format) throws IOException;
Workflow read(Reader input, WorkflowFormat format);

Workflow read(byte[] input, WorkflowFormat format) throws IOException;
Workflow read(byte[] input, WorkflowFormat format);

Workflow read(String input, WorkflowFormat format) throws IOException;
Workflow read(String input, WorkflowFormat format);
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,8 @@ public static void writeWorkflow(Path output, Workflow workflow, WorkflowFormat
* @param workflow the workflow object to serialize
* @param format the format to use (JSON or YAML)
* @return the serialized workflow as a string
* @throws IOException if an error occurs during serialization
*/
public static String workflowAsString(Workflow workflow, WorkflowFormat format)
throws IOException {
public static String workflowAsString(Workflow workflow, WorkflowFormat format) {
return format.mapper().writeValueAsString(workflow);
}

Expand Down
Loading