You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2021/11/15 16:32:17 UTC
[sling-whiteboard] branch master updated (fff3ea9 -> 8f9444a)
This is an automated email from the ASF dual-hosted git repository.
bdelacretaz pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git.
from fff3ea9 Remove extra examples
new 2362ffe Reorg APIs
new 8f9444a Elements storage
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../jsonstore/{ => internal}/api/DataTypeValidator.java | 2 +-
.../jsonstore/{ => internal}/api/JsonStoreConstants.java | 2 +-
.../sling/jsonstore/{ => internal}/api/SchemaProvider.java | 2 +-
.../jsonstore/{ => internal}/impl/ContentValidator.java | 12 ++++++------
.../jsonstore/{ => internal}/impl/JsonStorePathInfo.java | 4 ++--
.../{ => internal}/impl/JsonStoreResourceDecorator.java | 8 ++++----
.../jsonstore/{ => internal}/impl/JsonStoreServlet.java | 11 +++++------
.../jsonstore/{ => internal}/impl/SchemaProviderImpl.java | 11 +++++------
.../sling/jsonstore/{ => internal}/impl/SchemaValidator.java | 8 ++++----
.../sling/jsonstore/{ => internal}/impl/WrappedResource.java | 4 ++--
.../karate/{storeContent.feature => storeElements.feature} | 12 ++++++------
11 files changed, 37 insertions(+), 39 deletions(-)
rename json-store/src/main/java/org/apache/sling/jsonstore/{ => internal}/api/DataTypeValidator.java (97%)
rename json-store/src/main/java/org/apache/sling/jsonstore/{ => internal}/api/JsonStoreConstants.java (96%)
rename json-store/src/main/java/org/apache/sling/jsonstore/{ => internal}/api/SchemaProvider.java (96%)
rename json-store/src/main/java/org/apache/sling/jsonstore/{ => internal}/impl/ContentValidator.java (85%)
rename json-store/src/main/java/org/apache/sling/jsonstore/{ => internal}/impl/JsonStorePathInfo.java (91%)
rename json-store/src/main/java/org/apache/sling/jsonstore/{ => internal}/impl/JsonStoreResourceDecorator.java (90%)
rename json-store/src/main/java/org/apache/sling/jsonstore/{ => internal}/impl/JsonStoreServlet.java (93%)
rename json-store/src/main/java/org/apache/sling/jsonstore/{ => internal}/impl/SchemaProviderImpl.java (88%)
rename json-store/src/main/java/org/apache/sling/jsonstore/{ => internal}/impl/SchemaValidator.java (84%)
rename json-store/src/main/java/org/apache/sling/jsonstore/{ => internal}/impl/WrappedResource.java (89%)
copy json-store/src/test/java/org/apache/sling/jsonstore/karate/{storeContent.feature => storeElements.feature} (89%)
[sling-whiteboard] 01/02: Reorg APIs
Posted by bd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git
commit 2362ffe8992931942c0cfa9aa87e93991bf38700
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Mon Nov 15 17:27:34 2021 +0100
Reorg APIs
---
.../jsonstore/{ => internal}/api/DataTypeValidator.java | 2 +-
.../jsonstore/{ => internal}/api/JsonStoreConstants.java | 2 +-
.../sling/jsonstore/{ => internal}/api/SchemaProvider.java | 2 +-
.../jsonstore/{ => internal}/impl/ContentValidator.java | 12 ++++++------
.../jsonstore/{ => internal}/impl/JsonStorePathInfo.java | 4 ++--
.../{ => internal}/impl/JsonStoreResourceDecorator.java | 8 ++++----
.../jsonstore/{ => internal}/impl/JsonStoreServlet.java | 11 +++++------
.../jsonstore/{ => internal}/impl/SchemaProviderImpl.java | 11 +++++------
.../sling/jsonstore/{ => internal}/impl/SchemaValidator.java | 8 ++++----
.../sling/jsonstore/{ => internal}/impl/WrappedResource.java | 4 ++--
10 files changed, 31 insertions(+), 33 deletions(-)
diff --git a/json-store/src/main/java/org/apache/sling/jsonstore/api/DataTypeValidator.java b/json-store/src/main/java/org/apache/sling/jsonstore/internal/api/DataTypeValidator.java
similarity index 97%
rename from json-store/src/main/java/org/apache/sling/jsonstore/api/DataTypeValidator.java
rename to json-store/src/main/java/org/apache/sling/jsonstore/internal/api/DataTypeValidator.java
index 75d202a..76d4b86 100644
--- a/json-store/src/main/java/org/apache/sling/jsonstore/api/DataTypeValidator.java
+++ b/json-store/src/main/java/org/apache/sling/jsonstore/internal/api/DataTypeValidator.java
@@ -17,7 +17,7 @@
* under the License.
*/
- package org.apache.sling.jsonstore.api;
+ package org.apache.sling.jsonstore.internal.api;
import java.io.IOException;
diff --git a/json-store/src/main/java/org/apache/sling/jsonstore/api/JsonStoreConstants.java b/json-store/src/main/java/org/apache/sling/jsonstore/internal/api/JsonStoreConstants.java
similarity index 96%
rename from json-store/src/main/java/org/apache/sling/jsonstore/api/JsonStoreConstants.java
rename to json-store/src/main/java/org/apache/sling/jsonstore/internal/api/JsonStoreConstants.java
index 601b5e9..87ed887 100644
--- a/json-store/src/main/java/org/apache/sling/jsonstore/api/JsonStoreConstants.java
+++ b/json-store/src/main/java/org/apache/sling/jsonstore/internal/api/JsonStoreConstants.java
@@ -17,7 +17,7 @@
* under the License.
*/
- package org.apache.sling.jsonstore.api;
+ package org.apache.sling.jsonstore.internal.api;
public class JsonStoreConstants {
public static final String STORE_ROOT_PATH = "/content/sites";
diff --git a/json-store/src/main/java/org/apache/sling/jsonstore/api/SchemaProvider.java b/json-store/src/main/java/org/apache/sling/jsonstore/internal/api/SchemaProvider.java
similarity index 96%
rename from json-store/src/main/java/org/apache/sling/jsonstore/api/SchemaProvider.java
rename to json-store/src/main/java/org/apache/sling/jsonstore/internal/api/SchemaProvider.java
index c6cb59e..25437eb 100644
--- a/json-store/src/main/java/org/apache/sling/jsonstore/api/SchemaProvider.java
+++ b/json-store/src/main/java/org/apache/sling/jsonstore/internal/api/SchemaProvider.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.sling.jsonstore.api;
+package org.apache.sling.jsonstore.internal.api;
import java.io.IOException;
diff --git a/json-store/src/main/java/org/apache/sling/jsonstore/impl/ContentValidator.java b/json-store/src/main/java/org/apache/sling/jsonstore/internal/impl/ContentValidator.java
similarity index 85%
rename from json-store/src/main/java/org/apache/sling/jsonstore/impl/ContentValidator.java
rename to json-store/src/main/java/org/apache/sling/jsonstore/internal/impl/ContentValidator.java
index a80a1d9..dc271b4 100644
--- a/json-store/src/main/java/org/apache/sling/jsonstore/impl/ContentValidator.java
+++ b/json-store/src/main/java/org/apache/sling/jsonstore/internal/impl/ContentValidator.java
@@ -17,11 +17,11 @@
* under the License.
*/
-package org.apache.sling.jsonstore.impl;
+package org.apache.sling.jsonstore.internal.impl;
-import static org.apache.sling.jsonstore.api.JsonStoreConstants.CONTENT_DATA_TYPE;
-import static org.apache.sling.jsonstore.api.JsonStoreConstants.ELEMENTS_DATA_TYPE;
-import static org.apache.sling.jsonstore.api.JsonStoreConstants.JSON_SCHEMA_FIELD;
+import static org.apache.sling.jsonstore.internal.api.JsonStoreConstants.CONTENT_DATA_TYPE;
+import static org.apache.sling.jsonstore.internal.api.JsonStoreConstants.ELEMENTS_DATA_TYPE;
+import static org.apache.sling.jsonstore.internal.api.JsonStoreConstants.JSON_SCHEMA_FIELD;
import java.io.IOException;
import java.util.Set;
@@ -31,8 +31,8 @@ import com.networknt.schema.JsonSchema;
import com.networknt.schema.ValidationMessage;
import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.jsonstore.api.DataTypeValidator;
-import org.apache.sling.jsonstore.api.SchemaProvider;
+import org.apache.sling.jsonstore.internal.api.DataTypeValidator;
+import org.apache.sling.jsonstore.internal.api.SchemaProvider;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
diff --git a/json-store/src/main/java/org/apache/sling/jsonstore/impl/JsonStorePathInfo.java b/json-store/src/main/java/org/apache/sling/jsonstore/internal/impl/JsonStorePathInfo.java
similarity index 91%
rename from json-store/src/main/java/org/apache/sling/jsonstore/impl/JsonStorePathInfo.java
rename to json-store/src/main/java/org/apache/sling/jsonstore/internal/impl/JsonStorePathInfo.java
index 6716bd8..65b4b96 100644
--- a/json-store/src/main/java/org/apache/sling/jsonstore/impl/JsonStorePathInfo.java
+++ b/json-store/src/main/java/org/apache/sling/jsonstore/internal/impl/JsonStorePathInfo.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.sling.jsonstore.impl;
+package org.apache.sling.jsonstore.internal.impl;
-import static org.apache.sling.jsonstore.api.JsonStoreConstants.STORE_ROOT_PATH;
+import static org.apache.sling.jsonstore.internal.api.JsonStoreConstants.STORE_ROOT_PATH;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
diff --git a/json-store/src/main/java/org/apache/sling/jsonstore/impl/JsonStoreResourceDecorator.java b/json-store/src/main/java/org/apache/sling/jsonstore/internal/impl/JsonStoreResourceDecorator.java
similarity index 90%
rename from json-store/src/main/java/org/apache/sling/jsonstore/impl/JsonStoreResourceDecorator.java
rename to json-store/src/main/java/org/apache/sling/jsonstore/internal/impl/JsonStoreResourceDecorator.java
index 2151c47..81f9db0 100644
--- a/json-store/src/main/java/org/apache/sling/jsonstore/impl/JsonStoreResourceDecorator.java
+++ b/json-store/src/main/java/org/apache/sling/jsonstore/internal/impl/JsonStoreResourceDecorator.java
@@ -17,12 +17,12 @@
* under the License.
*/
-package org.apache.sling.jsonstore.impl;
+package org.apache.sling.jsonstore.internal.impl;
-import javax.servlet.http.HttpServletRequest;
+import static org.apache.sling.jsonstore.internal.api.JsonStoreConstants.JSON_BLOB_RESOURCE_TYPE;
+import static org.apache.sling.jsonstore.internal.api.JsonStoreConstants.STORE_ROOT_PATH;
-import static org.apache.sling.jsonstore.api.JsonStoreConstants.STORE_ROOT_PATH;
-import static org.apache.sling.jsonstore.api.JsonStoreConstants.JSON_BLOB_RESOURCE_TYPE;
+import javax.servlet.http.HttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceDecorator;
diff --git a/json-store/src/main/java/org/apache/sling/jsonstore/impl/JsonStoreServlet.java b/json-store/src/main/java/org/apache/sling/jsonstore/internal/impl/JsonStoreServlet.java
similarity index 93%
rename from json-store/src/main/java/org/apache/sling/jsonstore/impl/JsonStoreServlet.java
rename to json-store/src/main/java/org/apache/sling/jsonstore/internal/impl/JsonStoreServlet.java
index 17f1c36..b7e5941 100644
--- a/json-store/src/main/java/org/apache/sling/jsonstore/impl/JsonStoreServlet.java
+++ b/json-store/src/main/java/org/apache/sling/jsonstore/internal/impl/JsonStoreServlet.java
@@ -17,11 +17,11 @@
* under the License.
*/
-package org.apache.sling.jsonstore.impl;
+package org.apache.sling.jsonstore.internal.impl;
-import static org.apache.sling.jsonstore.api.JsonStoreConstants.JSON_BLOB_RESOURCE_TYPE;
-import static org.apache.sling.jsonstore.api.JsonStoreConstants.JSON_FOLDER_RESOURCE_TYPE;
-import static org.apache.sling.jsonstore.api.JsonStoreConstants.JSON_PROP_NAME;
+import static org.apache.sling.jsonstore.internal.api.JsonStoreConstants.JSON_BLOB_RESOURCE_TYPE;
+import static org.apache.sling.jsonstore.internal.api.JsonStoreConstants.JSON_FOLDER_RESOURCE_TYPE;
+import static org.apache.sling.jsonstore.internal.api.JsonStoreConstants.JSON_PROP_NAME;
import java.io.IOException;
import java.util.List;
@@ -40,13 +40,13 @@ import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceUtil;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
+import org.apache.sling.jsonstore.internal.api.DataTypeValidator;
import org.apache.sling.servlets.annotations.SlingServletResourceTypes;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;
import org.osgi.service.component.annotations.ReferencePolicyOption;
-import org.apache.sling.jsonstore.api.DataTypeValidator;
@Component(service = Servlet.class)
@SlingServletResourceTypes(
@@ -82,7 +82,6 @@ public class JsonStoreServlet extends SlingAllMethodsServlet {
public void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {
// Parse incoming JSON
- // TODO validate, depending on subpath
JsonNode json = null;
try {
json = mapper.readTree(request.getInputStream());
diff --git a/json-store/src/main/java/org/apache/sling/jsonstore/impl/SchemaProviderImpl.java b/json-store/src/main/java/org/apache/sling/jsonstore/internal/impl/SchemaProviderImpl.java
similarity index 88%
rename from json-store/src/main/java/org/apache/sling/jsonstore/impl/SchemaProviderImpl.java
rename to json-store/src/main/java/org/apache/sling/jsonstore/internal/impl/SchemaProviderImpl.java
index 60c8bd2..a2a9065 100644
--- a/json-store/src/main/java/org/apache/sling/jsonstore/impl/SchemaProviderImpl.java
+++ b/json-store/src/main/java/org/apache/sling/jsonstore/internal/impl/SchemaProviderImpl.java
@@ -17,15 +17,14 @@
* under the License.
*/
-package org.apache.sling.jsonstore.impl;
+package org.apache.sling.jsonstore.internal.impl;
-import static org.apache.sling.jsonstore.api.JsonStoreConstants.SCHEMA_DATA_TYPE;
-import static org.apache.sling.jsonstore.api.JsonStoreConstants.STORE_ROOT_PATH;
+import static org.apache.sling.jsonstore.internal.api.JsonStoreConstants.JSON_PROP_NAME;
+import static org.apache.sling.jsonstore.internal.api.JsonStoreConstants.SCHEMA_DATA_TYPE;
+import static org.apache.sling.jsonstore.internal.api.JsonStoreConstants.STORE_ROOT_PATH;
import java.io.IOException;
-import static org.apache.sling.jsonstore.api.JsonStoreConstants.JSON_PROP_NAME;
-
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
@@ -38,7 +37,7 @@ import com.networknt.schema.SpecVersionDetector;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;
-import org.apache.sling.jsonstore.api.SchemaProvider;
+import org.apache.sling.jsonstore.internal.api.SchemaProvider;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.osgi.service.component.annotations.Component;
diff --git a/json-store/src/main/java/org/apache/sling/jsonstore/impl/SchemaValidator.java b/json-store/src/main/java/org/apache/sling/jsonstore/internal/impl/SchemaValidator.java
similarity index 84%
rename from json-store/src/main/java/org/apache/sling/jsonstore/impl/SchemaValidator.java
rename to json-store/src/main/java/org/apache/sling/jsonstore/internal/impl/SchemaValidator.java
index 28f7b5a..1d7d6e0 100644
--- a/json-store/src/main/java/org/apache/sling/jsonstore/impl/SchemaValidator.java
+++ b/json-store/src/main/java/org/apache/sling/jsonstore/internal/impl/SchemaValidator.java
@@ -17,15 +17,15 @@
* under the License.
*/
-package org.apache.sling.jsonstore.impl;
+package org.apache.sling.jsonstore.internal.impl;
-import static org.apache.sling.jsonstore.api.JsonStoreConstants.SCHEMA_DATA_TYPE;
+import static org.apache.sling.jsonstore.internal.api.JsonStoreConstants.SCHEMA_DATA_TYPE;
import com.fasterxml.jackson.databind.JsonNode;
import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.jsonstore.api.DataTypeValidator;
-import org.apache.sling.jsonstore.api.SchemaProvider;
+import org.apache.sling.jsonstore.internal.api.DataTypeValidator;
+import org.apache.sling.jsonstore.internal.api.SchemaProvider;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
diff --git a/json-store/src/main/java/org/apache/sling/jsonstore/impl/WrappedResource.java b/json-store/src/main/java/org/apache/sling/jsonstore/internal/impl/WrappedResource.java
similarity index 89%
rename from json-store/src/main/java/org/apache/sling/jsonstore/impl/WrappedResource.java
rename to json-store/src/main/java/org/apache/sling/jsonstore/internal/impl/WrappedResource.java
index 7d1bb45..52ec997 100644
--- a/json-store/src/main/java/org/apache/sling/jsonstore/impl/WrappedResource.java
+++ b/json-store/src/main/java/org/apache/sling/jsonstore/internal/impl/WrappedResource.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.sling.jsonstore.impl;
+package org.apache.sling.jsonstore.internal.impl;
-import static org.apache.sling.jsonstore.api.JsonStoreConstants.JSON_BLOB_RESOURCE_TYPE;
+import static org.apache.sling.jsonstore.internal.api.JsonStoreConstants.JSON_BLOB_RESOURCE_TYPE;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceWrapper;
[sling-whiteboard] 02/02: Elements storage
Posted by bd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git
commit 8f9444a05f72b946836a2906cee6645b535058a1
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Mon Nov 15 17:29:13 2021 +0100
Elements storage
---
.../sling/jsonstore/karate/storeElements.feature | 81 ++++++++++++++++++++++
1 file changed, 81 insertions(+)
diff --git a/json-store/src/test/java/org/apache/sling/jsonstore/karate/storeElements.feature b/json-store/src/test/java/org/apache/sling/jsonstore/karate/storeElements.feature
new file mode 100644
index 0000000..d58133e
--- /dev/null
+++ b/json-store/src/test/java/org/apache/sling/jsonstore/karate/storeElements.feature
@@ -0,0 +1,81 @@
+# /*
+# * 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.
+# */
+
+# ------------------------------------------------------------------------
+@content
+Feature: Test elements storage
+# ------------------------------------------------------------------------
+
+# ------------------------------------------------------------------------
+Background:
+# ------------------------------------------------------------------------
+
+* url baseURL
+
+# Use admin credentials for all requests
+* configure headers = call read('classpath:util/basic-auth-header.js')
+
+# ------------------------------------------------------------------------
+Scenario: Cleanup previous test content
+# ------------------------------------------------------------------------
+Given path 'content/sites'
+When method DELETE
+* match [204,404,405] contains responseStatus
+
+# ------------------------------------------------------------------------
+Scenario: Attempt to store an element before having a schema
+# ------------------------------------------------------------------------
+Given request read('/content/minimal-content.json')
+And path 'content/sites/example.com/elements/somepath/minimal-before-schema'
+When method POST
+Then status 400
+* match response contains "Error retrieving schema"
+
+# ------------------------------------------------------------------------
+Scenario: Store minimal schema
+# ------------------------------------------------------------------------
+Given request read('/schema/minimal.json')
+And path 'content/sites/example.com/schema/test/minimal'
+When method POST
+Then status 200
+
+# ------------------------------------------------------------------------
+Scenario: Store content that uses minimal schema
+# ------------------------------------------------------------------------
+Given request read('/content/minimal-content.json')
+And path 'content/sites/example.com/elements/somepath/minimal'
+When method POST
+Then status 200
+
+# ------------------------------------------------------------------------
+Scenario: Verify content
+# ------------------------------------------------------------------------
+Given path 'content/sites/example.com/elements/somepath/minimal'
+When method GET
+Then status 200
+And match response == read('/content/minimal-content.json')
+
+# ------------------------------------------------------------------------
+Scenario: Attempt to store content that the schema does not validate
+# ------------------------------------------------------------------------
+Given request read('/content/invalid-minimal-content.json')
+And path 'content/sites/example.com/elements/somepath/willfail'
+When method POST
+Then status 400
+* match response contains "DataTypeValidator$ValidatorException"
\ No newline at end of file