Return-Path: Delivered-To: apmail-sling-commits-archive@www.apache.org Received: (qmail 55147 invoked from network); 5 May 2010 15:11:48 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 5 May 2010 15:11:48 -0000 Received: (qmail 33540 invoked by uid 500); 5 May 2010 15:11:47 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 33473 invoked by uid 500); 5 May 2010 15:11:47 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 33466 invoked by uid 99); 5 May 2010 15:11:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 May 2010 15:11:47 +0000 X-ASF-Spam-Status: No, hits=-1385.1 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 May 2010 15:11:42 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id AE08323889BF; Wed, 5 May 2010 15:10:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r941335 - in /sling/trunk/bundles/jcr/resource/src/main: java/org/apache/sling/jcr/resource/internal/ java/org/apache/sling/jcr/resource/internal/helper/ resources/OSGI-INF/metatype/ Date: Wed, 05 May 2010 15:10:52 -0000 To: commits@sling.apache.org From: fmeschbe@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100505151052.AE08323889BF@eris.apache.org> Author: fmeschbe Date: Wed May 5 15:10:52 2010 New Revision: 941335 URL: http://svn.apache.org/viewvc?rev=941335&view=rev Log: SLING-1519 Use colon (:) as a bidirectional URL Mapping indicator instead of the dash (-) to prevent wrong mappings if the source path contains a dash. The dash is still supported for backwards compatibility with existing configuration Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/Mapping.java sling/trunk/bundles/jcr/resource/src/main/resources/OSGI-INF/metatype/metatype.properties Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java?rev=941335&r1=941334&r2=941335&view=diff ============================================================================== --- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java (original) +++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java Wed May 5 15:10:52 2010 @@ -143,15 +143,13 @@ public class JcrResourceResolverFactoryI * multivalue properties at the moment. So we just add a dummy direct * mapping. * - * @scr.property values.1="/-/" + * @scr.property values.1="/:/" */ private static final String PROP_VIRTUAL = "resource.resolver.virtual"; /** - * @scr.property values.1="/-/" values.2="/content/-/" - * Cvalues.3="/apps/×/docroot/-/" - * Cvalues.4="/libs/×/docroot/-/" - * values.5="/system/docroot/-/" + * @scr.property values.1="/:/" values.2="/content/:/" + * values.3="/system/docroot/:/" */ private static final String PROP_MAPPING = "resource.resolver.mapping"; Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/Mapping.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/Mapping.java?rev=941335&r1=941334&r2=941335&view=diff ============================================================================== --- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/Mapping.java (original) +++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/Mapping.java Wed May 5 15:10:52 2010 @@ -18,7 +18,8 @@ */ package org.apache.sling.jcr.resource.internal.helper; -import java.util.StringTokenizer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * The Mapping class conveys the mapping configuration used by @@ -63,6 +64,13 @@ public class Mapping { } }; + // Regular expression to split mapping configuration strings into three + // groups: + // 1 - external path prefix + // 2 - direction (Outbound (>), Bidirectional (:), Inbound (>)) + // 3 - internap path prefix + private static final Pattern CONFIG_SPLITTER = Pattern.compile("(.+)([:<>])(.+)"); + /** the 'from' (inside, repository) mapping */ private final String from; @@ -78,36 +86,6 @@ public class Mapping { /** the mapping direction */ private final int direction; - /** - * Creates a new instance of a mapping. - * - * @param from Handle prefix possible valid in the ContentBus. - * @param to URI path prefix to be replaced by from to get a possibly valid - * handle. - * @param dir the direction of the mapping. either "inwards", "outwards" or - * "both". - * @throws NullPointerException if either from or - * to is null. - */ - public Mapping(String from, String to, String dir) { - this(from, to, "in".equals(dir) ? Mapping.INBOUND : ("out".equals(dir) - ? Mapping.OUTBOUND - : Mapping.BOTH)); - } - - /** - * Creates a new instance of a mapping. - * - * @param from Handle prefix possible valid in the ContentBus. - * @param to URI path prefix to be replaced by from to get a possibly valid - * handle. - * @throws NullPointerException if either from or - * to is null. - */ - public Mapping(String from, String to) { - this(from, to, Mapping.BOTH); - } - public Mapping(String config) { this(split(config)); } @@ -122,10 +100,10 @@ public class Mapping { ? Mapping.INBOUND : ("<".equals(parts[1]) ? Mapping.OUTBOUND : Mapping.BOTH); } - + @Override public String toString() { - return "Mapping (from=" + from + ", to=" + to + ", direction=" + direction + return "Mapping (from=" + from + ", to=" + to + ", direction=" + direction + ", lengths=" + fromLength + "/" + toLength; } @@ -169,12 +147,12 @@ public class Mapping { public String getFrom() { return from; } - + // TODO: temporary public String getTo() { return to; } - + /** * Checks, if this mapping is defined for inbound mapping. * @@ -207,14 +185,23 @@ public class Mapping { } public static String[] split(String map) { - String[] res = new String[3]; // src, op, dst - StringTokenizer st = new StringTokenizer(map, "-<>", true); - for (int i = 0; i < res.length; i++) { - res[i] = st.hasMoreTokens() ? st.nextToken() : ""; + // standard case of mapping [<:>] + Matcher mapMatch = CONFIG_SPLITTER.matcher(map); + if (mapMatch.matches()) { + return new String[] { mapMatch.group(1), mapMatch.group(2), + mapMatch.group(3) }; + } + + // backwards compatibility using "-" instead of ":" + int dash = map.indexOf('-'); + if (dash > 0) { + return new String[] { map.substring(0, dash), + map.substring(dash, dash + 1), + map.substring(dash + 1, map.length()) }; } - return res; + return new String[] { map, "-", map }; } } Modified: sling/trunk/bundles/jcr/resource/src/main/resources/OSGI-INF/metatype/metatype.properties URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=941335&r1=941334&r2=941335&view=diff ============================================================================== --- sling/trunk/bundles/jcr/resource/src/main/resources/OSGI-INF/metatype/metatype.properties (original) +++ sling/trunk/bundles/jcr/resource/src/main/resources/OSGI-INF/metatype/metatype.properties Wed May 5 15:10:52 2010 @@ -40,7 +40,7 @@ resource.resolver.allowDirect.descriptio resource.resolver.virtual.name = Virtual URLs resource.resolver.virtual.description = List of virtual URLs and there \ - mappings to real URLs. Format is -. Mappings are \ + mappings to real URLs. Format is :. Mappings are \ applied on the complete request URL only. resource.resolver.mapping.name = URL Mappings @@ -48,9 +48,10 @@ resource.resolver.mapping.description = Incoming mappings are applied to request URLs to map to Content paths, \ outgoing mappings are applied to map Content paths to URLs used on subsequent \ requests. Form ist where is \ - ">" for incoming mappings, "<" for outgoing mappings and "-" for mappings \ + ">" for incoming mappings, "<" for outgoing mappings and ":" for mappings \ applied in both directions. Mappings are applied in configuration order by \ - comparing and replacing URL prefixes. + comparing and replacing URL prefixes. Note: The use of "-" as the value \ + indicating a mapping in both directions is deprecated. resource.resolver.searchpath.name = Resource Search Path resource.resolver.searchpath.description = The list of absolute path prefixes \