You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2013/09/24 08:40:40 UTC

svn commit: r1525802 - in /sling/trunk/bundles/resourceresolver/src: main/java/org/apache/sling/resourceresolver/impl/ main/java/org/apache/sling/resourceresolver/impl/mapping/ main/resources/ main/resources/OSGI-INF/ main/resources/OSGI-INF/metatype/ ...

Author: cziegeler
Date: Tue Sep 24 06:40:39 2013
New Revision: 1525802

URL: http://svn.apache.org/r1525802
Log:
SLING-2944 - Revert accidentally committed additional changes from rev 1525411

Added:
    sling/trunk/bundles/resourceresolver/src/main/resources/
    sling/trunk/bundles/resourceresolver/src/main/resources/OSGI-INF/
    sling/trunk/bundles/resourceresolver/src/main/resources/OSGI-INF/metatype/
    sling/trunk/bundles/resourceresolver/src/main/resources/OSGI-INF/metatype/metatype.properties   (with props)
Modified:
    sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryActivator.java
    sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryImpl.java
    sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapConfigurationProvider.java
    sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
    sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java

Modified: sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryActivator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryActivator.java?rev=1525802&r1=1525801&r2=1525802&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryActivator.java (original)
+++ sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryActivator.java Tue Sep 24 06:40:39 2013
@@ -64,8 +64,8 @@ import org.osgi.service.event.EventAdmin
  */
 @Component(
      name = "org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl",
-     label = "Apache Sling Resource Resolver Factory",
-     description = "Configures the Resource Resolver for request URL and resource path rewriting.",
+     label = "%resource.resolver.name",
+     description = "%resource.resolver.description",
      specVersion = "1.1",
      metatype = true)
 @Properties({
@@ -83,12 +83,7 @@ public class ResourceResolverFactoryActi
         public volatile ServiceRegistration factoryRegistration;
     }
 
-    @Property(value = { "/apps", "/libs" },
-              label = "Resource Search Path",
-              description = "The list of absolute path prefixes " +
-                            "applied to find resources whose path is just specified with a relative path. " +
-                            "The default value is [ \"/apps\", \"/libs\" ]. If an empty path is specified a " +
-                            "single entry path of [ \"/\" ] is assumed.")
+    @Property(value = { "/apps", "/libs" })
     public static final String PROP_PATH = "resource.resolver.searchpath";
 
     /**
@@ -108,33 +103,13 @@ public class ResourceResolverFactoryActi
      * The default value of this property if no configuration is provided is <code>true</code>.
      *
      */
-    @Property(boolValue = true,
-              label = "Namespace Mangling",
-              description = "Defines whether namespace " +
-                            "prefixes of resource names inside the path (e.g. \"jcr:\" in \"/home/path/jcr:content\") " +
-                            "are mangled or not. Mangling means that any namespace prefix contained in the " +
-                            "path is replaced as per the generic substitution pattern \"/([^:]+):/_$1_/\" " +
-                            "when calling the \"map\" method of the resource resolver. Likewise the " +
-                            "\"resolve\" methods will unmangle such namespace prefixes according to the " +
-                            "substituation pattern \"/_([^_]+)_/$1:/\". This feature is provided since " +
-                            "there may be systems out there in the wild which cannot cope with URLs " +
-                            "containing colons, even though they are perfectly valid characters in the " +
-                            "path part of URI references with a scheme. The default value of this property " +
-                            "if no configuration is provided is \"true\".")
+    @Property(boolValue = true)
     private static final String PROP_MANGLE_NAMESPACES = "resource.resolver.manglenamespaces";
 
-    @Property(boolValue = true,
-              label = "Allow Direct Mapping",
-              description = "Whether to add a direct URL mapping to the front of the mapping list.")
+    @Property(boolValue = true)
     private static final String PROP_ALLOW_DIRECT = "resource.resolver.allowDirect";
 
-    @Property(unbounded=PropertyUnbounded.ARRAY,
-              value = "org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProviderFactory",
-              label = "Required Providers",
-              description = "A resource resolver factory is only " +
-                             "available (registered) if all resource providers mentioned in this configuration " +
-                             "are available. Each entry is either a service PID or a filter expression.  " +
-                             "Invalid filters are ignored.")
+    @Property(unbounded=PropertyUnbounded.ARRAY, value = "org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProviderFactory")
     private static final String PROP_REQUIRED_PROVIDERS = "resource.resolver.required.providers";
 
     /**
@@ -143,45 +118,18 @@ public class ResourceResolverFactoryActi
      * multivalue properties at the moment. So we just add a dummy direct
      * mapping.
      */
-    @Property(value = "/:/", unbounded = PropertyUnbounded.ARRAY,
-              label = "Virtual URLs",
-              description = "List of virtual URLs and there mappings to real URLs. " +
-                            "Format is <externalURL>:<internalURL>. Mappings are " +
-                            "applied on the complete request URL only.")
+    @Property(value = "/:/", unbounded = PropertyUnbounded.ARRAY)
     private static final String PROP_VIRTUAL = "resource.resolver.virtual";
 
-    @Property(value = { "/:/", "/content/:/", "/system/docroot/:/" },
-              label = "URL Mappings",
-              description = "List of mappings to apply to paths. Incoming mappings are " +
-                            "applied to request paths to map to resource paths, " +
-                            "outgoing mappings are applied to map resource paths to paths used on subsequent " +
-                            "requests. Form is <internalPathPrefix><op><externalPathPrefix> where <op> is " +
-                            "\">\" 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. Note: The use of \"-\" as the <op> value " +
-                            "indicating a mapping in both directions is deprecated.")
+    @Property(value = { "/:/", "/content/:/", "/system/docroot/:/" })
     private static final String PROP_MAPPING = "resource.resolver.mapping";
 
-    @Property(value = MapEntries.DEFAULT_MAP_ROOT,
-              label = "Mapping Location",
-              description = "The path to the root of the configuration to setup and configure " +
-                            "the ResourceResolver mapping. The default value is /etc/map.")
+    @Property(value = MapEntries.DEFAULT_MAP_ROOT)
     private static final String PROP_MAP_LOCATION = "resource.resolver.map.location";
 
-    @Property(intValue = MapEntries.DEFAULT_DEFAULT_VANITY_PATH_REDIRECT_STATUS,
-              label = "Default Vanity Path Redirect Status",
-              description = "The default status code used when a sling:vanityPath is configured to redirect " +
-                            "and does not have a specific status code associated with it " +
-                            "(via a sling:redirectStatus property)")
+    @Property(intValue = MapEntries.DEFAULT_DEFAULT_VANITY_PATH_REDIRECT_STATUS)
     private static final String PROP_DEFAULT_VANITY_PATH_REDIRECT_STATUS = "resource.resolver.default.vanity.redirect.status";
 
-    private static final boolean DEFAULT_ENABLE_VANITY_PATH = true;
-    @Property(boolValue = DEFAULT_ENABLE_VANITY_PATH,
-              label = "Enable Vanity Paths",
-              description = "This flag controls whether all resources with a sling:vanityPath property " +
-                            "are processed and added to the mappoing table.")
-    private static final String PROP_ENABLE_VANITY_PATH = "resource.resolver.enable.vanitypath";
-
     /** Tracker for the resource decorators. */
     private final ResourceDecoratorTracker resourceDecoratorTracker = new ResourceDecoratorTracker();
 
@@ -219,9 +167,6 @@ public class ResourceResolverFactoryActi
 
     private int defaultVanityPathRedirectStatus;
 
-    /** vanityPath enabled? */
-    private boolean enableVanityPath = DEFAULT_ENABLE_VANITY_PATH;
-
     private final FactoryPreconditions preconds = new FactoryPreconditions();
 
     /** Factory registration. */
@@ -276,10 +221,6 @@ public class ResourceResolverFactoryActi
         return defaultVanityPathRedirectStatus;
     }
 
