AttrHistoricalMultiple.java revision f61444ce38af62d66efd549a90c9a958bde95691
0N/A * The contents of this file are subject to the terms of the 0N/A * Common Development and Distribution License, Version 1.0 only 0N/A * (the "License"). You may not use this file except in compliance 0N/A * See the License for the specific language governing permissions 0N/A * and limitations under the License. 0N/A * When distributing Covered Code, include this CDDL HEADER in each 0N/A * If applicable, add the following below this CDDL HEADER, with the 0N/A * fields enclosed by brackets "[]" replaced with your own identifying 1472N/A * Portions Copyright [yyyy] [name of copyright owner] 0N/A * Copyright 2006-2010 Sun Microsystems, Inc. 1879N/A * Portions Copyright 2011-2015 ForgeRock AS 1585N/A * This class is used to store historical information for multiple valued 0N/A * One object of this type is created for each attribute that was changed in 0N/A * It allows to record the last time a given value was added, the last 113N/A * time a given value was deleted and the last time the whole attribute was 113N/A /** Last time when the attribute was deleted. */ 0N/A /** Last time the attribute was modified. */ 0N/A * Change history for the values of this attribute. We are using a 113N/A * LinkedHashMap here because we want: 0N/A * attribute value => Use a Map</li> 0N/A * <li>Ordering changes according to the CSN of each changes => Use a 0N/A * LinkedHashMap</li> 0N/A * Create a new object from the provided information. 0N/A * @param deleteTime the last time this attribute was deleted 0N/A * @param updateTime the last time this attribute was updated 0N/A * @param valuesHist the new attribute values when updated. 0N/A * Returns the last time when the attribute was updated. 0N/A * @return the last time when the attribute was updated 0N/A * Duplicate an object. CSNs are duplicated by references. 0N/A * Method only called in tests 0N/A * @return the duplicated object. 0N/A * Delete all historical information that is older than the provided CSN for 0N/A * this attribute type. 0N/A * Add the delete attribute state information 0N/A * @param csn time when the delete was done 0N/A // iterate through the values in the valuesInfo and suppress all the values 0N/A // that have not been added after the date of this delete. 679N/A * Update the historical of this attribute after deleting a set of values. 0N/A * the attribute containing the set of values that were deleted 0N/A * time when the delete was done 0N/A * Update the historical of this attribute after a delete value. 0N/A * @param val value that was deleted 0N/A * @param csn time when the delete was done 1145N/A * Update the historical information when values are added. 1145N/A * the attribute containing the set of added values 1145N/A * time when the add is done 1630N/A * Update the historical information when a value is added. 1630N/A * time when the value was added 0N/A // We are replaying an operation that was already done 0N/A // on another master server and this operation has a potential 0N/A // conflict with some more recent operations on this same entry 0N/A // we need to take the more complex path to solve them 0N/A // the attribute was modified after this change -> conflict 2941N/A /* this delete is already obsoleted by a more recent delete 113N/A /* this replace is already obsoleted by a more recent delete 0N/A /* save the values that are added by the replace operation 113N/A * first process the replace as a delete operation -> this generate 113N/A * a list of values that should be kept 0N/A * then process the addedValues as if they were coming from a add 113N/A * -> this generate the list of values that needs to be added 113N/A * concatenate the 2 generated lists into a replace 0N/A return false;
// the attribute was not modified more recently 0N/A * The operation is either a non-conflicting operation or a local operation 0N/A * so there is no need to check the historical information for conflicts. 695N/A * If this is a local operation, then this code is run after 695N/A * If this is a non-conflicting replicated operation, this code is run 0N/A * during the handleConflictResolution(). 0N/A /* TODO : can we replace specific attribute values ????? */ 0N/A /* FIXME : we should update CSN */ 0N/A * Process a delete attribute values that is conflicting with a previous 0N/A * @param csn The CSN of the currently processed change 0N/A * @param m the modification that is being processed 0N/A * @param modifiedEntry the entry that is modified (before current mod) 0N/A * @return false if there is nothing to do 0N/A * We are processing a conflicting DELETE modification 0N/A * This code is written on the assumption that conflict are 0N/A * rare. We therefore don't care much about the performance 0N/A * However since it is rarely executed this code needs to be 0N/A * as simple as possible to make sure that all paths are tested. 0N/A * In this case the most simple seem to change the DELETE 0N/A * in a REPLACE modification that keeps all values 0N/A * more recent that the DELETE. 0N/A * we are therefore going to change m into a REPLACE that will keep 0N/A * all the values that have been updated after the DELETE time 0N/A * If a value is present in the entry without any state information 0N/A * it must be removed so we simply ignore them 0N/A * We are processing a DELETE attribute modification 0N/A * this value has been updated after this delete, therefore 0N/A * this value must be kept 679N/A * this value is going to be deleted, remove it from historical 679N/A * information unless it is a Deleted attribute value that is 0N/A * more recent than this DELETE 0N/A // we are processing DELETE of some attribute values /* update historical information */ /* this value already exist in the historical information */ // This value was added earlier in the same operation // we need to keep the delete. /* if the attribute value is not to be deleted * or if attribute value is not present suppress it from the * MOD to make sure the delete is going to succeed // this value was already deleted before and therefore // this should not be replayed. // This was the last values in the set of values to be deleted. // this MOD must therefore be skipped. * Process a add attribute values that is conflicting with a previous * @param csn the historical info associated to the entry * @param m the modification that is being processed * @param modsIterator iterator on the list of modification * if historicalattributedelete is newer forget this mod else find * attr value if does not exist add historicalvalueadded timestamp * add real value in entry else if timestamp older and already was * historicalvalueadded update historicalvalueadded else if * timestamp older and was historicalvaluedeleted change * historicalvaluedeleted into historicalvalueadded add value in /* A delete has been done more recently than this add /* this value does not exist yet * add it in the historical information * let the operation process normally /* if the value is already present * check if the updateTime must be updated * in all cases suppress this value from the value list * as it is already present in the entry /* this value is marked as a deleted value * check if this mod is more recent the this delete /* this add is more recent, * remove the old delete historical information * and add our more recent one * let the operation process /* the delete that is present in the historical information * is more recent so it must win, * remove this value from the list of values to add * don't update the historical information