Return-Path: X-Original-To: apmail-sling-commits-archive@www.apache.org Delivered-To: apmail-sling-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2AF1411B7C for ; Wed, 2 Jul 2014 11:23:57 +0000 (UTC) Received: (qmail 65465 invoked by uid 500); 2 Jul 2014 11:23:57 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 65411 invoked by uid 500); 2 Jul 2014 11:23:57 -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 65401 invoked by uid 99); 2 Jul 2014 11:23:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Jul 2014 11:23:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED 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, 02 Jul 2014 11:23:55 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 90DED238890D; Wed, 2 Jul 2014 11:23:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1607312 - in /sling/trunk/bundles/resourceresolver/src: main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java test/java/org/apache/sling/resourceresolver/impl/mapping/MapEntriesTest.java Date: Wed, 02 Jul 2014 11:23:35 -0000 To: commits@sling.apache.org From: asanso@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140702112335.90DED238890D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: asanso Date: Wed Jul 2 11:23:35 2014 New Revision: 1607312 URL: http://svn.apache.org/r1607312 Log: SLING-3727 - MapEntries should not update the aliasMap is enableOptimizeAliasResolution is disabled Modified: 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/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=1607312&r1=1607311&r2=1607312&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 Wed Jul 2 11:23:35 2014 @@ -215,7 +215,9 @@ public class MapEntries implements Event } else if ("sling:vanityOrder".equals(changedAttribute)) { doUpdateVanityOrder(path, false); } else if ("sling:alias".equals(changedAttribute)) { - doAddAlias(path); + if (enableOptimizeAliasResolution) { + doAddAlias(path); + } } else { configurationUpdate = true; } @@ -245,7 +247,9 @@ public class MapEntries implements Event } else if ("sling:vanityOrder".equals(changedAttribute)) { doUpdateVanityOrder(path, false); } else if ("sling:alias".equals(changedAttribute)) { - doUpdateAlias(path); + if (enableOptimizeAliasResolution) { + doUpdateAlias(path); + } } else { configurationUpdate = true; } @@ -275,7 +279,9 @@ public class MapEntries implements Event } else if ("sling:vanityOrder".equals(changedAttribute)) { doUpdateVanityOrder(path, true); } else if ("sling:alias".equals(changedAttribute)) { - doRemoveAlias(path, nodeDeletion); + if (enableOptimizeAliasResolution) { + doRemoveAlias(path, nodeDeletion); + } } else { configurationUpdate = true; } 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=1607312&r1=1607311&r2=1607312&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 Wed Jul 2 11:23:35 2014 @@ -609,4 +609,62 @@ public class MapEntriesTest { assertFalse(iterator.hasNext()); } + //SLING-3727 + @Test + public void test_doAddAliasAttributesWithDisableAliasOptimization() throws Exception { + Method method = MapEntries.class.getDeclaredMethod("doAddAttributes", String.class, String[].class, boolean.class); + method.setAccessible(true); + + when(resourceResolverFactory.isOptimizeAliasResolutionEnabled()).thenReturn(false); + mapEntries = new MapEntries(resourceResolverFactory, bundleContext, eventAdmin); + + Resource parent = mock(Resource.class); + when(parent.getPath()).thenReturn("/parent"); + + final Resource result = mock(Resource.class); + when(resourceResolver.getResource("/parent/child")).thenReturn(result); + when(result.getParent()).thenReturn(parent); + when(result.getPath()).thenReturn("/parent/child"); + when(result.getName()).thenReturn("child"); + when(result.adaptTo(ValueMap.class)).thenReturn(buildValueMap("sling:alias", "alias")); + + method.invoke(mapEntries, "/parent/child", + new String[] { "sling:alias" }, false); + + Map aliasMap = mapEntries.getAliasMap("/parent"); + assertNull(aliasMap); + } + + //SLING-3727 + @Test + public void test_doRemoveAttributessWithDisableAliasOptimization() throws Exception { + Method method = MapEntries.class.getDeclaredMethod("doRemoveAttributes", String.class, String[].class, boolean.class, boolean.class); + method.setAccessible(true); + + when(resourceResolverFactory.isOptimizeAliasResolutionEnabled()).thenReturn(false); + mapEntries = new MapEntries(resourceResolverFactory, bundleContext, eventAdmin); + + Resource parent = mock(Resource.class); + when(parent.getPath()).thenReturn("/parent"); + + final Resource result = mock(Resource.class); + when(resourceResolver.getResource("/parent/child")).thenReturn(result); + when(result.getParent()).thenReturn(parent); + when(result.getPath()).thenReturn("/parent/child"); + when(result.getName()).thenReturn("child"); + when(result.adaptTo(ValueMap.class)).thenReturn(buildValueMap("sling:alias", "alias")); + + method.invoke(mapEntries, "/parent/child", + new String[] { "sling:alias" }, false, false); + + Map aliasMap = mapEntries.getAliasMap("/parent"); + assertNull(aliasMap); + } + + //SLING-3727 + @Test + public void test_doUpdateAttributesWithDisableAliasOptimization() throws Exception { + + } + }