|
36 | 36 | import java.io.FileNotFoundException; |
37 | 37 | import java.io.IOException; |
38 | 38 | import java.io.InputStream; |
39 | | -import java.net.URI; |
40 | 39 | import java.util.List; |
41 | 40 | import java.util.Map; |
42 | 41 | import java.util.concurrent.ConcurrentHashMap; |
@@ -651,6 +650,69 @@ public Schema getSchema(final SchemaLocation schemaUri) { |
651 | 650 | return schema; |
652 | 651 | } |
653 | 652 |
|
| 653 | + /** |
| 654 | + * Gets the schema. |
| 655 | + * |
| 656 | + * @param schemaUri the base absolute IRI |
| 657 | + * @param jsonNode the node |
| 658 | + * @return the schema |
| 659 | + */ |
| 660 | + public Schema getSchema(final SchemaLocation schemaUri, final JsonNode jsonNode) { |
| 661 | + return newSchema(schemaUri, jsonNode); |
| 662 | + } |
| 663 | + |
| 664 | + /** |
| 665 | + * Gets the schema. |
| 666 | + * |
| 667 | + * @param schemaUri the base absolute IRI |
| 668 | + * @param schema the input schema data |
| 669 | + * @param inputFormat input format |
| 670 | + * @return the schema |
| 671 | + */ |
| 672 | + public Schema getSchema(final SchemaLocation schemaUri, final String schema, InputFormat inputFormat) { |
| 673 | + try { |
| 674 | + final JsonNode schemaNode = readTree(schema, inputFormat); |
| 675 | + return newSchema(schemaUri, schemaNode); |
| 676 | + } catch (IOException ioe) { |
| 677 | + logger.error("Failed to load json schema!", ioe); |
| 678 | + throw new SchemaException(ioe); |
| 679 | + } |
| 680 | + } |
| 681 | + |
| 682 | + /** |
| 683 | + * Gets the schema. |
| 684 | + * |
| 685 | + * @param schemaUri the base absolute IRI |
| 686 | + * @param schemaStream the input schema data |
| 687 | + * @param inputFormat input format |
| 688 | + * @return the schema |
| 689 | + */ |
| 690 | + public Schema getSchema(final SchemaLocation schemaUri, final InputStream schemaStream, InputFormat inputFormat) { |
| 691 | + try { |
| 692 | + final JsonNode schemaNode = readTree(schemaStream, inputFormat); |
| 693 | + return newSchema(schemaUri, schemaNode); |
| 694 | + } catch (IOException ioe) { |
| 695 | + logger.error("Failed to load json schema!", ioe); |
| 696 | + throw new SchemaException(ioe); |
| 697 | + } |
| 698 | + } |
| 699 | + |
| 700 | + /** |
| 701 | + * Gets the schema. |
| 702 | + * <p> |
| 703 | + * Using this is not recommended as there is potentially no base IRI for |
| 704 | + * resolving references to the absolute IRI. |
| 705 | + * <p> |
| 706 | + * Prefer {@link #getSchema(SchemaLocation, JsonNode)} instead to ensure the |
| 707 | + * base IRI if no id is present. |
| 708 | + * |
| 709 | + * @param jsonNode the node |
| 710 | + * @return the schema |
| 711 | + */ |
| 712 | + public Schema getSchema(final JsonNode jsonNode) { |
| 713 | + return newSchema(null, jsonNode); |
| 714 | + } |
| 715 | + |
654 | 716 | /** |
655 | 717 | * Loads the schema. |
656 | 718 | * |
@@ -720,56 +782,6 @@ protected Schema getMappedSchema(final SchemaLocation schemaUri) { |
720 | 782 | } |
721 | 783 | } |
722 | 784 |
|
723 | | - /** |
724 | | - * Gets the schema. |
725 | | - * |
726 | | - * @param schemaUri the absolute IRI of the schema which can map to the |
727 | | - * retrieval IRI. |
728 | | - * @return the schema |
729 | | - */ |
730 | | - public Schema getSchema(final URI schemaUri) { |
731 | | - return getSchema(SchemaLocation.of(schemaUri.toString())); |
732 | | - } |
733 | | - |
734 | | - /** |
735 | | - * Gets the schema. |
736 | | - * |
737 | | - * @param schemaUri the absolute IRI of the schema which can map to the |
738 | | - * retrieval IRI. |
739 | | - * @param jsonNode the node |
740 | | - * @return the schema |
741 | | - */ |
742 | | - public Schema getSchema(final URI schemaUri, final JsonNode jsonNode) { |
743 | | - return newSchema(SchemaLocation.of(schemaUri.toString()), jsonNode); |
744 | | - } |
745 | | - |
746 | | - /** |
747 | | - * Gets the schema. |
748 | | - * |
749 | | - * @param schemaUri the base absolute IRI |
750 | | - * @param jsonNode the node |
751 | | - * @return the schema |
752 | | - */ |
753 | | - public Schema getSchema(final SchemaLocation schemaUri, final JsonNode jsonNode) { |
754 | | - return newSchema(schemaUri, jsonNode); |
755 | | - } |
756 | | - |
757 | | - /** |
758 | | - * Gets the schema. |
759 | | - * <p> |
760 | | - * Using this is not recommended as there is potentially no base IRI for |
761 | | - * resolving references to the absolute IRI. |
762 | | - * <p> |
763 | | - * Prefer {@link #getSchema(SchemaLocation, JsonNode)} instead to ensure the |
764 | | - * base IRI if no id is present. |
765 | | - * |
766 | | - * @param jsonNode the node |
767 | | - * @return the schema |
768 | | - */ |
769 | | - public Schema getSchema(final JsonNode jsonNode) { |
770 | | - return newSchema(null, jsonNode); |
771 | | - } |
772 | | - |
773 | 785 | /** |
774 | 786 | * Gets the schema registry config. |
775 | 787 | * |
|
0 commit comments