-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
d27cacc
commit 1d354d7
Showing
5 changed files
with
151 additions
and
1 deletion.
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
38 changes: 38 additions & 0 deletions
38
...s-core/src/main/java/org/devgateway/jocds/jsonschema/checker/DeprecatedSyntaxChecker.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,38 @@ | ||
/* | ||
* Copyright (c) 2017. Development Gateway and contributors. All rights reserved. | ||
* Licensed under the MIT license. See LICENSE file in the project root for details. | ||
*/ | ||
|
||
package org.devgateway.jocds.jsonschema.checker; | ||
|
||
import com.github.fge.jackson.NodeType; | ||
import com.github.fge.jackson.jsonpointer.JsonPointer; | ||
import com.github.fge.jsonschema.core.exceptions.ProcessingException; | ||
import com.github.fge.jsonschema.core.keyword.syntax.checkers.AbstractSyntaxChecker; | ||
import com.github.fge.jsonschema.core.keyword.syntax.checkers.SyntaxChecker; | ||
import com.github.fge.jsonschema.core.report.ProcessingReport; | ||
import com.github.fge.jsonschema.core.tree.SchemaTree; | ||
import com.github.fge.msgsimple.bundle.MessageBundle; | ||
import java.util.Collection; | ||
import org.devgateway.jocds.OcdsValidatorConstants; | ||
|
||
public final class DeprecatedSyntaxChecker extends AbstractSyntaxChecker { | ||
|
||
private static final SyntaxChecker INSTANCE = new DeprecatedSyntaxChecker(); | ||
|
||
public static SyntaxChecker getInstance() { | ||
return INSTANCE; | ||
} | ||
|
||
private DeprecatedSyntaxChecker() { | ||
super(OcdsValidatorConstants.CustomSchemaKeywords.DEPRECATED, NodeType.OBJECT); | ||
} | ||
|
||
@Override | ||
protected void checkValue(final Collection<JsonPointer> pointers, | ||
final MessageBundle bundle, final ProcessingReport report, | ||
final SchemaTree tree) | ||
throws ProcessingException { | ||
System.out.println(tree); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
jocds-core/src/main/java/org/devgateway/jocds/jsonschema/validator/DeprecatedValidator.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,51 @@ | ||
/* | ||
* Copyright (c) 2017. Development Gateway and contributors. All rights reserved. | ||
* Licensed under the MIT license. See LICENSE file in the project root for details. | ||
*/ | ||
|
||
package org.devgateway.jocds.jsonschema.validator; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.github.fge.jsonschema.core.exceptions.ProcessingException; | ||
import com.github.fge.jsonschema.core.processing.Processor; | ||
import com.github.fge.jsonschema.core.report.ProcessingReport; | ||
import com.github.fge.jsonschema.keyword.validator.AbstractKeywordValidator; | ||
import com.github.fge.jsonschema.processors.data.FullData; | ||
import com.github.fge.msgsimple.bundle.MessageBundle; | ||
|
||
/** | ||
* Keyword validator for {@code additionalProperties} | ||
*/ | ||
public final class DeprecatedValidator | ||
extends AbstractKeywordValidator { | ||
|
||
private final JsonNode deprecated; | ||
|
||
public DeprecatedValidator(final JsonNode digest) { | ||
super("deprecated"); | ||
deprecated = digest.get(keyword); | ||
} | ||
|
||
@Override | ||
public void validate(final Processor<FullData, FullData> processor, | ||
final ProcessingReport report, final MessageBundle bundle, | ||
final FullData data) | ||
throws ProcessingException { | ||
|
||
if (deprecated == null) { | ||
return; | ||
} | ||
|
||
report.warn(newMsg(data, bundle, | ||
"warn.jocds.deprecatedValidator") | ||
.putArgument("unwanted", deprecated)); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
final StringBuilder sb = new StringBuilder(keyword + ": "); | ||
|
||
return sb.toString(); | ||
} | ||
|
||
} |