// Path: src/main/java/de/galan/verjson/step/ProcessStepException.java
// public class ProcessStepException extends ReadException {
// 
// 	public ProcessStepException(String message) {
// 		super(message);
// 	}
// 
// 
// 	public ProcessStepException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// 
// }
// 
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
// 
// 	/** Perform action on wrapped root node */
// 	public void process(JsonNode node) throws ProcessStepException;
// 
// }
// 
// Path: src/main/java/de/galan/verjson/util/MetaWrapper.java
// public class MetaWrapper {
// 
// 	public static final String ID_VERSION = "$v";
// 	public static final String ID_NAMESPACE = "$ns";
// 	public static final String ID_DATA = "$d";
// 	public static final String ID_TIMESTAMP = "$ts";
// 
// 	/** Incremental version */
// 	@JsonProperty(ID_VERSION)
// 	private long version;
// 
// 	/** Namespace for the data object */
// 	@JsonProperty(ID_NAMESPACE)
// 	private String namespace;
// 
// 	/** Timestamp when the object was serialized */
// 	@JsonProperty(ID_TIMESTAMP)
// 	private Date timestamp;
// 
// 	/** Actual payload */
// 	@JsonProperty(ID_DATA)
// 	private Object data;
// 
// 
// 	public MetaWrapper(long version, String namespace, Object data, Date timestamp) {
// 		this.version = version;
// 		this.namespace = namespace;
// 		this.data = data;
// 		this.timestamp = timestamp;
// 	}
// 
// 
// 	/** Returns the data node from a wrapped JsonNode */
// 	public static JsonNode getData(JsonNode node) {
// 		return getObj(obj(node), MetaWrapper.ID_DATA);
// 	}
// 
// 
// 	/** Returns the namespace from a wrapped JsonNode */
// 	public static String getNamespace(JsonNode node) {
// 		JsonNode nodeNs = obj(node).get(ID_NAMESPACE);
// 		return (nodeNs != null) ? nodeNs.asText() : null;
// 	}
// 
// 
// 	/** Returns the source version from a wrapped JsonNode */
// 	public static Long getVersion(JsonNode node) {
// 		return obj(node).get(ID_VERSION).asLong();
// 	}
// 
// 
// 	/** Sets the version on a wrapped JsonNode */
// 	public static void setVersion(JsonNode node, Long version) {
// 		obj(node).put(ID_VERSION, version);
// 	}
// 
// 
// 	/** Returns the timestamp from a wrapped JsonNode */
// 	public static Date getTimestamp(JsonNode node) {
// 		String text = obj(node).get(ID_TIMESTAMP).asText();
// 		return isNotBlank(text) ? from(instantUtc(text)).toDate() : null;
// 	}
// 
// }


import static org.apache.commons.lang3.StringUtils.*;
import java.io.IOException;
import java.util.List;
import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jackson.JsonLoader;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import com.github.fge.jsonschema.core.report.ProcessingMessage;
import com.github.fge.jsonschema.core.report.ProcessingReport;
import com.github.fge.jsonschema.main.JsonSchema;
import com.github.fge.jsonschema.main.JsonSchemaFactory;
import com.google.common.base.StandardSystemProperty;
import com.google.common.collect.Lists;
import de.galan.verjson.step.ProcessStepException;
import de.galan.verjson.step.Step;
import de.galan.verjson.util.MetaWrapper;
package de.galan.verjson.step.validation;






/**
 * Creates a JSON Schema Validator to check json against it, using https://github.com/fge/json-schema-validator
 *
 * @author daniel
 */
public class Validation implements Step {

	protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();

	String description;
	JsonSchema schema; // thread-safe
	static JsonSchemaFactory factory; // cached


	public Validation(String schema) {
		this(schema, null);
	}


	public Validation(String schema, String description) {
		this.description = description;
		this.schema = create(schema);
	}


	public String getDescription() {
		return description;
	}


	protected String getDescriptionAppendable() {
		return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
	}


	protected static synchronized JsonSchemaFactory getFactory() {
		if (factory == null) {
			factory = JsonSchemaFactory.byDefault();
		}
		return factory;
	}


	protected JsonSchemaFactory getJsonSchemaFactory() {
		return getFactory();
	}


