You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by dk...@apache.org on 2023/01/28 19:19:26 UTC

[sling-org-apache-sling-app-cms] branch master updated (725e6064 -> 1871f886)

This is an automated email from the ASF dual-hosted git repository.

dklco pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git


    from 725e6064 Minor: updating to latest sling bundle parent and commons-text
     new acd002cb Minor - Fixing sonar code smells
     new 1871f886 Minor - Fixing cypress CI failures

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:
 .../java/org/apache/sling/cms/AuthorizableWrapper.java |  2 +-
 .../main/java/org/apache/sling/cms/package-info.java   |  2 +-
 .../cms/core/internal/FileMetadataExtractorImpl.java   |  3 +++
 .../apache/sling/cms/core/internal/IndexCreator.java   | 15 +++++++++------
 .../core/internal/models/AuthorizableWrapperImpl.java  |  2 +-
 .../cms/core/internal/models/ComponentManagerImpl.java |  4 +---
 .../cms/core/internal/servlets/PreviewFileServlet.java |  2 +-
 it/cypress/e2e/ugc.cy.js                               |  7 +------
 it/cypress/ready.js                                    |  2 +-
 it/package-lock.json                                   | 18 ++++++------------
 it/package.json                                        |  3 ++-
 it/pom.xml                                             | 10 ++++++++++
 12 files changed, 37 insertions(+), 33 deletions(-)


[sling-org-apache-sling-app-cms] 02/02: Minor - Fixing cypress CI failures

Posted by dk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dklco pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git

commit 1871f8862c97c5940171e6b1cadae5672182dd4e
Author: Dan Klco <kl...@adobe.com>
AuthorDate: Sat Jan 28 14:19:17 2023 -0500

    Minor - Fixing cypress CI failures
---
 it/cypress/e2e/ugc.cy.js |  7 +------
 it/cypress/ready.js      |  2 +-
 it/package-lock.json     | 18 ++++++------------
 it/package.json          |  3 ++-
 it/pom.xml               | 10 ++++++++++
 5 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/it/cypress/e2e/ugc.cy.js b/it/cypress/e2e/ugc.cy.js
index 4fe13889..16fb8c7e 100644
--- a/it/cypress/e2e/ugc.cy.js
+++ b/it/cypress/e2e/ugc.cy.js
@@ -18,12 +18,7 @@
  */
 
 const { doneLoading } = require("../utils");
-const {
-  createComponentPage,
-  configureComponentFromDialog,
-  COMPONENT_SUBPATH,
-  XSS_PAYLOAD,
-} = require("../util/component-test-helper");
+const { createComponentPage } = require("../util/component-test-helper");
 const { login, sendPost } = require("../util/test-helper");
 
 describe("UGC Tests", () => {
diff --git a/it/cypress/ready.js b/it/cypress/ready.js
index b637643e..8ffae2b8 100644
--- a/it/cypress/ready.js
+++ b/it/cypress/ready.js
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-const fetch = require("node-fetch");
+const fetch = require("node-fetch-commonjs");
 
 const url = process.env.CYPRESS_BASE_URL;
 
diff --git a/it/package-lock.json b/it/package-lock.json
index ced1aff1..bf2c8f57 100644
--- a/it/package-lock.json
+++ b/it/package-lock.json
@@ -1364,11 +1364,6 @@
         "assert-plus": "^1.0.0"
       }
     },
-    "data-uri-to-buffer": {
-      "version": "4.0.0",
-      "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.0.tgz",
-      "integrity": "sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA=="
-    },
     "dayjs": {
       "version": "1.11.7",
       "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.7.tgz",
@@ -2606,14 +2601,13 @@
       "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
       "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ=="
     },
