From 339d1e59da678d716b3673041bc429d759985cd9 Mon Sep 17 00:00:00 2001
From: pvarga88 <pvarga@opentext.com>
Date: Tue, 10 Mar 2020 07:57:43 +0000
Subject: [PATCH] Backport fix for OPENDJ-3653 (#107)
---
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java | 47 ++++++++++++++---------------------------------
1 files changed, 14 insertions(+), 33 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
index ffe20c0..963ea88 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
@@ -16,6 +16,7 @@
*/
package org.opends.server.workflowelement.localbackend;
+import java.math.BigInteger;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@@ -1381,22 +1382,7 @@
ERR_MODIFY_INCREMENT_REQUIRES_SINGLE_VALUE.get(entryDN, attrDesc));
}
- MatchingRule eqRule = t.getEqualityMatchingRule();
- ByteString v = attr.iterator().next();
-
- long incrementValue;
- try
- {
- String nv = eqRule.normalizeAttributeValue(v).toString();
- incrementValue = Long.parseLong(nv);
- }
- catch (Exception e)
- {
- logger.traceException(e);
-
- throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- ERR_MODIFY_INCREMENT_PROVIDED_VALUE_NOT_INTEGER.get(entryDN, attrDesc, v), e);
- }
+ BigInteger incrementValue = parseLdapInteger(attr.iterator().next(), attrDesc, entryDN);
// Get the attribute that is to be incremented.
Attribute modifiedAttr = modifiedEntry.getAttribute(attrDesc);
@@ -1412,29 +1398,24 @@
AttributeBuilder builder = new AttributeBuilder(modifiedAttrDesc);
for (ByteString existingValue : modifiedAttr)
{
- long currentValue;
- try
- {
- currentValue = Long.parseLong(existingValue.toString());
- }
- catch (Exception e)
- {
- logger.traceException(e);
-
- throw new DirectoryException(
- ResultCode.INVALID_ATTRIBUTE_SYNTAX,
- ERR_MODIFY_INCREMENT_REQUIRES_INTEGER_VALUE.get(entryDN, modifiedAttrDesc, existingValue),
- e);
- }
-
- long newValue = currentValue + incrementValue;
- builder.add(String.valueOf(newValue));
+ BigInteger currentValue = parseLdapInteger(existingValue, modifiedAttrDesc, entryDN);
+ builder.add(currentValue.add(incrementValue).toString());
}
// Replace the existing attribute with the incremented version.
modifiedEntry.replaceAttribute(builder.toAttribute());
}
+ private BigInteger parseLdapInteger(ByteString v, AttributeDescription attrDesc, DN entryDN) throws DirectoryException {
+ try {
+ return new BigInteger(v.toString());
+ } catch (Exception e) {
+ logger.traceException(e);
+ throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
+ ERR_MODIFY_INCREMENT_REQUIRES_INTEGER_VALUE.get(entryDN, attrDesc, v), e);
+ }
+ }
+
/**
* Performs additional preliminary processing that is required for a password change.
*
--
Gitblit v1.10.0