	@Override
	public void process(JsonNode node) throws ProcessStepException {
// Path: src/main/java/de/galan/verjson/step/ProcessStepException.java
// public class ProcessStepException extends ReadException {
// 
// 	public ProcessStepException(String message) {
// 		super(message);
// 	}
// 
// 
// 	public ProcessStepException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// 
// }
// 
// Path: src/main/java/de/galan/verjson/step/Step.java
// public interface Step {
// 
// 	/** Perform action on wrapped root node */
// 	public void process(JsonNode node) throws ProcessStepException;
// 
// }
// 
// Path: src/main/java/de/galan/verjson/util/MetaWrapper.java
// public class MetaWrapper {
// 
// 	public static final String ID_VERSION = "$v";
// 	public static final String ID_NAMESPACE = "$ns";
// 	public static final String ID_DATA = "$d";
// 	public static final String ID_TIMESTAMP = "$ts";
// 
// 	/** Incremental version */
// 	@JsonProperty(ID_VERSION)
// 	private long version;
// 
// 	/** Namespace for the data object */
// 	@JsonProperty(ID_NAMESPACE)
// 	private String namespace;
// 
// 	/** Timestamp when the object was serialized */
// 	@JsonProperty(ID_TIMESTAMP)
// 	private Date timestamp;
// 
// 	/** Actual payload */
// 	@JsonProperty(ID_DATA)
// 	private Object data;
// 
// 
// 	public MetaWrapper(long version, String namespace, Object data, Date timestamp) {
// 		this.version = version;
// 		this.namespace = namespace;
// 		this.data = data;
// 		this.timestamp = timestamp;
// 	}
// 
// 
// 	/** Returns the data node from a wrapped JsonNode */
// 	public static JsonNode getData(JsonNode node) {
// 		return getObj(obj(node), MetaWrapper.ID_DATA);
// 	}
// 
// 
// 	/** Returns the namespace from a wrapped JsonNode */
// 	public static String getNamespace(JsonNode node) {
// 		JsonNode nodeNs = obj(node).get(ID_NAMESPACE);
// 		return (nodeNs != null) ? nodeNs.asText() : null;
// 	}
// 
// 
// 	/** Returns the source version from a wrapped JsonNode */
// 	public static Long getVersion(JsonNode node) {
// 		return obj(node).get(ID_VERSION).asLong();
// 	}
// 
// 
// 	/** Sets the version on a wrapped JsonNode */
// 	public static void setVersion(JsonNode node, Long version) {
// 		obj(node).put(ID_VERSION, version);
// 	}
// 
// 
// 	/** Returns the timestamp from a wrapped JsonNode */
// 	public static Date getTimestamp(JsonNode node) {
// 		String text = obj(node).get(ID_TIMESTAMP).asText();
// 		return isNotBlank(text) ? from(instantUtc(text)).toDate() : null;
// 	}
// 
// }


// Path: src/main/java/de/galan/verjson/step/validation/Validation.java
import static org.apache.commons.lang3.StringUtils.*;
import java.io.IOException;
import java.util.List;
import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jackson.JsonLoader;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import com.github.fge.jsonschema.core.report.ProcessingMessage;
import com.github.fge.jsonschema.core.report.ProcessingReport;
import com.github.fge.jsonschema.main.JsonSchema;
import com.github.fge.jsonschema.main.JsonSchemaFactory;
import com.google.common.base.StandardSystemProperty;
import com.google.common.collect.Lists;
import de.galan.verjson.step.ProcessStepException;
import de.galan.verjson.step.Step;
import de.galan.verjson.util.MetaWrapper;

package de.galan.verjson.step.validation;






/**
 * Creates a JSON Schema Validator to check json against it, using https://github.com/fge/json-schema-validator
 *
 * @author daniel
 */
public class Validation implements Step {

	protected final static String LS = StandardSystemProperty.LINE_SEPARATOR.value();

	String description;
	JsonSchema schema; // thread-safe
	static JsonSchemaFactory factory; // cached


	public Validation(String schema) {
		this(schema, null);
	}


	public Validation(String schema, String description) {
		this.description = description;
		this.schema = create(schema);
	}


	public String getDescription() {
		return description;
	}


	protected String getDescriptionAppendable() {
		return isBlank(getDescription()) ? EMPTY : (" (" + getDescription() + ")");
	}


	protected static synchronized JsonSchemaFactory getFactory() {
		if (factory == null) {
			factory = JsonSchemaFactory.byDefault();
		}
		return factory;
	}


	protected JsonSchemaFactory getJsonSchemaFactory() {
		return getFactory();
	}


	@Override
	public void process(JsonNode node) throws ProcessStepException {
		validate(MetaWrapper.getData(node));