-    public boolean isVanityPathEnabled() {
-        return this.enableVanityPath;
-    }
-
     // ---------- SCR Integration ---------------------------------------------
 
     /** Activates this component, called by SCR before registering as a service */
@@ -342,7 +283,6 @@ public class ResourceResolverFactoryActi
 
         defaultVanityPathRedirectStatus = PropertiesUtil.toInteger(properties.get(PROP_DEFAULT_VANITY_PATH_REDIRECT_STATUS),
                                                                    MapEntries.DEFAULT_DEFAULT_VANITY_PATH_REDIRECT_STATUS);
-        this.enableVanityPath = PropertiesUtil.toBoolean(properties.get(PROP_ENABLE_VANITY_PATH), DEFAULT_ENABLE_VANITY_PATH);
 
         final BundleContext bc = componentContext.getBundleContext();
 

Modified: sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryImpl.java?rev=1525802&r1=1525801&r2=1525802&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryImpl.java (original)
+++ sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryImpl.java Tue Sep 24 06:40:39 2013
@@ -230,10 +230,6 @@ public class ResourceResolverFactoryImpl
         return this.activator.getDefaultVanityPathRedirectStatus();
     }
 
-    public boolean isVanityPathEnabled() {
-        return this.activator.isVanityPathEnabled();
-    }
-
     /**
      * get's the ServiceTracker of the ResourceAccessSecurity service
      */

