@Override
 protected void loadFrom(Device device, Attributes attrs)
     throws NamingException, CertificateException {
   super.loadFrom(device, attrs);
   if (!(device instanceof ArchiveDevice)) return;
   ArchiveDevice arcdev = (ArchiveDevice) device;
   arcdev.setFuzzyAlgorithmClass(stringValue(attrs.get("dcmFuzzyAlgorithmClass")));
   arcdev.setConfigurationStaleTimeout(intValue(attrs.get("dcmConfigurationStaleTimeout"), 0));
 }
 @Override
 protected Attributes storeTo(Device device, Attributes attrs) {
   super.storeTo(device, attrs);
   if (!(device instanceof ArchiveDevice)) return attrs;
   ArchiveDevice arcDev = (ArchiveDevice) device;
   storeNotNull(attrs, "dcmFuzzyAlgorithmClass", arcDev.getFuzzyAlgorithmClass());
   storeNotDef(attrs, "dcmConfigurationStaleTimeout", arcDev.getConfigurationStaleTimeout(), 0);
   return attrs;
 }
 @Override
 protected void storeChilds(String deviceDN, Device device) throws NamingException {
   super.storeChilds(deviceDN, device);
   if (!(device instanceof ArchiveDevice)) return;
   ArchiveDevice arcDev = (ArchiveDevice) device;
   for (Entity entity : Entity.values())
     createSubcontext(
         dnOf("dcmEntity", entity.toString(), deviceDN),
         storeTo(arcDev.getAttributeFilter(entity), entity, new BasicAttributes(true)));
 }
  @Override
  protected void mergeChilds(Device prev, Device device, String deviceDN) throws NamingException {
    super.mergeChilds(prev, device, deviceDN);
    if (!(prev instanceof ArchiveDevice && device instanceof ArchiveDevice)) return;

    ArchiveDevice aa = (ArchiveDevice) prev;
    ArchiveDevice bb = (ArchiveDevice) device;
    for (Entity entity : Entity.values())
      modifyAttributes(
          dnOf("dcmEntity", entity.toString(), deviceDN),
          storeDiffs(
              aa.getAttributeFilter(entity),
              bb.getAttributeFilter(entity),
              new ArrayList<ModificationItem>()));
  }
 private void loadAttributeFilters(ArchiveDevice device, String deviceDN) throws NamingException {
   NamingEnumeration<SearchResult> ne = search(deviceDN, "(objectclass=dcmAttributeFilter)");
   try {
     while (ne.hasMore()) {
       SearchResult sr = ne.next();
       Attributes attrs = sr.getAttributes();
       AttributeFilter filter = new AttributeFilter(tags(attrs.get("dcmTag")));
       filter.setCustomAttribute1(valueSelector(attrs.get("dcmCustomAttribute1")));
       filter.setCustomAttribute2(valueSelector(attrs.get("dcmCustomAttribute2")));
       filter.setCustomAttribute3(valueSelector(attrs.get("dcmCustomAttribute3")));
       device.setAttributeFilter(Entity.valueOf(stringValue(attrs.get("dcmEntity"))), filter);
     }
   } finally {
     safeClose(ne);
   }
 }
  @Override
  protected List<ModificationItem> storeDiffs(Device a, Device b, List<ModificationItem> mods) {
    super.storeDiffs(a, b, mods);
    if (!(a instanceof ArchiveDevice && b instanceof ArchiveDevice)) return mods;

    ArchiveDevice aa = (ArchiveDevice) a;
    ArchiveDevice bb = (ArchiveDevice) b;
    storeDiff(
        mods, "dcmFuzzyAlgorithmClass", aa.getFuzzyAlgorithmClass(), bb.getFuzzyAlgorithmClass());
    storeDiff(
        mods,
        "dcmConfigurationStaleTimeout",
        aa.getConfigurationStaleTimeout(),
        bb.getConfigurationStaleTimeout(),
        0);
    return mods;
  }