| | |
| | | public static final String HISTORICAL = "ds-synch-historical"; |
| | | |
| | | /** |
| | | * The AttributeType associated to the attribute used to store |
| | | * hitorical information. |
| | | * The name of the entryuuid attribute. |
| | | */ |
| | | public static final AttributeType historicalAttrType = |
| | | DirectoryServer.getSchema().getAttributeType(HISTORICALATTRIBUTENAME); |
| | | |
| | | static final String ENTRYUIDNAME = "entryuuid"; |
| | | static final AttributeType entryuuidAttrType = |
| | | DirectoryServer.getSchema().getAttributeType(ENTRYUIDNAME); |
| | | |
| | | |
| | | /* |
| | |
| | | Modification mod; |
| | | mod = new Modification(ModificationType.REPLACE, attr); |
| | | mods.add(mod); |
| | | modifiedEntry.removeAttribute(historicalAttrType); |
| | | modifiedEntry.removeAttribute(attr.getAttributeType()); |
| | | modifiedEntry.addAttribute(attr, null); |
| | | } |
| | | |
| | |
| | | private AttributeInfo getAttrInfo(Modification mod) |
| | | { |
| | | Attribute modAttr = mod.getAttribute(); |
| | | if (modAttr.getAttributeType().equals(Historical.historicalAttrType)) |
| | | if (isHistoricalAttribute(modAttr)) |
| | | { |
| | | // Don't keep historical information for the attribute that is |
| | | // used to store the historical information. |
| | |
| | | */ |
| | | public Attribute encode() |
| | | { |
| | | AttributeType historicalAttrType = |
| | | DirectoryServer.getSchema().getAttributeType(HISTORICALATTRIBUTENAME); |
| | | LinkedHashSet<AttributeValue> hist = new LinkedHashSet<AttributeValue>(); |
| | | |
| | | for (Map.Entry<AttributeType, AttrInfoWithOptions> entryWithOptions : |
| | |
| | | */ |
| | | public static Historical load(Entry entry) |
| | | { |
| | | List<Attribute> hist = entry.getAttribute(historicalAttrType); |
| | | List<Attribute> hist = getHistoricalAttr(entry); |
| | | Historical histObj = new Historical(); |
| | | AttributeType lastAttrType = null; |
| | | Set<String> lastOptions = new HashSet<String>(); |
| | |
| | | { |
| | | TreeMap<ChangeNumber, FakeOperation> operations = |
| | | new TreeMap<ChangeNumber, FakeOperation>(); |
| | | List<Attribute> attrs = entry.getOperationalAttribute(historicalAttrType); |
| | | List<Attribute> attrs = getHistoricalAttr(entry); |
| | | if (attrs != null) |
| | | { |
| | | for (Attribute attr : attrs) |
| | |
| | | } |
| | | |
| | | /** |
| | | * Get the Attribute used to store the historical information from |
| | | * the given Entry. |
| | | * |
| | | * @param entry The entry containing the historical information. |
| | | * |
| | | * @return The Attribute used to store the historical information. |
| | | */ |
| | | public static List<Attribute> getHistoricalAttr(Entry entry) |
| | | { |
| | | return entry.getAttribute(HISTORICALATTRIBUTENAME); |
| | | } |
| | | |
| | | /** |
| | | * Get the entry unique Id in String form. |
| | | * |
| | | * @param entry The entry for which the unique id should be returned. |
| | |
| | | public static String getEntryUuid(Entry entry) |
| | | { |
| | | String uuidString = null; |
| | | AttributeType entryuuidAttrType = |
| | | DirectoryServer.getSchema().getAttributeType(ENTRYUIDNAME); |
| | | List<Attribute> uuidAttrs = |
| | | entry.getOperationalAttribute(entryuuidAttrType); |
| | | if (uuidAttrs != null) |
| | |
| | | { |
| | | String uuidString = null; |
| | | Map<AttributeType, List<Attribute>> attrs = op.getOperationalAttributes(); |
| | | AttributeType entryuuidAttrType = |
| | | DirectoryServer.getSchema().getAttributeType(ENTRYUIDNAME); |
| | | List<Attribute> uuidAttrs = attrs.get(entryuuidAttrType); |
| | | |
| | | if (uuidAttrs != null) |
| | |
| | | } |
| | | return uuidString; |
| | | } |
| | | |
| | | /** |
| | | * Check if a given attribute is an attribute used to store historical |
| | | * information. |
| | | * |
| | | * @param attr The attribute that needs to be checked. |
| | | * |
| | | * @return a boolean indicating if the given attribute is |
| | | * used to store historical information. |
| | | */ |
| | | public static boolean isHistoricalAttribute(Attribute attr) |
| | | { |
| | | AttributeType attrType = attr.getAttributeType(); |
| | | return attrType.getNameOrOID().equals(Historical.HISTORICALATTRIBUTENAME); |
| | | } |
| | | } |
| | | |