ModifyMsg.java revision 99faa045b6241c1d2843cce1b7a9d9c97055beae
/*
* 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
*
*
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
/**
* Message used to send Modify information.
*/
public class ModifyMsg extends UpdateMessage
{
private static final long serialVersionUID = -4905520652801395185L;
private byte[] encodedMods = null;
private byte[] encodedMsg = null;
/**
* Creates a new Modify message from a ModifyOperation.
*
* @param op The operation to use for building the message
*/
{
}
/**
* Creates a new Modify message using the provided information.
*
* @param changeNumber The ChangeNumber for the operation.
* @param dn The baseDN of the operation.
* @param mods The mod of the operation.
* @param entryuuid The unique id of the entry on which the modification
* needs to apply.
*/
{
dn.toNormalizedString());
}
/**
* Creates a new Modify message from a byte[].
*
* @param in The byte[] from which the operation must be read.
* @throws DataFormatException If the input byte[] is not a valid modifyMsg
* @throws UnsupportedEncodingException If UTF8 is not supported by the JVM.
*/
{
super(in);
encodedMsg = in;
}
/**
* Get the byte array representation of this Message.
*
* @return The byte array representation of this Message.
*/
public byte[] getBytes()
{
if (encodedMsg == null)
{
try
{
encode();
} catch (UnsupportedEncodingException e)
{
// should never happens : TODO : log some error
return null;
}
}
return encodedMsg;
}
/**
* {@inheritDoc}
*/
{
if (encodedMods == null)
{
decode();
}
return mod;
}
/**
* Encode the Msg information into a byte array.
*
* @throws UnsupportedEncodingException If utf8 is not suported.
*/
private void encode() throws UnsupportedEncodingException
{
/* encode the header in a byte[] large enough to also contain the mods */
/* add the mods */
}
/**
* Decode the encodedMsg into mods and dn.
*
* @throws DataFormatException when the encodedMsg is no a valid modify.
*/
private void decode() throws DataFormatException
{
/* Read the mods : all the remaining bytes but the terminating 0 */
int i =0;
{
}
}
/**
* Encode an ArrayList of Modification into a byte[] suitable
* for storage in a database or send on the network.
*
* @param mods the ArrayList of Modification to be encoded.
*/
{
{
{
{
// Attributes with a dsaOperation usage should not be synchronized.
// skip them.
continue;
}
}
{
}
}
}
/**
* {@inheritDoc}
*/
{
}
}