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

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


The following commit(s) were added to refs/heads/master by this push:
     new dd7ff4b  SLING-9874 - Allow adapting SlingHttpServletRequest and 
ResourceResolver to XSSAPI
dd7ff4b is described below

commit dd7ff4b41bd8431ae64858f86d3aad692a7e476e
Author: Radu Cotescu <[email protected]>
AuthorDate: Mon Feb 15 11:02:12 2021 +0100

    SLING-9874 - Allow adapting SlingHttpServletRequest and ResourceResolver to 
XSSAPI
    
    This reverts commit 1d7559ef58dc1093c25f0b8ef360ab677b9c0d92.
---
 .../sling/xss/impl/XSSAPIAdapterFactory.java       | 60 ------------------
 .../sling/xss/impl/XSSAPIAdapterFactoryTest.java   | 72 ----------------------
 2 files changed, 132 deletions(-)

diff --git a/src/main/java/org/apache/sling/xss/impl/XSSAPIAdapterFactory.java 
b/src/main/java/org/apache/sling/xss/impl/XSSAPIAdapterFactory.java
deleted file mode 100644
index f996c2d..0000000
--- a/src/main/java/org/apache/sling/xss/impl/XSSAPIAdapterFactory.java
+++ /dev/null
@@ -1,60 +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.sling.xss.impl;
-
-import org.apache.sling.api.SlingHttpServletRequest;
-import org.apache.sling.api.adapter.AdapterFactory;
-import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.xss.XSSAPI;
-import org.jetbrains.annotations.NotNull;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferencePolicyOption;
-
-@Component(
-        service = AdapterFactory.class,
-        property = {
-                AdapterFactory.ADAPTER_CLASSES + 
"=org.apache.sling.xss.XSSAPI",
-                AdapterFactory.ADAPTABLE_CLASSES + 
"=org.apache.sling.api.resource.ResourceResolver",
-                AdapterFactory.ADAPTABLE_CLASSES + 
"=org.apache.sling.api.SlingHttpServletRequest"
-        }
-)
-public class XSSAPIAdapterFactory implements AdapterFactory {
-
-    @Reference(policyOption = ReferencePolicyOption.GREEDY)
-    private XSSAPI xssapi;
-
-    public XSSAPIAdapterFactory() {
-        // default constructor for SCR
-    }
-
-    // constructor for testing, could use constructor injection with OSGi R7
-    XSSAPIAdapterFactory(XSSAPI xssapi) {
-        this.xssapi = xssapi;
-    }
-
-    @Override
-    public <AdapterType> AdapterType getAdapter(@NotNull Object adaptable, 
@NotNull Class<AdapterType> type) {
-        if (type == XSSAPI.class
-                && (adaptable instanceof ResourceResolver || adaptable 
instanceof SlingHttpServletRequest)) {
-            return type.cast(xssapi);
-        }
-        return null;
-    }
-}
diff --git 
a/src/test/java/org/apache/sling/xss/impl/XSSAPIAdapterFactoryTest.java 
b/src/test/java/org/apache/sling/xss/impl/XSSAPIAdapterFactoryTest.java
deleted file mode 100644
index df1e4af..0000000
--- a/src/test/java/org/apache/sling/xss/impl/XSSAPIAdapterFactoryTest.java
+++ /dev/null
@@ -1,72 +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.sling.xss.impl;
-
-import org.apache.sling.api.SlingHttpServletRequest;
-import org.apache.sling.api.resource.Resource;
-import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.xss.XSSAPI;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.isA;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.mockito.Mockito.mock;
-
-public class XSSAPIAdapterFactoryTest {
-
-    private XSSAPIAdapterFactory factory;
-
-    @Before
-    public void setup() {
-        final XSSAPI xssapi = mock(XSSAPI.class);
-        factory = new XSSAPIAdapterFactory(xssapi);
-    }
-
-    @Test
-    public void testAdaptFromResourceResolver() {
-        final ResourceResolver resolver = mock(ResourceResolver.class);
-
-        assertThat("should adapt ResourceResolver to XSSAPI",
-                factory.getAdapter(resolver, XSSAPI.class), isA(XSSAPI.class));
-    }
-
-    @Test
-    public void testAdaptFromRequest() {
-        final SlingHttpServletRequest request = 
mock(SlingHttpServletRequest.class);
-
-        assertThat("should adapt SlingHttpServletRequest to XSSAPI",
-                factory.getAdapter(request, XSSAPI.class), isA(XSSAPI.class));
-    }
-
-    @Test
-    public void testNoAdaptionFromArbitraryObject() {
-        assertThat("should not adapt Object to XSSAPI",
-                factory.getAdapter(new Object(), XSSAPI.class), nullValue());
-    }
-
-    @Test
-    public void testNoAdaptionFromRequestToResource() {
-        final SlingHttpServletRequest request = 
mock(SlingHttpServletRequest.class);
-
-        assertThat("should not adapt SlingHttpServletRequest to Resource",
-                factory.getAdapter(request, Resource.class), nullValue());
-    }
-}
\ No newline at end of file

Reply via email to