From 3a8602f46cf4ea8aa97850e8f6e6f9f1b7531acb Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Fri, 12 Jun 2015 10:33:47 +0000 Subject: [PATCH] Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud) 105991: Merged 5.0.N (5.0.3) to HEAD-BUG-FIX (5.1/Cloud) 105915: Merged V4.2-BUG-FIX (4.2.5) to 5.0.N (5.0.3) 105898: MNT-13901 TransformationOptions Timeout Can Not Easily Be Set - Fix "TransformationOptionPair.setMax(long max) and TransformationOptionPair.setLimit(long limit) so that they don't clear the other half of the pair when the value being set is < 0 (unset). - Unit tests added - Added comments about how the 'transformer' code builds up limits to include defaults. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@106013 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../transform/TransformerConfigLimits.java | 2 ++ .../TransformationOptionLimits.java | 12 ++++++++-- .../repository/TransformationOptionPair.java | 22 +++++++++++++++---- .../TransformationOptionPairTest.java | 20 +++++++++++++++++ 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/source/java/org/alfresco/repo/content/transform/TransformerConfigLimits.java b/source/java/org/alfresco/repo/content/transform/TransformerConfigLimits.java index 4d44b89450..6db250b203 100644 --- a/source/java/org/alfresco/repo/content/transform/TransformerConfigLimits.java +++ b/source/java/org/alfresco/repo/content/transform/TransformerConfigLimits.java @@ -179,6 +179,8 @@ public class TransformerConfigLimits extends TransformerPropertyNameExtractor int origLevel = getLevel(transformerName, sourceMimetype); TransformationOptionLimits limits = new TransformationOptionLimits(); + // Start at the most general limits and then override with more specific values so that + // defaults from the most general get used if there is not something more specific. for (int level=0; levelThis method overrides rather than defaults values into the supplied limits (as the + * name might suggest), but because of the order in which it is called, this results in the + * correct defaults being set. + *

+ * A call to this method overrides any values in the supplied limits parameter with those + * in this Object. The supplied limits parameter is being gradually built up by initially + * setting the most general limits and then more specific values for each level. As a result + * 'default' values from the more general levels will still exist at the end if more specific + * ones have not been supplied. + * * @param limits to be set */ public void defaultTo(TransformationOptionLimits limits) diff --git a/source/java/org/alfresco/service/cmr/repository/TransformationOptionPair.java b/source/java/org/alfresco/service/cmr/repository/TransformationOptionPair.java index f721982cfd..1262003793 100644 --- a/source/java/org/alfresco/service/cmr/repository/TransformationOptionPair.java +++ b/source/java/org/alfresco/service/cmr/repository/TransformationOptionPair.java @@ -92,7 +92,10 @@ public class TransformationOptionPair implements Serializable private void setMax(long max) { this.max = max; - this.limit = -1; + if (max >= 0) + { + this.limit = -1; + } } public long getLimit() @@ -111,8 +114,11 @@ public class TransformationOptionPair implements Serializable private void setLimit(long limit) { - this.max = -1; this.limit = limit; + if (limit >= 0) + { + this.max = -1; + } } public long getValue() @@ -139,8 +145,16 @@ public class TransformationOptionPair implements Serializable } /** - * Defaults values that are set in this pair into the - * supplied pair. + * This method overrides rather than defaults values into the supplied pair (as the + * name might suggest), but because of the order in which it is called, this results in the + * correct defaults being set. + *

+ * A call to this method overrides any values in the supplied pair parameter with those + * in this Object. The supplied pair parameter is being gradually built up by initially + * setting the most general values and then more specific values for each level. As a result + * 'default' values from the more general levels will still exist at the end if more specific + * ones have not been supplied. + * * @param pair to be set */ public void defaultTo(TransformationOptionPair pair) diff --git a/source/test-java/org/alfresco/service/cmr/repository/TransformationOptionPairTest.java b/source/test-java/org/alfresco/service/cmr/repository/TransformationOptionPairTest.java index 8a39cf0075..906a7b9880 100644 --- a/source/test-java/org/alfresco/service/cmr/repository/TransformationOptionPairTest.java +++ b/source/test-java/org/alfresco/service/cmr/repository/TransformationOptionPairTest.java @@ -131,6 +131,26 @@ public class TransformationOptionPairTest assertEquals("Getter did not return set value", value, actual); } + @Test + public void testSetMaxClearLimit() throws Exception + { + long value = 1234; + pair.setMax(value, null); + pair.setLimit(-1, null); + long actual = pair.getMax(); + assertEquals("Getter did not return set value", value, actual); + } + + @Test + public void testSetLimitClearMax() throws Exception + { + long value = 1234; + pair.setLimit(value, null); + pair.setMax(-1, null); + long actual = pair.getLimit(); + assertEquals("Getter did not return set value", value, actual); + } + @Test public void testSetClearSet() throws Exception {