Modified: sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapConfigurationProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapConfigurationProvider.java?rev=1525802&r1=1525801&r2=1525802&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapConfigurationProvider.java (original)
+++ sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapConfigurationProvider.java Tue Sep 24 06:40:39 2013
@@ -37,5 +37,4 @@ public interface MapConfigurationProvide
 
     int getDefaultVanityPathRedirectStatus();
 
-    boolean isVanityPathEnabled();
 }

Modified: sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java?rev=1525802&r1=1525801&r2=1525802&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java (original)
+++ sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java Tue Sep 24 06:40:39 2013
@@ -108,8 +108,6 @@ public class MapEntries implements Event
 
     private final ReentrantLock initializing = new ReentrantLock();
 
-    private final boolean enabledVanityPaths;
-
     @SuppressWarnings("unchecked")
     private MapEntries() {
         this.factory = null;
@@ -122,7 +120,6 @@ public class MapEntries implements Event
         this.aliasMap = Collections.<String, Map<String, String>>emptyMap();
         this.registration = null;
         this.eventAdmin = null;
-        this.enabledVanityPaths = true;
     }
 
     @SuppressWarnings("unchecked")
@@ -131,7 +128,6 @@ public class MapEntries implements Event
         this.resolver = factory.getAdministrativeResourceResolver(null);
         this.factory = factory;
         this.mapRoot = factory.getMapRoot();
-        this.enabledVanityPaths = factory.isVanityPathEnabled();
         this.eventAdmin = eventAdmin;
 
         this.resolveMapsMap = Collections.singletonMap(GLOBAL_LIST_KEY, (List<MapEntry>)Collections.EMPTY_LIST);
@@ -143,7 +139,7 @@ public class MapEntries implements Event
 
         final Dictionary<String, String> props = new Hashtable<String, String>();
         props.put(EventConstants.EVENT_TOPIC, "org/apache/sling/api/resource/*");
-        props.put(EventConstants.EVENT_FILTER, createFilter(this.enabledVanityPaths));
+        props.put(EventConstants.EVENT_FILTER, createFilter());
         props.put(Constants.SERVICE_DESCRIPTION, "Map Entries Observation");
         props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
         this.registration = bundleContext.registerService(EventHandler.class.getName(), this, props);
@@ -207,7 +203,7 @@ public class MapEntries implements Event
             loadResolverMap(resolver, globalResolveMap, newMapMaps);
 
             // load the configuration into the resolver map
-            final Collection<String> vanityTargets = (this.enabledVanityPaths ? this.loadVanityPaths(resolver, newResolveMapsMap) : Collections.<String> emptySet());
+            final Collection<String> vanityTargets = this.loadVanityPaths(resolver, newResolveMapsMap);
             loadConfiguration(factory, globalResolveMap);
 
             // load the configuration into the mapper map
@@ -769,8 +765,8 @@ public class MapEntries implements Event
      * modified JCR properties) this allows to only get events interesting for
      * updating the internal structure
      */
