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
This commit is contained in:
Alan Davis
2015-06-12 10:33:47 +00:00
parent b249a2d9b9
commit 3a8602f46c
4 changed files with 50 additions and 6 deletions

View File

@@ -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; level<origLevel; level++)
{
TransformationOptionLimits defaultLimits =

View File

@@ -78,8 +78,16 @@ public class TransformationOptionLimits implements Serializable
}
/**
* Defaults values that are set in this object into the
* supplied limits.
* <b>This method overrides rather than defaults values into the supplied limits</b> (as the
* name might suggest), but because of the order in which it is called, this results in the
* correct defaults being set.
* <p>
* 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)

View File

@@ -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.
* <b>This method overrides rather than defaults values into the supplied pair</b> (as the
* name might suggest), but because of the order in which it is called, this results in the
* correct defaults being set.
* <p>
* 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)

View File

@@ -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
{