/** * Update an entry with the designated DN. * * @param oldSet the old entry containing teh old set of attributes. * @param newSet the new entry containing the replacement set of attributes. * @return the operation's success status. */ public boolean updateEntry(DXEntry oldSet, DXEntry newSet) { try { if (DXAttributes.attributesEqual(oldSet, newSet)) return true; // nothing to do. DN nodeDN = newSet.getDN(); RDN newRDN = nodeDN.getLowestRDN(); DXAttributes adds = null; // use modify-add for new attribute values (inc entirely new attribute) DXAttributes reps = null; // use modify-replace for changed attribute values DXAttributes dels = null; // use modify-delete for deleted attribute values (inc deleting entire attribute) reps = DXAttributes.getReplacementSet(newRDN, oldSet, newSet); dels = DXAttributes.getDeletionSet(newRDN, oldSet, newSet); adds = DXAttributes.getAdditionSet(newRDN, oldSet, newSet); /*if (false) printDebug(oldSet, newSet, adds, reps, dels);*/ CBUtility.log("updateNode: ", 4); ModificationItem[] mods; mods = new ModificationItem[dels.size() + reps.size() + adds.size()]; int modIndex = 0; modIndex = loadMods(mods, dels.getAll(), DirContext.REMOVE_ATTRIBUTE, modIndex); modIndex = loadMods(mods, adds.getAll(), DirContext.ADD_ATTRIBUTE, modIndex); modIndex = loadMods(mods, reps.getAll(), DirContext.REPLACE_ATTRIBUTE, modIndex); return modifyAttributes(nodeDN, mods); // TE: This may fail, returning false. } catch (NamingException e) { error("Unable to update node " + oldSet.getDN() + "! " + e.toString(), e); e.printStackTrace(); return false; } catch (Exception e) { error("Unexpected Error updating node " + oldSet.getDN() + "! " + e.toString(), e); e.printStackTrace(); return false; } }