| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011 ForgeRock AS |
| | | * Portions Copyright 2011-2012 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | /** |
| | | * Name of the attribute used to store historical information. |
| | | */ |
| | | public static final String HISTORICALATTRIBUTENAME = "ds-sync-hist"; |
| | | public static final String HISTORICAL_ATTRIBUTE_NAME = "ds-sync-hist"; |
| | | |
| | | /** |
| | | * Name used to store attachment of historical information in the |
| | |
| | | /** |
| | | * Name of the entryuuid attribute. |
| | | */ |
| | | public static final String ENTRYUIDNAME = "entryuuid"; |
| | | public static final String ENTRYUUID_ATTRIBUTE_NAME = "entryuuid"; |
| | | |
| | | /* The delay to purge the historical informations |
| | | * This delay indicates the time the domain keeps the historical |
| | |
| | | PreOperationAddOperation addOperation) |
| | | { |
| | | AttributeType historicalAttrType = |
| | | DirectoryServer.getSchema().getAttributeType(HISTORICALATTRIBUTENAME); |
| | | DirectoryServer.getSchema().getAttributeType(HISTORICAL_ATTRIBUTE_NAME); |
| | | |
| | | // Get the changeNumber from the attached synchronization context |
| | | // Create the attribute (encoded) |
| | |
| | | private static AttributeValue encodeAddHistorical(ChangeNumber cn) |
| | | { |
| | | AttributeType historicalAttrType = |
| | | DirectoryServer.getSchema().getAttributeType(HISTORICALATTRIBUTENAME); |
| | | DirectoryServer.getSchema().getAttributeType(HISTORICAL_ATTRIBUTE_NAME); |
| | | |
| | | String strValue = "dn:" + cn.toString() +":add"; |
| | | AttributeValue val = AttributeValues.create(historicalAttrType, strValue); |
| | |
| | | private static AttributeValue encodeMODDNHistorical(ChangeNumber cn) |
| | | { |
| | | AttributeType historicalAttrType = |
| | | DirectoryServer.getSchema().getAttributeType(HISTORICALATTRIBUTENAME); |
| | | DirectoryServer.getSchema().getAttributeType(HISTORICAL_ATTRIBUTE_NAME); |
| | | |
| | | String strValue = "dn:" + cn.toString() +":moddn"; |
| | | AttributeValue val = AttributeValues.create(historicalAttrType, strValue); |
| | |
| | | purgeDate = TimeThread.getTime() - purgeDelayInMillisec; |
| | | |
| | | AttributeType historicalAttrType = |
| | | DirectoryServer.getSchema().getAttributeType(HISTORICALATTRIBUTENAME); |
| | | DirectoryServer.getSchema().getAttributeType(HISTORICAL_ATTRIBUTE_NAME); |
| | | AttributeBuilder builder = new AttributeBuilder(historicalAttrType); |
| | | |
| | | for (Map.Entry<AttributeType, AttrHistoricalWithOptions> entryWithOptions : |
| | |
| | | } |
| | | else |
| | | { |
| | | String uuidString = getEntryUuid(entry); |
| | | String uuidString = getEntryUUID(entry); |
| | | if (uuidString != null) |
| | | { |
| | | modifyFakeOperation = new FakeModifyOperation(entry.getDN(), |
| | |
| | | */ |
| | | public static List<Attribute> getHistoricalAttr(Entry entry) |
| | | { |
| | | return entry.getAttribute(HISTORICALATTRIBUTENAME); |
| | | return entry.getAttribute(HISTORICAL_ATTRIBUTE_NAME); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return The Unique Id of the entry if it has one. null, otherwise. |
| | | */ |
| | | public static String getEntryUuid(Entry entry) |
| | | public static String getEntryUUID(Entry entry) |
| | | { |
| | | String uuidString = null; |
| | | AttributeType entryuuidAttrType = |
| | | DirectoryServer.getSchema().getAttributeType(ENTRYUIDNAME); |
| | | DirectoryServer.getSchema().getAttributeType(ENTRYUUID_ATTRIBUTE_NAME); |
| | | List<Attribute> uuidAttrs = |
| | | entry.getOperationalAttribute(entryuuidAttrType); |
| | | if (uuidAttrs != null) |
| | |
| | | * @param op The operation |
| | | * @return The Entry Unique Id String form. |
| | | */ |
| | | public static String getEntryUuid(PreOperationAddOperation op) |
| | | public static String getEntryUUID(PreOperationAddOperation op) |
| | | { |
| | | String uuidString = null; |
| | | Map<AttributeType, List<Attribute>> attrs = op.getOperationalAttributes(); |
| | | AttributeType entryuuidAttrType = |
| | | DirectoryServer.getSchema().getAttributeType(ENTRYUIDNAME); |
| | | DirectoryServer.getSchema().getAttributeType(ENTRYUUID_ATTRIBUTE_NAME); |
| | | List<Attribute> uuidAttrs = attrs.get(entryuuidAttrType); |
| | | |
| | | if (uuidAttrs != null) |
| | |
| | | { |
| | | AttributeType attrType = attr.getAttributeType(); |
| | | return |
| | | attrType.getNameOrOID().equals(EntryHistorical.HISTORICALATTRIBUTENAME); |
| | | attrType.getNameOrOID().equals(EntryHistorical.HISTORICAL_ATTRIBUTE_NAME); |
| | | } |
| | | |
| | | /** |