You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2024/01/27 12:39:06 UTC
(camel) branch main updated: camel-json-validator - Removed deprecated API from 2021
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new f1ee41af3e3 camel-json-validator - Removed deprecated API from 2021
f1ee41af3e3 is described below
commit f1ee41af3e3cea1b53ef9f261b39f360f1e7853a
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Jan 27 13:38:57 2024 +0100
camel-json-validator - Removed deprecated API from 2021
---
.../jsonvalidator/DefaultJsonSchemaLoader.java | 39 -----------
.../component/jsonvalidator/JsonSchemaLoader.java | 43 ------------
.../jsonvalidator/JsonValidatorEndpoint.java | 24 +------
.../LegacyDefaultSchemaLoaderTest.java | 77 ---------------------
.../jsonvalidator/LegacyJsonSchemaLoaderTest.java | 78 ----------------------
.../ROOT/pages/camel-4x-upgrade-guide-4_4.adoc | 6 ++
6 files changed, 7 insertions(+), 260 deletions(-)
diff --git a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/DefaultJsonSchemaLoader.java b/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/DefaultJsonSchemaLoader.java
deleted file mode 100644
index 957a31bb7b1..00000000000
--- a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/DefaultJsonSchemaLoader.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jsonvalidator;
-
-import java.io.InputStream;
-
-import com.networknt.schema.JsonSchema;
-import com.networknt.schema.JsonSchemaFactory;
-import com.networknt.schema.SpecVersion;
-import org.apache.camel.CamelContext;
-
-/**
- * @deprecated use DefaultJsonUriSchemaLoader instead
- */
-@Deprecated
-public class DefaultJsonSchemaLoader implements JsonSchemaLoader {
-
- @Override
- @Deprecated
- public JsonSchema createSchema(CamelContext camelContext, InputStream inputStream) throws Exception {
- JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4);
- return factory.getSchema(inputStream);
- }
-
-}
diff --git a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonSchemaLoader.java b/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonSchemaLoader.java
deleted file mode 100644
index e36247d0244..00000000000
--- a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonSchemaLoader.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jsonvalidator;
-
-import java.io.InputStream;
-
-import com.networknt.schema.JsonSchema;
-import org.apache.camel.CamelContext;
-
-/**
- * Can be used to create custom schema for the JSON validator endpoint.
- *
- * @deprecated Use JsonUriSchemaLoader instead
- */
-@Deprecated
-public interface JsonSchemaLoader {
-
- /**
- * Create a new Schema based on the schema input stream.
- *
- * @param camelContext camel context
- * @param inputStream the resource input stream
- * @return a Schema to be used when validating incoming requests
- * @deprecated use {@link JsonUriSchemaLoader} instead
- */
- @Deprecated
- JsonSchema createSchema(CamelContext camelContext, InputStream inputStream) throws Exception;
-
-}
diff --git a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidatorEndpoint.java b/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidatorEndpoint.java
index 10df1843271..5b2264656b0 100644
--- a/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidatorEndpoint.java
+++ b/components/camel-json-validator/src/main/java/org/apache/camel/component/jsonvalidator/JsonValidatorEndpoint.java
@@ -51,7 +51,6 @@ public class JsonValidatorEndpoint extends ResourceEndpoint {
private String headerName;
@UriParam(label = "advanced")
private JsonValidatorErrorHandler errorHandler = new DefaultJsonValidationErrorHandler();
- private JsonSchemaLoader schemaLoader;
@UriParam(label = "advanced")
private JsonUriSchemaLoader uriSchemaLoader = new DefaultJsonUriSchemaLoader();
@@ -181,12 +180,7 @@ public class JsonValidatorEndpoint extends ResourceEndpoint {
private JsonSchema getOrCreateSchema() throws Exception {
synchronized (this) {
if (this.schema == null) {
- if (this.schemaLoader == null) {
- this.schema = this.uriSchemaLoader.createSchema(getCamelContext(), getResourceUri());
- } else {
- // for backwards compatility, will continue to use the old schema loader if one was provided
- this.schema = this.schemaLoader.createSchema(getCamelContext(), this.getResourceAsInputStream());
- }
+ this.schema = this.uriSchemaLoader.createSchema(getCamelContext(), getResourceUri());
}
}
return this.schema;
@@ -210,22 +204,6 @@ public class JsonValidatorEndpoint extends ResourceEndpoint {
this.errorHandler = errorHandler;
}
- @Deprecated
- public JsonSchemaLoader getSchemaLoader() {
- return schemaLoader;
- }
-
- /**
- * To use a custom schema loader allowing for adding custom format validation. The default implementation will
- * create a schema loader with draft v4 support.
- *
- * @deprecated Use {@link #setUriSchemaLoader(JsonUriSchemaLoader)} instead
- */
- @Deprecated
- public void setSchemaLoader(JsonSchemaLoader schemaLoader) {
- this.schemaLoader = schemaLoader;
- }
-
public JsonUriSchemaLoader getUriSchemaLoader() {
return uriSchemaLoader;
}
diff --git a/components/camel-json-validator/src/test/java/org/apache/camel/component/jsonvalidator/LegacyDefaultSchemaLoaderTest.java b/components/camel-json-validator/src/test/java/org/apache/camel/component/jsonvalidator/LegacyDefaultSchemaLoaderTest.java
deleted file mode 100644
index 01c2359710e..00000000000
--- a/components/camel-json-validator/src/test/java/org/apache/camel/component/jsonvalidator/LegacyDefaultSchemaLoaderTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jsonvalidator;
-
-import java.io.*;
-
-import com.networknt.schema.JsonSchema;
-import org.apache.camel.CamelContext;
-import org.apache.camel.EndpointInject;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.support.ResourceHelper;
-import org.apache.camel.test.junit5.CamelTestSupport;
-import org.junit.jupiter.api.Test;
-
-/**
- * Applications that extended {@link DefaultJsonSchemaLoader} should continue to work.
- */
-public class LegacyDefaultSchemaLoaderTest extends CamelTestSupport {
-
- @EndpointInject("mock:end")
- protected MockEndpoint endpoint;
-
- @Test
- public void testValidMessage() throws Exception {
- endpoint.expectedMessageCount(1);
-
- template.sendBody("direct:start",
- "{ \"name\": \"Joe Doe\", \"id\": 1, \"price\": 12.5 }");
-
- MockEndpoint.assertIsSatisfied(endpoint);
- }
-
- @Override
- protected CamelContext createCamelContext() throws Exception {
- CamelContext context = super.createCamelContext();
- JsonValidatorEndpoint endpoint = context.getEndpoint(
- "json-validator:org/apache/camel/component/jsonvalidator/Order.json", JsonValidatorEndpoint.class);
- endpoint.setSchemaLoader(new DefaultJsonSchemaLoader() {
- @Override
- public JsonSchema createSchema(CamelContext camelContext, InputStream inputStream) throws Exception {
- // ignore the requested schema and always return schema.json schema ... the validation will only
- // succeed if it's done with this schema
- inputStream = ResourceHelper.resolveMandatoryResourceAsInputStream(camelContext,
- "org/apache/camel/component/jsonvalidator/schema.json");
- return super.createSchema(camelContext, inputStream);
- }
- });
- return context;
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:start")
- .to("json-validator:org/apache/camel/component/jsonvalidator/Order.json")
- .to("mock:end");
- }
- };
- }
-}
diff --git a/components/camel-json-validator/src/test/java/org/apache/camel/component/jsonvalidator/LegacyJsonSchemaLoaderTest.java b/components/camel-json-validator/src/test/java/org/apache/camel/component/jsonvalidator/LegacyJsonSchemaLoaderTest.java
deleted file mode 100644
index 42e339d97c2..00000000000
--- a/components/camel-json-validator/src/test/java/org/apache/camel/component/jsonvalidator/LegacyJsonSchemaLoaderTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jsonvalidator;
-
-import java.io.*;
-import java.net.*;
-
-import com.networknt.schema.JsonSchema;
-import com.networknt.schema.JsonSchemaFactory;
-import com.networknt.schema.SpecVersion;
-import org.apache.camel.CamelContext;
-import org.apache.camel.EndpointInject;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit5.CamelTestSupport;
-import org.junit.jupiter.api.Test;
-
-/**
- * Applications that rely on an instance of the legacy {@link JsonSchemaLoader} should continue to work.
- */
-public class LegacyJsonSchemaLoaderTest extends CamelTestSupport {
-
- @EndpointInject("mock:end")
- protected MockEndpoint endpoint;
-
- @Test
- public void testValidMessage() throws Exception {
- endpoint.expectedMessageCount(1);
-
- template.sendBody("direct:start",
- "{ \"customer\": \"Donald \\\"Duck\\\" Dunn\", \"orderItems\": [{ \"product\": \"bass guitar\", \"quantity\": 1 }] }");
-
- MockEndpoint.assertIsSatisfied(endpoint);
- }
-
- @Override
- protected CamelContext createCamelContext() throws Exception {
- CamelContext context = super.createCamelContext();
- JsonValidatorEndpoint endpoint = context.getEndpoint(
- "json-validator:org/apache/camel/component/jsonvalidator/schema.json", JsonValidatorEndpoint.class);
- endpoint.setSchemaLoader(new JsonSchemaLoader() {
- @Override
- public JsonSchema createSchema(CamelContext camelContext, InputStream inputStream) {
- // ignore the requested schema and always return Order.json schema ... the validation will only
- // succeed if it's done with this schema
- JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909);
- return factory.getSchema(URI.create("classpath:org/apache/camel/component/jsonvalidator/Order.json"));
- }
- });
- return context;
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:start")
- .to("json-validator:org/apache/camel/component/jsonvalidator/schema.json")
- .to("mock:end");
- }
- };
- }
-}
diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_4.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_4.adoc
index 3e96262eae4..f2e2e1b353c 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_4.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_4.adoc
@@ -142,6 +142,12 @@ The component was removed without deprecation. The library supporting this compo
The component now has support for batch processing.
+=== camel-json-validator
+
+Removed deprecated `org.apache.camel.component.jsonvalidator.DefaultJsonSchemaLoader`,
+use `org.apache.camel.component.jsonvalidator.DefaultJsonUriSchemaLoader` instead.
+
+
== Camel Spring Boot
=== Ordering of BOM imports