if (readProperty.hasError()) {
request.setError(readProperty.getError());
return;
}
Property property = readProperty.getProperty();
List<Object> actualRemovedValues = new ArrayList<Object>(request.removedValues().size());
List<Object> newValues = property == null ? new LinkedList<Object>() : new LinkedList<Object>(
Arrays.asList(property.getValuesAsArray()));
// Calculate what the new values should be
for (Object removedValue : request.removedValues()) {
for (Iterator<Object> iter = newValues.iterator(); iter.hasNext();) {
if (iter.next().equals(removedValue)) {
iter.remove();
actualRemovedValues.add(removedValue);
break;
}
}
}
newValues.addAll(request.addedValues());
Property newProperty = getExecutionContext().getPropertyFactory().create(propertyName, newValues);
// Update the current values
SetPropertyRequest setProperty = new SetPropertyRequest(on, workspaceName, newProperty);
process(setProperty);