ModifyDNMsg.java revision d25372dc8e65a9ed019a88fdf659ca61313f1b31
/*
* 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
* 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
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. 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 2006-2008 Sun Microsystems, Inc.
*/
/**
* Message used to send Modify DN information.
*/
public class ModifyDNMsg extends UpdateMsg
{
private String newSuperior;
private boolean deleteOldRdn;
private String newSuperiorId;
/**
* construct a new Modify DN message.
*
* @param operation The operation to use for building the message
*/
{
else
newSuperior = null;
}
/**
* construct a new Modify DN message.
*
* @param dn The dn to use for building the message.
* @param changeNumber The changeNumberto use for building the message.
* @param uid The unique id to use for building the message.
* @param newParentUid The new parent unique id to use for building
* the message.
* @param deleteOldRdn boolean indicating if old rdn must be deleted to use
* for building the message.
* @param newSuperior The new Superior entry to use for building the message.
* @param newRDN The new Rdn to use for building the message.
*/
{
this.deleteOldRdn = deleteOldRdn;
this.newSuperior = newSuperior;
}
/**
* Creates a new ModifyDN message from a byte[].
*
* @param in The byte[] from which the operation must be read.
* @throws DataFormatException The input byte[] is not a valid ModifyDNMsg.
* @throws UnsupportedEncodingException If UTF8 is not supported.
*/
{
byte[] allowedPduTypes = new byte[2];
/* read the newRDN
* first calculate the length then construct the string
*/
/* read the newSuperior
* first calculate the length then construct the string
*/
if (length != 0)
else
newSuperior = null;
/* read the new parent Id
*/
if (length != 0)
else
/* get the deleteoldrdn flag */
deleteOldRdn = false;
else
deleteOldRdn = true;
}
/**
* {@inheritDoc}
*/
public AbstractOperation createOperation(
{
return moddn;
}
/**
* {@inheritDoc}
*/
public byte[] getBytes() throws UnsupportedEncodingException
{
byte[] byteNewSuperior = null;
byte[] byteNewSuperiorId = null;
// calculate the length necessary to encode the parameters
if (newSuperior != null)
{
}
else
length += 1;
if (newSuperiorId != null)
{
}
else
length += 1;
/* put the new RDN and a terminating 0 */
/* put the newsuperior and a terminating 0 */
if (newSuperior != null)
{
}
else
/* put the newsuperiorId and a terminating 0 */
if (newSuperiorId != null)
{
}
else
/* put the deleteoldrdn flag */
if (deleteOldRdn)
else
return resultByteArray;
}
/**
* {@inheritDoc}
*/
{
{
return "ModifyDNMsg content: " +
"\nprotocolVersion: " + protocolVersion +
"\ndn: " + dn +
"\nchangeNumber: " + changeNumber +
"\nuniqueId: " + uniqueId +
"\nassuredFlag: " + assuredFlag +
"\nnewRDN: " + newRDN +
"\nnewSuperior: " + newSuperior +
"\ndeleteOldRdn: " + deleteOldRdn;
}
{
return "ModifyDNMsg content: " +
"\nprotocolVersion: " + protocolVersion +
"\ndn: " + dn +
"\nchangeNumber: " + changeNumber +
"\nuniqueId: " + uniqueId +
"\nnewRDN: " + newRDN +
"\nnewSuperior: " + newSuperior +
"\ndeleteOldRdn: " + deleteOldRdn +
"\nassuredFlag: " + assuredFlag +
"\nassuredMode: " + assuredMode +
"\nsafeDataLevel: " + safeDataLevel;
}
}
/**
* Set the new superior.
* @param string the new superior.
*/
{
}
/**
* Get the new superior.
*
* @return The new superior.
*/
public String getNewSuperior()
{
return newSuperior;
}
/**
* Get the new superior id.
*
* @return The new superior id.
*/
public String getNewSuperiorId()
{
return newSuperiorId;
}
/**
* Get the delete old rdn option.
*
* @return The delete old rdn option.
*/
public boolean deleteOldRdn()
{
return deleteOldRdn;
}
/**
* Set the new superior id.
*
* @param newSup The new superior id.
*/
{
}
/**
* Set the delete old rdn option.
*
* @param delete The delete old rdn option.
*/
public void setDeleteOldRdn(boolean delete)
{
}
/**
* Get the new RDN of this operation.
*
* @return The new RDN of this operation.
*/
{
return newRDN;
}
/**
* Set the new RDN of this operation.
* @param newRDN the new RDN of this operation.
*/
{
}
/**
* Check if this MSG will change the DN of the target entry to be
* the same as the dn given as a parameter.
* @param targetDn the DN to use when checking if this MSG will change
* the DN of the entry to a given DN.
* @return A boolean indicating if the modify DN MSG will change the DN of
* the target entry to be the same as the dn given as a parameter.
*/
{
try
{
if (newSuperior == null)
{
}
else
{
}
return true;
else
return false;
} catch (DirectoryException e)
{
// The DN was not a correct DN, and therefore does not a parent of the
// DN given as a parameter.
return false;
}
}
/**
* Check if the new dn of this ModifyDNMsg is the same as the targetDN
* given in parameter.
*
* @param targetDN The targetDN to use to check for equality.
*
* @return A boolean indicating if the targetDN if the same as the new DN of
* the ModifyDNMsg.
*/
{
try
{
return true;
else
return false;
} catch (DirectoryException e)
{
// The DN was not a correct DN, and therefore does not match the
// DN given as a parameter.
return false;
}
}
/**
* Check if the new parent of the modifyDNMsg is the same as the targetDN
* given in parameter.
*
* @param targetDN the targetDN to use when checking equality.
*
* @return A boolean indicating if the new parent of the modifyDNMsg is the
* same as the targetDN.
*/
{
try
{
return true;
else
return false;
} catch (DirectoryException e)
{
// The newsuperior was not a correct DN, and therefore does not match the
// DN given as a parameter.
return false;
}
}
/**
* {@inheritDoc}
*/
public int size()
{
// The MODDN message size are mainly dependent on the
// size of the DN. let's assume that they average on 100 bytes
return 100;
}
/**
* {@inheritDoc}
*/
public byte[] getBytes_V1() throws UnsupportedEncodingException
{
byte[] byteNewSuperior = null;
byte[] byteNewSuperiorId = null;
// calculate the length necessary to encode the parameters
if (newSuperior != null)
{
}
else
length += 1;
if (newSuperiorId != null)
{
}
else
length += 1;
/* put the new RDN and a terminating 0 */
/* put the newsuperior and a terminating 0 */
if (newSuperior != null)
{
}
else
/* put the newsuperiorId and a terminating 0 */
if (newSuperiorId != null)
{
}
else
/* put the deleteoldrdn flag */
if (deleteOldRdn)
else
return resultByteArray;
}
}