Skip to content

Commit

Permalink
Merge branch 'master' into feature/update-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
huggsboson authored Jun 3, 2017
2 parents f8fb1d6 + 4e75df4 commit 95b1df8
Show file tree
Hide file tree
Showing 28 changed files with 582 additions and 424 deletions.
39 changes: 25 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
[![License LGPLv3][LGPLv3 badge]][LGPLv3]
[![License ASL 2.0][ASL 2.0 badge]][ASL 2.0]
[![Build Status][Travis badge]][Travis]
![Maven Central](https://img.shields.io/maven-central/v/com.github.fge/json-schema-validator.svg)

## Travis builds now enabled

Builds are now verified by Travis (see [issue #20](https://github.com/daveclayton/json-patch/issues/20) from the json-patch project for details)
Builds are now verified by Travis (see [issue #20](https://github.com/java-json-tools/json-patch/issues/20) from the json-patch project for details)

https://travis-ci.org/daveclayton/json-schema-validator
https://travis-ci.org/java-json-tools/json-schema-validator

## Read me first

The **current** version of this project is licensed under both LGPLv3 (or later) and ASL 2.0. The old version
(2.0.x) was licensed under LGPL 3.0 (or later) only.
The **current** version of this project is licensed under both [LGPLv3] (or later) and [ASL 2.0]. The old version
(2.0.x) was licensed under [LGPL 3.0][LGPLv3] (or later) only.

**Version 2.2 is out**. See [here](https://github.com/daveclayton/json-schema-validator/wiki/Whatsnew_22)
**Version 2.2 is out**. See [here](https://github.com/java-json-tools/json-schema-validator/wiki/Whatsnew_22)
for the list of changes compared to 2.0. And of course, it still has [all the
features](https://github.com/daveclayton/json-schema-validator/wiki/Features) of older versions.

Expand All @@ -34,19 +39,19 @@ timely manner.
## Testing online

You can [test this library online](http://json-schema-validator.herokuapp.com); this web site is in
a [project of its own](https://github.com/daveclayton/json-schema-validator-demo), which you can fork and
a [project of its own](https://github.com/java-json-tools/json-schema-validator-demo), which you can fork and
run by yourself.

## Versions

* current stable version: **2.2.6**
([ChangeLog](https://github.com/daveclayton/json-schema-validator/wiki/ChangeLog_22x),
[Javadoc](http://daveclayton.github.io/json-schema-validator/2.2.x/index.html), [code
samples](http://daveclayton.github.io/json-schema-validator/2.2.x/index.html?com/github/fge/jsonschema/examples/package-summary.html)).
([ChangeLog](https://github.com/java-json-tools/json-schema-validator/wiki/ChangeLog_22x),
[Javadoc](http://java-json-tools.github.io/json-schema-validator/2.2.x/index.html), [code
samples](http://java-json-tools.github.io/json-schema-validator/2.2.x/index.html?com/github/fge/jsonschema/examples/package-summary.html)).
* old stable version: **2.0.4**
([ChangeLog](https://github.com/daveclayton/json-schema-validator/wiki/ChangeLog_20x),
[Javadoc](http://daveclayton.github.io/json-schema-validator/2.0.x/index.html), [code
samples](http://daveclayton.github.io/json-schema-validator/2.0.x/index.html?com/github/fge/jsonschema/examples/package-summary.html)).
([ChangeLog](https://github.com/java-json-tools/json-schema-validator/wiki/ChangeLog_20x),
[Javadoc](http://java-json-tools.github.io/json-schema-validator/2.0.x/index.html), [code
samples](http://java-json-tools.github.io/json-schema-validator/2.0.x/index.html?com/github/fge/jsonschema/examples/package-summary.html)).

## Available downloads

Expand Down Expand Up @@ -100,8 +105,14 @@ This implementation is based on the following drafts:
## More...

For a detailed discussion of the implementation, see
[here](https://github.com/daveclayton/json-schema-validator/wiki/Status).
[here](https://github.com/java-json-tools/json-schema-validator/wiki/Status).

Please see the [wiki](https://github.com/daveclayton/json-schema-validator/wiki/) for more
Please see the [wiki](https://github.com/java-json-tools/json-schema-validator/wiki/) for more
details.

[LGPLv3 badge]: https://img.shields.io/:license-LGPLv3-blue.svg
[LGPLv3]: http://www.gnu.org/licenses/lgpl-3.0.html
[ASL 2.0 badge]: https://img.shields.io/:license-Apache%202.0-blue.svg
[ASL 2.0]: http://www.apache.org/licenses/LICENSE-2.0.html
[Travis Badge]: https://api.travis-ci.org/daveclayton/json-schema-validator.svg?branch=master
[Travis]: https://travis-ci.org/daveclayton/json-schema-validator
97 changes: 40 additions & 57 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,18 @@
* - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
*/

/*
* This has to be here... It will not be taken into account in common.gradle!
*
* Looks like a serious bug... See also:
*
* http://forums.gradle.org/gradle/topics/buildscript_in_subprojects_ignored
*/
/*
* This has to be here... It will not be taken into account in common.gradle!
*
* Looks like a serious bug... See also:
*
* http://forums.gradle.org/gradle/topics/buildscript_in_subprojects_ignored
*
* We also use Spring's propdeps plugin to have a _real_ provided scope. See:
*
* https://github.com/spring-projects/gradle-plugins/tree/master/propdeps-plugin
*/

apply(plugin: "java");
apply(plugin: "maven");
apply(plugin: "signing");
apply(plugin: "osgi");
apply(plugin: "idea");
apply(plugin: "eclipse");

group = "com.github.fge";
version = "2.2.6";
group = "com.github.java-json-tools";
version = "2.2.7";
sourceCompatibility = "1.6";
targetCompatibility = "1.6"; // defaults to sourceCompatibility

project.ext {
description = "A Java implementation of the JSON Schema specification";
};

/*
* Repositories to use
*/
Expand All @@ -63,7 +40,7 @@ repositories {
* List of dependencies
*/
dependencies {
compile(group: "com.github.fge", name: "json-schema-core", version: "1.2.5");
compile(group: "com.github.java-json-tools", name: "json-schema-core", version: "1.2.8");
compile(group: "javax.mail", name: "mailapi", version: "1.4.3");
compile(group: "joda-time", name: "joda-time", version: "2.9.7");
compile(group: "com.googlecode.libphonenumber", name: "libphonenumber", version: "8.0.0");
Expand All @@ -87,7 +64,7 @@ javadoc.options.links("http://fge.github.io/btf/");
javadoc.options.links("http://fge.github.io/msg-simple/");
javadoc.options.links("http://fge.github.io/jackson-coreutils/");
javadoc.options.links("http://fge.github.io/uri-template/");
javadoc.options.links("http://fge.github.io/json-schema-core/1.2.x/");
javadoc.options.links("http://java-json-tools.github.io/json-schema-core/1.2.x/");


/*
Expand Down Expand Up @@ -125,12 +102,14 @@ javadoc.options {
* Equally annoyingly, the docFilesSubDirs option above does not seem to have
* any effect :/
*/
task copyDocFiles(dependsOn: javadoc) << {
copy {
from("src/main/javadoc") {
include "**/doc-files/**";
};
into javadoc.destinationDir;
task copyDocFiles(dependsOn: javadoc) {
doLast {
copy {
from("src/main/javadoc") {
include "**/doc-files/**";
};
into javadoc.destinationDir;
}
}
}

Expand Down Expand Up @@ -164,38 +143,42 @@ artifacts {
}

task wrapper(type: Wrapper) {
gradleVersion = "1.11";
gradleVersion = "3.5";
distributionUrl = "http://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip";
}

task pom << {
pom {}.writeTo("${projectDir}/pom.xml");
task pom {
doLast {
pom {}.writeTo("${projectDir}/pom.xml");
}
}

/*
* SIGNING
*/

project.ext {
gitrwscm = sprintf("[email protected]:fge/%s", name);
gitroscm = sprintf("https://github.com/fge/%s.git", name);
projectURL = sprintf("https://github.com/fge/%s", name);
description = "A Java implementation of the JSON Schema specification";
scmUrl = sprintf("git@github.com:box-metadata/%s", name);
projectURL = sprintf("https://github.com/box-metadata/%s", name);
sonatypeStaging = "https://oss.sonatype.org/service/local/staging/deploy/maven2/";
sonatypeSnapshots = "https://oss.sonatype.org/content/repositories/snapshots/";
};

task checkSigningRequirements << {
def requiredProperties = [ "sonatypeUsername", "sonatypePassword" ];
def noDice = false;
requiredProperties.each {
if (project.properties[it] == null) {
noDice = true;
System.err.printf("property \"%s\" is not defined!", it);
task checkSigningRequirements {
doLast {
def requiredProperties = [ "sonatypeUsername", "sonatypePassword" ];
def noDice = false;
requiredProperties.each {
if (project.properties[it] == null) {
noDice = true;
System.err.printf("property \"%s\" is not defined!", it);
}
}
if (noDice)
throw new IllegalStateException("missing required properties for " +
"upload");
}
if (noDice)
throw new IllegalStateException("missing required properties for " +
"upload");
}

uploadArchives {
Expand Down Expand Up @@ -231,15 +214,15 @@ uploadArchives {
uploadArchives.repositories.mavenDeployer
]*.pom*.whenConfigured { pom ->
pom.project {
name "${name}";
name "${project.name}";
packaging "jar";
description "${description}";
description "${project.ext.description}";
url "${projectURL}";

scm {
url "${gitrwscm}";
connection "${gitrwscm}";
developerConnection "${gitroscm}";
url "${scmUrl}";
connection "scm:git:${scmUrl}";
developerConnection "scm:git:${scmUrl}";
}

licenses {
Expand All @@ -257,9 +240,9 @@ uploadArchives {

developers {
developer {
id "fge";
name "Francis Galiegue";
email "fgaliegue@gmail.com";
id "huggsboson";
name "John Huffaker";
email "jhuffaker+java-json-tools@gmail.com";
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions dorelease.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/bin/bash

# Release instructions
# 1. Follow the gpg setup instructions: http://central.sonatype.org/pages/working-with-pgp-signatures.html
# a. gpg2 --export-secret-keys > ~/.gnupg/secring.gpg
# 2. In ~/.gradle add:
# sonatypeUsername=your sonatype user name
# sonatypePassword=password in vault for oss sonatype<ensure newline>
#
# signing.keyId=generated key
# signing.password=password for gpg key
# signing.secretKeyRingFile=/Users/username/.gnupg/secring.gpg
#
# 3. ./dorelease.sh
# 4. Go to UI at: https://oss.sonatype.org
# 5. Login as sonatypeUsername
# 6. Follow the instructions here: http://central.sonatype.org/pages/releasing-the-deployment.html

./gradlew --recompile-scripts clean test uploadArchives

23 changes: 2 additions & 21 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
#
# Copyright (c) 2014, Francis Galiegue ([email protected])
#
# This software is dual-licensed under:
#
# - the Lesser General Public License (LGPL) version 3.0 or, at your option, any
# later version;
# - the Apache Software License (ASL) version 2.0.
#
# The text of this file and of both licenses is available at the root of this
# project or, if you have the jar distribution, in directory META-INF/, under
# the names LGPL-3.0.txt and ASL-2.0.txt respectively.
#
# Direct link to the sources:
#
# - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
# - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
#

#Mon Apr 14 09:45:58 CEST 2014
#Fri Jun 02 16:48:25 PDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-all.zip
distributionUrl=http\://services.gradle.org/distributions/gradle-3.5-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ public final class DateTimeAttribute
extends AbstractFormatAttribute
{
private static final List<String> FORMATS = ImmutableList.of(
"yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
"yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-MM-dd'T'HH:mm:ss.[0-9]{1,12}Z"
);
private static final DateTimeFormatter FORMATTER;

static {
final DateTimeParser msParser = new DateTimeFormatterBuilder()
.appendLiteral('.').appendDecimal(millisOfSecond(), 1, 3)
final DateTimeParser secFracsParser = new DateTimeFormatterBuilder()
.appendLiteral('.').appendFractionOfSecond(1,12)
.toParser();

DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder();
Expand All @@ -64,7 +64,7 @@ public final class DateTimeAttribute
.appendFixedDecimal(minuteOfHour(), 2)
.appendLiteral(':')
.appendFixedDecimal(secondOfMinute(), 2)
.appendOptional(msParser)
.appendOptional(secFracsParser)
.appendTimeZoneOffset("Z", false, 2, 2);

FORMATTER = builder.toFormatter();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.github.fge.jsonschema.keyword.validator;

import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;

/**
* Interface for a keyword validator factory
*/
public interface KeywordValidatorFactory
{
/**
* Create a validator for the instance
*
* @param node the instance to validate
* @return a validator for the given instance
* @throws ProcessingException an error occurs creating the validator
*/
KeywordValidator getKeywordValidator(JsonNode node)
throws ProcessingException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.github.fge.jsonschema.keyword.validator;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import com.github.fge.jsonschema.messages.JsonSchemaConfigurationBundle;
import com.github.fge.msgsimple.bundle.MessageBundle;
import com.github.fge.msgsimple.load.MessageBundles;

/**
* A validator factory that uses reflection to create an instance of the
* specified KeywordValidator class
*/
public class ReflectionKeywordValidatorFactory
implements KeywordValidatorFactory
{
private static final String ERRMSG = "failed to build keyword validator";
private static final MessageBundle BUNDLE
= MessageBundles.getBundle(JsonSchemaConfigurationBundle.class);

private final Constructor<? extends KeywordValidator> constructor;

public ReflectionKeywordValidatorFactory(String name,
Class<? extends KeywordValidator> clazz)
{
try {
constructor = clazz.getConstructor(JsonNode.class);
} catch (NoSuchMethodException ignored) {
throw new IllegalArgumentException(BUNDLE.printf(
"noAppropriateConstructor", name, clazz.getCanonicalName()
));
}
}

@Override
public KeywordValidator getKeywordValidator(JsonNode node)
throws ProcessingException
{
try {
return constructor.newInstance(node);
} catch (InstantiationException e) {
throw new ProcessingException(ERRMSG, e);
} catch (IllegalAccessException e) {
throw new ProcessingException(ERRMSG, e);
} catch (InvocationTargetException e) {
throw new ProcessingException(ERRMSG, e);
}
}

}
Loading

0 comments on commit 95b1df8

Please sign in to comment.