// - and who would have thought such a simple task could get so nickity -
protected String getUniqueCopyRDN(DN activeDN, DN copyDN)
{
RDN testRDN = copyDN.getLowestRDN();
String testValue = copyDN.getLowestRDN().getRawVal();
String testClass = copyDN.getLowestRDN().getAtt();
// XXX translation of this is ugly! Can't see how to improve it off hand however.
String copyPrefix = testClass + "=" + CBIntText.get("Copy");
String copyPrefix2 = CBIntText.get("of");
boolean originalExists = false;
int copyNumber = 0;
SmartNode parent = getNodeForDN(activeDN);
if (parent != null) // can't think why it *would* equal null, mind you...
{
Enumeration children = parent.children();
/**
* Loop through all children, doing two things;
* a) check if there is already a child with the name
* we're going to add (i.e. we need to do find a new name)
* b) check if there are already copies (i.e we need to
* produce a unique "Copy (512) of ..." name)
*/
SmartNode child;
while (children.hasMoreElements())
{
child = (SmartNode)children.nextElement();
RDN childRDN = child.getRDN();
String childRDNString = childRDN.toString();
if ((!originalExists ) && childRDN.equals(testRDN)) // test if there is already a doo-dad of this name
{
originalExists = true; // ... there is, we have work to do!
}
if (childRDNString.startsWith(copyPrefix)==true) // we have a contender