/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
*/
/**
* The task that is called when we must modify an entry.
*
*/
{
private boolean mustRename;
private boolean hasModifications;
private boolean useAdminCtx = false;
/**
* Constructor of the task.
* @param info the control panel information.
* @param dlg the progress dialog where the task progress will be displayed.
* @param newEntry the entry containing the new values.
* @param oldEntry the old entry as we retrieved using JNDI.
* @param controller the BrowserController.
* @param path the TreePath corresponding to the node in the tree that we
* want to modify.
*/
{
this.controller = controller;
try
{
{
{
{
}
}
}
}
catch (OpenDsException ode)
{
ode);
}
// Find password modifications
{
{
break;
}
}
if (passwordModification != null)
{
}
(passwordModification != null);
}
/**
* Tells whether there actually modifications on the entry.
* @return <CODE>true</CODE> if there are modifications and <CODE>false</CODE>
* otherwise.
*/
public boolean hasModifications()
{
return hasModifications;
}
/**
* {@inheritDoc}
*/
{
return Type.MODIFY_ENTRY;
}
/**
* {@inheritDoc}
*/
{
return backendSet;
}
/**
* {@inheritDoc}
*/
{
}
/**
* {@inheritDoc}
*/
{
return null;
}
/**
* {@inheritDoc}
*/
{
}
/**
* {@inheritDoc}
*/
{
boolean canLaunch = true;
if (!isServerRunning())
{
{
// All the operations are incompatible if they apply to this
// backend for safety. This is a short operation so the limitation
// has not a lot of impact.
{
canLaunch = false;
}
}
}
return canLaunch;
}
/**
* {@inheritDoc}
*/
public boolean regenerateDescriptor()
{
return false;
}
/**
* {@inheritDoc}
*/
public void runTask()
{
try
{
if (!mustRename)
{
ModificationItem[] mods =
{
public void run()
{
}
});
{
public void run()
{
}
});
}
}
else
{
}
}
catch (Throwable t)
{
lastException = t;
}
}
/**
* {@inheritDoc}
*/
public void postOperation()
{
(passwordModification != null))
{
try
{
if (o instanceof byte[])
{
try
{
}
catch (Throwable t)
{
throw new RuntimeException("Unexpected error: "+t, t);
}
}
else
{
}
{
}
null,
false,
getInfo());
getProgressDialog().setVisible(true);
}
catch (NamingException ne)
{
// This should not happen
}
}
}
/**
* Modifies and renames the entry.
* @param ctx the connection to the server.
* @param oldDN the oldDN of the entry.
* @param originalEntry the original entry.
* @param newEntry the new entry.
* @param originalMods the original modifications (these are required since
* we might want to update them).
* @throws CannotRenameException if we cannot perform the modification.
* @throws NamingException if an error performing the modification occurs.
*/
throws CannotRenameException, NamingException
{
boolean rdnTypeChanged =
boolean found = false;
for (int j=0;
oldRDN.getAttributeName(j));
}
rdnTypeChanged = !found;
}
if (rdnTypeChanged) {
/* Check if user changed the objectclass...*/
boolean changedOc = false;
{
if (changedOc)
{
break;
}
}
if (changedOc)
{
/* See if the original entry contains the new
naming attribute(s) if it does we will be able
to perform the renaming and then the
modifications without problem */
boolean entryContainsRdnTypes = true;
{
newRDN.getAttributeName(i));
}
if (!entryContainsRdnTypes)
{
throw new CannotRenameException(
}
}
}
{
public void run()
{
}
});
{
public void run()
{
}
});
{
{
public void run()
{
}
});
mods);
{
public void run()
{
{
}
}
});
}
}
/**
* Gets the modifications to apply between two entries.
* @param newEntry the new entry.
* @param oldEntry the old entry.
* @param info the ControlPanelInfo, used to retrieve the schema for instance.
* @return the modifications to apply between two entries.
*/
new ArrayList<ModificationItem>();
{
{
continue;
}
{
}
{
}
boolean isAttributeInNewRdn = false;
{
if (isAttributeInNewRdn)
{
}
}
/* Check the attributes of the old DN. If we are renaming them they
* will be deleted. Check that they are on the new entry but not in
* the new RDN. If it is the case we must add them after the renaming.
*/
/* Check the value in the RDN that will be deleted. If the value was
* on the previous RDN but not in the new entry it will be deleted. So
* we must avoid to include it as a delete modification in the
* modifications.
*/
try
{
}
catch (DirectoryException de)
{
throw new RuntimeException("Unexpected error parsing DN: "+
}
{
{
boolean containsValue = false;
{
{
containsValue = true;
break;
}
}
if (containsValue)
{
{
}
}
else
{
}
break;
}
}
{
{
}
{
}
} else {
attrType);
if (oldRdnValueDeleted != null)
{
}
attrType);
if (oldRdnValueToAdd != null)
{
}
{
}
else
{
{
}
{
{
}
{
}
}
}
}
}
/* Check if there are attributes to delete */
{
{
continue;
}
boolean found = false;
{
{
{
found = true;
break;
}
}
}
{
new BasicAttribute(attrName)));
}
}
return modifications;
}
/**
* Creates a JNDI attribute using an attribute name and a set of values.
* @param attrName the attribute name.
* @param values the values.
* @return a JNDI attribute using an attribute name and a set of values.
*/
{
}
return attribute;
}
/**
* Creates an AttributeValue for an attribute and a value (the one we got
* using JNDI).
* @param attrType the attribute type.
* @param value the value found using JNDI.
* @return an AttributeValue object.
*/
{
ByteString v;
{
}
else if (value instanceof byte[])
{
}
else
{
}
}
/**
* Returns the set of AttributeValue that must be deleted.
* @param oldValues the old values of the entry.
* @param newValues the new values of the entry.
* @param attrType the attribute type.
* @return the set of AttributeValue that must be deleted.
*/
{
{
{
}
}
return valuesToDelete;
}
/**
* Returns the set of AttributeValue that must be added.
* @param oldValues the old values of the entry.
* @param newValues the new values of the entry.
* @param attrType the attribute type.
* @return the set of AttributeValue that must be added.
*/
{
{
boolean found = false;
{
if (found)
{
break;
}
}
if (!found)
{
}
}
return valuesToAdd;
}
}