private static Attributes storeTo(AttributeCoercion ac, BasicAttributes attrs) {
   attrs.put("objectclass", "dcmAttributeCoercion");
   storeNotNull(attrs, "dcmDIMSE", ac.getDimse());
   storeNotNull(attrs, "dicomTransferRole", ac.getRole());
   storeNotNull(attrs, "dicomAETitle", ac.getAETitle());
   storeNotNull(attrs, "dicomSOPClass", ac.getSopClass());
   storeNotNull(attrs, "labeledURI", ac.getURI());
   return attrs;
 }
 protected void merge(AttributeCoercions prevs, AttributeCoercions acs, String parentDN)
     throws NamingException {
   for (AttributeCoercion prev : prevs.getAll())
     if (acs.findEquals(prev.getSopClass(), prev.getDimse(), prev.getRole(), prev.getAETitle())
         == null) destroySubcontext(dnOf(prev, parentDN));
   for (AttributeCoercion ac : acs.getAll()) {
     String dn = dnOf(ac, parentDN);
     AttributeCoercion prev =
         prevs.findEquals(
             ac.getSopClass(), ac.getDimse(),
             ac.getRole(), ac.getAETitle());
     if (prev == null) createSubcontext(dn, storeTo(ac, new BasicAttributes(true)));
     else modifyAttributes(dn, storeDiffs(prev, ac, new ArrayList<ModificationItem>()));
   }
 }
 private static String dnOf(AttributeCoercion ac, String parentDN) {
   StringBuilder sb = new StringBuilder();
   sb.append("dcmDIMSE=").append(ac.getDimse());
   sb.append("+dicomTransferRole=").append(ac.getRole());
   if (ac.getAETitle() != null) sb.append("+dicomAETitle=").append(ac.getAETitle());
   if (ac.getSopClass() != null) sb.append("+dicomSOPClass=").append(ac.getSopClass());
   sb.append(',').append(parentDN);
   return sb.toString();
 }
 private List<ModificationItem> storeDiffs(
     AttributeCoercion prev, AttributeCoercion ac, ArrayList<ModificationItem> mods) {
   storeDiff(mods, "labeledURI", prev.getURI(), ac.getURI());
   return mods;
 }