-    "node-fetch": {
-      "version": "3.3.0",
-      "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.0.tgz",
-      "integrity": "sha512-BKwRP/O0UvoMKp7GNdwPlObhYGB5DQqwhEDQlNKuoqwVYSxkSZCSbHjnFFmUEtwSKRPU4kNK8PbDYYitwaE3QA==",
+    "node-fetch-commonjs": {
+      "version": "3.2.4",
+      "resolved": "https://registry.npmjs.org/node-fetch-commonjs/-/node-fetch-commonjs-3.2.4.tgz",
+      "integrity": "sha512-bZW7+ldcuuMPLTJk8DufhT6qHDRdljYD0jqBjmrYfcInaYcReX5kK42SQsu/jvtit/tER28yYjnk63PEEmNPtg==",
       "requires": {
-        "data-uri-to-buffer": "^4.0.0",
-        "fetch-blob": "^3.1.4",
-        "formdata-polyfill": "^4.0.10"
+        "formdata-polyfill": "^4.0.10",
+        "web-streams-polyfill": "^3.1.1"
       }
     },
     "node.extend": {
diff --git a/it/package.json b/it/package.json
index 7691e3d7..895605ee 100644
--- a/it/package.json
+++ b/it/package.json
@@ -4,6 +4,7 @@
   "description": "",
   "main": "tests/index.js",
   "scripts": {
+    "cypress:install": "./node_modules/.bin/cypress install",
     "cypress": "./node_modules/.bin/cypress open",
     "test": "./node_modules/.bin/cypress run",
     "wait-for-ready": "node cypress/ready.js"
@@ -18,7 +19,7 @@
   "dependencies": {
     "@cypress-audit/pa11y": "^1.3.1",
     "cypress": "^12.2.0",
-    "node-fetch": "^3.3.0",
+    "node-fetch-commonjs": "^3.2.4",
     "uuid": "^9.0.0"
   }
 }
diff --git a/it/pom.xml b/it/pom.xml
index 869a000e..2f473e48 100644
--- a/it/pom.xml
+++ b/it/pom.xml
@@ -173,6 +173,16 @@
                                     </environmentVariables>
                                 </configuration>
                             </execution>
+                            <execution>
+                                <id>install cypress</id>
+                                <goals>
+                                    <goal>npm</goal>
+                                </goals>
+                                <phase>integration-test</phase>
+                                <configuration>
+                                    <arguments>run cypress:install</arguments>
+                                </configuration>
+                            </execution>
                             <execution>
                                 <id>run cypress</id>
                                 <goals>


[sling-org-apache-sling-app-cms] 01/02: Minor - Fixing sonar code smells

Posted by dk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dklco pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git

commit acd002cb0009f8daa97e427667f7b3d05c41743c
Author: Dan Klco <kl...@adobe.com>
AuthorDate: Sat Jan 28 14:18:48 2023 -0500

    Minor - Fixing sonar code smells
---
 .../java/org/apache/sling/cms/AuthorizableWrapper.java    |  2 +-
 api/src/main/java/org/apache/sling/cms/package-info.java  |  2 +-
 .../cms/core/internal/FileMetadataExtractorImpl.java      |  3 +++
 .../org/apache/sling/cms/core/internal/IndexCreator.java  | 15 +++++++++------
 .../cms/core/internal/models/AuthorizableWrapperImpl.java |  2 +-
 .../cms/core/internal/models/ComponentManagerImpl.java    |  4 +---
 .../cms/core/internal/servlets/PreviewFileServlet.java    |  2 +-
 7 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/api/src/main/java/org/apache/sling/cms/AuthorizableWrapper.java b/api/src/main/java/org/apache/sling/cms/AuthorizableWrapper.java
index 8492fee8..c0c93521 100644
--- a/api/src/main/java/org/apache/sling/cms/AuthorizableWrapper.java
+++ b/api/src/main/java/org/apache/sling/cms/AuthorizableWrapper.java
@@ -71,7 +71,7 @@ public interface AuthorizableWrapper {
      * 
      * @return the current user's ID
      */
-    @NotNull
+    @Nullable
     public String getId();
 
     /**
diff --git a/api/src/main/java/org/apache/sling/cms/package-info.java b/api/src/main/java/org/apache/sling/cms/package-info.java
index f5e9516c..e211d4e9 100644
--- a/api/src/main/java/org/apache/sling/cms/package-info.java
+++ b/api/src/main/java/org/apache/sling/cms/package-info.java
@@ -23,5 +23,5 @@
  *
  * @since 0.10.0
  */
-@org.osgi.annotation.versioning.Version("2.1.0")
+@org.osgi.annotation.versioning.Version("2.1.1")
 package org.apache.sling.cms;
diff --git a/core/src/main/java/org/apache/sling/cms/core/internal/FileMetadataExtractorImpl.java b/core/src/main/java/org/apache/sling/cms/core/internal/FileMetadataExtractorImpl.java
index 48b14744..abdf6f0d 100644
--- a/core/src/main/java/org/apache/sling/cms/core/internal/FileMetadataExtractorImpl.java
+++ b/core/src/main/java/org/apache/sling/cms/core/internal/FileMetadataExtractorImpl.java
@@ -123,6 +123,7 @@ public class FileMetadataExtractorImpl implements FileMetadataExtractor {
         }
     }
 
+    @SuppressWarnings(value={"java:S1872", "java:S1874"})
     public Map<String, Object> extractMetadata(Resource resource)
             throws IOException, SAXException, TikaException, RepositoryException, LoginException {
         log.info("Extracting metadata from {}", resource.getPath());
@@ -135,6 +136,7 @@ public class FileMetadataExtractorImpl implements FileMetadataExtractor {
             try {
                 parser.parse(is, handler, md, context);
             } catch (SAXException se) {
+                // unfortunately, we can't use instanceof to check as the class is not exported
                 if ("WriteLimitReachedException".equals(se.getClass().getSimpleName())) {
                     log.info("Write limit reached for {}", resource.getPath());
                 } else {
@@ -142,6 +144,7 @@ public class FileMetadataExtractorImpl implements FileMetadataExtractor {
                 }
             }
 
+            
             try (ResourceResolver adminResolver = resolverFactory.getAdministrativeResourceResolver(null)) {
                 NamespaceRegistry registry = adminResolver.adaptTo(Session.class).getWorkspace().getNamespaceRegistry();
                 for (String name : md.names()) {
diff --git a/core/src/main/java/org/apache/sling/cms/core/internal/IndexCreator.java b/core/src/main/java/org/apache/sling/cms/core/internal/IndexCreator.java
index 84dc9789..68531194 100644
--- a/core/src/main/java/org/apache/sling/cms/core/internal/IndexCreator.java
+++ b/core/src/main/java/org/apache/sling/cms/core/internal/IndexCreator.java
@@ -31,6 +31,9 @@ import org.osgi.service.component.annotations.Component;
 @Component(service = RepositoryInitializer.class)
 public class IndexCreator implements RepositoryInitializer {
 
+    private static final String VAL_NODE_NAME = ":nodeName";
+    private static final String PN_NODE_NAME = "nodeName";
+    private static final String PN_JCR_TITLE = "jcrTitle";
     private static final String[] CONTENT_PATHS = new String[] { "/content", "/static" };
     private static final String JCR_CONTENT_PROPERTIES = "jcr:content/*";
     private static final String SLINGCMS = "slingcms";
@@ -84,8 +87,8 @@ public class IndexCreator implements RepositoryInitializer {
 
         IndexRule indexRule = builder.indexRule("sling:Component");
         indexRule.property("componentType", "componentType", false).propertyIndex().notNullCheckEnabled();
-        indexRule.property("jcrTitle", "jcr:title", false).analyzed().propertyIndex().ordered();
-        indexRule.property("nodeName", ":nodeName", false).analyzed().propertyIndex().ordered();
+        indexRule.property(PN_JCR_TITLE, "jcr:title", false).analyzed().propertyIndex().ordered();
+        indexRule.property(PN_NODE_NAME, VAL_NODE_NAME, false).analyzed().propertyIndex().ordered();
 
         indexRule.property("jcrLastModifiedBy", "jcr:content/jcr:lastModifiedBy", false).propertyIndex();
     }
@@ -151,13 +154,13 @@ public class IndexCreator implements RepositoryInitializer {
         builder.tags(SLINGCMS, "slingcms-slingTaxonomy");
 
         IndexRule indexRule = builder.indexRule("sling:Taxonomy");
-        indexRule.property("jcrTitle", "jcr:title", false).analyzed().propertyIndex().ordered();
-        indexRule.property("nodeName", ":nodeName", false).analyzed().propertyIndex().ordered();
+        indexRule.property(PN_JCR_TITLE, "jcr:title", false).analyzed().propertyIndex().ordered();
+        indexRule.property(PN_NODE_NAME, VAL_NODE_NAME, false).analyzed().propertyIndex().ordered();
     }
 
     private void ensureCommonSlingProperties(IndexRule indexRule) {
-        indexRule.property("jcrTitle", "jcr:content/jcr:title", false).analyzed().propertyIndex().boost(2).ordered();
-        indexRule.property("nodeName", ":nodeName", false).analyzed().propertyIndex().ordered();
+        indexRule.property(PN_JCR_TITLE, "jcr:content/jcr:title", false).analyzed().propertyIndex().boost(2).ordered();
+        indexRule.property(PN_NODE_NAME, VAL_NODE_NAME, false).analyzed().propertyIndex().ordered();
         indexRule.property("jcrDescription", "jcr:content/jcr:description", false).analyzed().propertyIndex();
         indexRule.property("jcrLastModified", "jcr:content/jcr:lastModified", false).propertyIndex().ordered()
                 .type("Date");
diff --git a/core/src/main/java/org/apache/sling/cms/core/internal/models/AuthorizableWrapperImpl.java b/core/src/main/java/org/apache/sling/cms/core/internal/models/AuthorizableWrapperImpl.java
index 24e4cd21..8ac0b38c 100644
--- a/core/src/main/java/org/apache/sling/cms/core/internal/models/AuthorizableWrapperImpl.java
+++ b/core/src/main/java/org/apache/sling/cms/core/internal/models/AuthorizableWrapperImpl.java
@@ -170,7 +170,7 @@ public class AuthorizableWrapperImpl implements AuthorizableWrapper {
 
     @Override
     public boolean isMember(String groupName) {
-        Iterable<Group> iterable = () -> getMembership();
+        Iterable<Group> iterable = this::getMembership;
         return StreamSupport.stream(iterable.spliterator(), false).anyMatch(g -> {
             try {
                 return groupName.equals(g.getID());
diff --git a/core/src/main/java/org/apache/sling/cms/core/internal/models/ComponentManagerImpl.java b/core/src/main/java/org/apache/sling/cms/core/internal/models/ComponentManagerImpl.java
index a7e2bd49..8358bb4e 100644
--- a/core/src/main/java/org/apache/sling/cms/core/internal/models/ComponentManagerImpl.java
+++ b/core/src/main/java/org/apache/sling/cms/core/internal/models/ComponentManagerImpl.java
@@ -107,9 +107,7 @@ public class ComponentManagerImpl implements ComponentManager {
             Component component = cmpRsrc.adaptTo(Component.class);
             if (component != null) {
                 for (String type : component.getComponentType()) {
-                    if (!componentCache.containsKey(type)) {
-                        componentCache.put(type, new ArrayList<>());
-                    }
+                    componentCache.putIfAbsent(type, new ArrayList<>());
                     componentCache.get(type).add(component);
                 }
             }
diff --git a/core/src/main/java/org/apache/sling/cms/core/internal/servlets/PreviewFileServlet.java b/core/src/main/java/org/apache/sling/cms/core/internal/servlets/PreviewFileServlet.java
index d2793d36..49ec7694 100644
--- a/core/src/main/java/org/apache/sling/cms/core/internal/servlets/PreviewFileServlet.java
+++ b/core/src/main/java/org/apache/sling/cms/core/internal/servlets/PreviewFileServlet.java
@@ -36,7 +36,7 @@ public class PreviewFileServlet extends SlingSafeMethodsServlet {
 
     private static final long serialVersionUID = 6234007100684499058L;
 
-    private SlingRequestProcessor requestProcessor;
+    private transient SlingRequestProcessor requestProcessor;
 
     @Activate
     public PreviewFileServlet(@Reference SlingRequestProcessor requestProcessor) {