-    private static String createFilter(final boolean vanityPathEnabled) {
-        final String[] nodeProps = {
+    private static String createFilter() {
+        final String[] nodeProps = { "sling:vanityPath", "sling:vanityOrder",
                         PROP_REDIRECT_EXTERNAL_REDIRECT_STATUS, PROP_REDIRECT_EXTERNAL,
                         ResourceResolverImpl.PROP_REDIRECT_INTERNAL, PROP_REDIRECT_EXTERNAL_STATUS,
                         PROP_REG_EXP, ResourceResolverImpl.PROP_ALIAS };
@@ -779,10 +775,6 @@ public class MapEntries implements Event
         filter.append("(|");
         for (final String eventProp : eventProps) {
             filter.append("(|");
-            if (  vanityPathEnabled ) {
-                filter.append('(').append(eventProp).append('=').append("sling:vanityPath").append(')');
-                filter.append('(').append(eventProp).append('=').append("sling:vanityOrder").append(')');
-            }
             for (final String nodeProp : nodeProps) {
                 filter.append('(').append(eventProp).append('=').append(nodeProp).append(')');
             }

Added: sling/trunk/bundles/resourceresolver/src/main/resources/OSGI-INF/metatype/metatype.properties
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=1525802&view=auto
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/main/resources/OSGI-INF/metatype/metatype.properties (added)
+++ sling/trunk/bundles/resourceresolver/src/main/resources/OSGI-INF/metatype/metatype.properties Tue Sep 24 06:40:39 2013
@@ -0,0 +1,84 @@
+#
+#  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.
+#
+
+
+#
+# This file contains localization strings for configuration labels and
+# descriptions as used in the metatype.xml descriptor generated by the
+# the SCR plugin
+
+#
+# Localizations for Resource Resolver Factory configuration
+resource.resolver.name = Apache Sling Resource Resolver Factory
+resource.resolver.description =  Configures the Resource Resolver for request \
+ URL and resource path rewriting.
+
+resource.resolver.map.location.name = Mapping Location
+resource.resolver.map.location.description = The path to the root of the \
+ configuration to setup and configure the ResourceResolver mapping. The \
+ default value is /etc/map.
+
+resource.resolver.allowDirect.name = Allow Direct Mapping
+resource.resolver.allowDirect.description = Whether to add a direct URL \
+ mapping to the front of the mapping list.
+
+resource.resolver.virtual.name = Virtual URLs
+resource.resolver.virtual.description = List of virtual URLs and there \
+ mappings to real URLs. Format is <externalURL>:<internalURL>. Mappings are \
+ applied on the complete request URL only.
+
+resource.resolver.mapping.name = URL Mappings
+resource.resolver.mapping.description = List of mappings to apply to paths. \
+ Incoming mappings are applied to request paths to map to resource paths, \
+ outgoing mappings are applied to map resource paths to paths used on subsequent \
+ requests. Form is <internalPathPrefix><op><externalPathPrefix> where <op> is \
+ ">" 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. Note: The use of "-" as the <op> 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 \
+ applied to find resources whose path is just specified with a relative path. \
+ The default value is [ "/apps", "/libs" ]. If an empty path is specified a \
+ single entry path of [ "/" ] is assumed.
+
+resource.resolver.manglenamespaces.name = Namespace Mangling
+resource.resolver.manglenamespaces.description = Defines whether namespace \
+ prefixes of resource names inside the path (e.g. "jcr:" in "/home/path/jcr:content") \
+ are mangled or not. Mangling means that any namespace prefix contained in the \
+ path is replaced as per the generic substitution pattern "/([^:]+):/_$1_/" \
+ when calling the "map" method of the resource resolver. Likewise the \
+ "resolve" methods will unmangle such namespace prefixes according to the \
+ substituation pattern "/_([^_]+)_/$1:/". This feature is provided since \
+ there may be systems out there in the wild which cannot cope with URLs \
+ containing colons, even though they are perfectly valid characters in the \
+ path part of URI references with a scheme. The default value of this property \
+ if no configuration is provided is "true".
+
+resource.resolver.required.providers.name = Required Providers
+resource.resolver.required.providers.description = A resource resolver factory is only \
+ available (registered) if all resource providers mentioned in this configuration \
+ are available. Each entry is either a service PID or a filter expression. \
+ Invalid filters are ignored.
+
+resource.resolver.default.vanity.redirect.status.name = Default Vanity Path Redirect Status
+resource.resolver.default.vanity.redirect.status.description = The default status code \
+ used when a sling:vanityPath is configured to redirect and does not have a specific \
+ status code associated with it (via a sling:redirectStatus property)
\ No newline at end of file

Propchange: sling/trunk/bundles/resourceresolver/src/main/resources/OSGI-INF/metatype/metatype.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/bundles/resourceresolver/src/main/resources/OSGI-INF/metatype/metatype.properties
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: sling/trunk/bundles/resourceresolver/src/main/resources/OSGI-INF/metatype/metatype.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java?rev=1525802&r1=1525801&r2=1525802&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java (original)
+++ sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java Tue Sep 24 06:40:39 2013
@@ -67,7 +67,6 @@ public class MapEntriesTest {
         MockitoAnnotations.initMocks(this);
 
         when(resourceResolverFactory.getAdministrativeResourceResolver(null)).thenReturn(resourceResolver);
-        when(resourceResolverFactory.isVanityPathEnabled()).thenReturn(true);
         when(resourceResolver.findResources(anyString(), eq("sql"))).thenReturn(
                 Collections.<Resource> emptySet().iterator());