incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1591888 - /sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
Date Fri, 02 May 2014 12:30:07 GMT
Author: cziegeler
Date: Fri May  2 12:30:07 2014
New Revision: 1591888

URL: http://svn.apache.org/r1591888
Log:
SLING-3523 : ResourceResolverImpl.mangleNamespace and unmangleNamespaces behave differently

Modified:
    sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java

Modified: sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java?rev=1591888&r1=1591887&r2=1591888&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
(original)
+++ sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
Fri May  2 12:30:07 2014
@@ -979,8 +979,31 @@ public class ResourceResolverImpl extend
 
             final StringBuffer buf = new StringBuffer();
             while (m.find()) {
-                final String replacement = MANGLE_NAMESPACE_IN_PREFIX + m.group(1) + MANGLE_NAMESPACE_IN_SUFFIX;
-                m.appendReplacement(buf, replacement);
+                final String namespace = m.group(1);
+                try {
+
+                    // throws if "namespace" is not a registered
+                    // namespace prefix
+                    final Session session = getSession();
+                    if ( session != null ) {
+                        session.getNamespaceURI(namespace);
+                        final String replacement = MANGLE_NAMESPACE_IN_PREFIX + namespace
+ MANGLE_NAMESPACE_IN_SUFFIX;
+                        m.appendReplacement(buf, replacement);
+                    } else {
+                        logger.debug("mangleNamespaces: '{}' is not a prefix, not mangling",
namespace);
+                    }
+
+
+                } catch (final NamespaceException ne) {
+
+                    // not a valid prefix
+                    logger.debug("mangleNamespaces: '{}' is not a prefix, not mangling",
namespace);
+
+                } catch (final RepositoryException re) {
+
+                    logger.warn("mangleNamespaces: Problem checking namespace '{}'", namespace,
re);
+
+                }
             }
 
             m.appendTail(buf);



Mime
View raw message