From 93ad50f0e8b182978c790c0707bd0a910ae2a39e Mon Sep 17 00:00:00 2001
From: jcambon <jcambon@localhost>
Date: Mon, 10 Nov 2008 08:07:58 +0000
Subject: [PATCH] Fix for Issue #3569: dsconfig does not handle correctly multi-valued properties
---
opends/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java | 42 ++++++++++++++++++++++++++----------------
1 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/opends/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java b/opends/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java
index e506b6d..7b767aa 100644
--- a/opends/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java
+++ b/opends/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java
@@ -754,6 +754,9 @@
// Set properties.
for (String m : propertySetArgument.getValues()) {
+ if (!propertyResetArgument.getValues().isEmpty()) {
+ throw ArgumentExceptionFactory.incompatiblePropertyModification(m);
+ }
// Parse the property "property:value".
int sep = m.indexOf(':');
@@ -790,6 +793,9 @@
// Remove properties.
for (String m : propertyRemoveArgument.getValues()) {
+ if (!propertyResetArgument.getValues().isEmpty()) {
+ throw ArgumentExceptionFactory.incompatiblePropertyModification(m);
+ }
// Parse the property "property:value".
int sep = m.indexOf(':');
@@ -816,19 +822,20 @@
}
// Apply the modification.
- if (lastModTypes.containsKey(propertyName)) {
- if (lastModTypes.get(propertyName) == ModificationType.SET) {
- throw ArgumentExceptionFactory.incompatiblePropertyModification(m);
- }
- } else {
- lastModTypes.put(propertyName, ModificationType.REMOVE);
- modifyPropertyValues(child, pd, changes, ModificationType.REMOVE,
- value);
+ if (lastModTypes.containsKey(propertyName) &&
+ (lastModTypes.get(propertyName) == ModificationType.SET)) {
+ throw ArgumentExceptionFactory.incompatiblePropertyModification(m);
}
+
+ lastModTypes.put(propertyName, ModificationType.REMOVE);
+ modifyPropertyValues(child, pd, changes, ModificationType.REMOVE, value);
}
// Add properties.
for (String m : propertyAddArgument.getValues()) {
+ if (!propertyResetArgument.getValues().isEmpty()) {
+ throw ArgumentExceptionFactory.incompatiblePropertyModification(m);
+ }
// Parse the property "property:value".
int sep = m.indexOf(':');
@@ -855,14 +862,13 @@
}
// Apply the modification.
- if (lastModTypes.containsKey(propertyName)) {
- if (lastModTypes.get(propertyName) == ModificationType.SET) {
- throw ArgumentExceptionFactory.incompatiblePropertyModification(m);
- }
- } else {
- lastModTypes.put(propertyName, ModificationType.ADD);
- modifyPropertyValues(child, pd, changes, ModificationType.ADD, value);
+ if (lastModTypes.containsKey(propertyName) &&
+ (lastModTypes.get(propertyName) == ModificationType.SET)) {
+ throw ArgumentExceptionFactory.incompatiblePropertyModification(m);
}
+
+ lastModTypes.put(propertyName, ModificationType.ADD);
+ modifyPropertyValues(child, pd, changes, ModificationType.ADD, value);
}
// Apply the command line changes.
@@ -931,7 +937,11 @@
values.add(value);
break;
case REMOVE:
- values.remove(value);
+ if (values.remove(value) != true) {
+ // value was not part of values
+ throw ArgumentExceptionFactory.
+ unknownValueForMultiValuedProperty(s, pd.getName());
+ }
break;
case SET:
values = new TreeSet<T>(pd);
--
Gitblit v1.10.0