sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject [sling-org-apache-sling-api] 02/02: Update api prototype
Date Wed, 02 Sep 2020 12:10:38 GMT
This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch feature/pathmappingproposal
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-api.git

commit 885ce6c93d6e315e2d5e382267cde0debcca77ad
Author: Carsten Ziegeler <cziegeler@apache.org>
AuthorDate: Wed Sep 2 14:09:59 2020 +0200

    Update api prototype
---
 .../spi/resource/mapping/MappingChainContext.java  | 37 +++++++++++++++++
 .../sling/spi/resource/mapping/PathMapper.java     | 48 ++++++++++++++++++++++
 .../sling/spi/resource/mapping/package-info.java   | 23 +++++++++++
 3 files changed, 108 insertions(+)

diff --git a/src/main/java/org/apache/sling/spi/resource/mapping/MappingChainContext.java
b/src/main/java/org/apache/sling/spi/resource/mapping/MappingChainContext.java
new file mode 100644
index 0000000..4b5f57f
--- /dev/null
+++ b/src/main/java/org/apache/sling/spi/resource/mapping/MappingChainContext.java
@@ -0,0 +1,37 @@
+/*
+ * 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.spi.resource.mapping;
+
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.osgi.annotation.versioning.ProviderType;
+
+@ProviderType
+public interface MappingChainContext {
+
+    void skipRemainingChain();
+
+    @NotNull Map<String, Object> getAttributes();
+
+    @Nullable HttpServletRequest getRequest();
+}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/spi/resource/mapping/PathMapper.java b/src/main/java/org/apache/sling/spi/resource/mapping/PathMapper.java
new file mode 100644
index 0000000..0220a9c
--- /dev/null
+++ b/src/main/java/org/apache/sling/spi/resource/mapping/PathMapper.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * 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.spi.resource.mapping;
+
+import org.jetbrains.annotations.NotNull;
+import org.osgi.annotation.versioning.ConsumerType;
+
+/**
+ * SPI interface that contributes to path rewriting.
+ *
+ * All registered services build a conceptual chain sorted by service ranking. The resource
link is passed through the chain while any
+ * chain member may or may not make adjustments to the path.
+ */
+@ConsumerType
+public interface PathMapper {
+
+    /**
+     * Contributes to the rewrite process, may or may not make adjustments to the path
+     *
+     * @param path the path to be rewritten
+     * @param context mapping context
+     * @return the adjusted ResourceUri
+     */
+    @NotNull String resolve(@NotNull String path, @NotNull MappingChainContext context);
+
+    /** Contributes to the map process, may or may not make adjustments to the resource link.
+      *
+     * @param path the path to be mapped
+     * @param context mapping context
+     * @return the adjusted path
+     */
+    @NotNull String map(@NotNull String path, @NotNull MappingChainContext context);
+
+}
diff --git a/src/main/java/org/apache/sling/spi/resource/mapping/package-info.java b/src/main/java/org/apache/sling/spi/resource/mapping/package-info.java
new file mode 100644
index 0000000..7dbcf64
--- /dev/null
+++ b/src/main/java/org/apache/sling/spi/resource/mapping/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+@Version("1.0.0")
+package org.apache.sling.spi.resource.mapping;
+
+import org.osgi.annotation.versioning.Version;


Mime
View raw message