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 {