public synchronized void destroySubcontextWithChilds(String name) throws NamingException { NamingEnumeration<NameClassPair> list = ctx.list(name); try { while (list.hasMore()) destroySubcontextWithChilds(list.next().getNameInNamespace()); } finally { LdapUtils.safeClose(list); } ctx.destroySubcontext(name); }
@Override public synchronized boolean purgeConfiguration() throws ConfigurationException { if (!configurationExists()) return false; try { destroySubcontextWithChilds(configurationDN); LOG.info("Purge DICOM Configuration at {}", configurationDN); clearConfigurationDN(); } catch (NamingException e) { throw new ConfigurationException(e); } return true; }
@Override public synchronized boolean purgeConfiguration() throws ConfigurationException { if (!configurationExists()) return false; try { destroySubcontextWithChilds(configurationDN); LOG.info("Purge DICOM Configuration at {}", configurationDN); clearConfigurationDN(); } catch (NamingException e) { throw new ConfigurationException(e); } return true; }
public synchronized void destroySubcontextWithChilds(String name) throws NamingException { NamingEnumeration<NameClassPair> list = ctx.list(name); try { while (list.hasMore()) destroySubcontextWithChilds(list.next().getNameInNamespace()); } finally { LdapUtils.safeClose(list); } ctx.destroySubcontext(name); }
private void removeDeviceWithDN(String deviceDN, boolean unregister) throws ConfigurationException { try { ArrayList<String> destroyDNs = new ArrayList<>(); if (unregister) markForUnregister(deviceDN, destroyDNs); destroySubcontextWithChilds(deviceDN); unregister(destroyDNs); } catch (NameNotFoundException e) { throw new ConfigurationNotFoundException(e); } catch (NamingException e) { throw new ConfigurationException(e); } }
private void removeDeviceWithDN(String deviceDN, boolean unregister) throws ConfigurationException { try { ArrayList<String> destroyDNs = new ArrayList<>(); if (unregister) markForUnregister(deviceDN, destroyDNs); destroySubcontextWithChilds(deviceDN); unregister(destroyDNs); } catch (NameNotFoundException e) { throw new ConfigurationNotFoundException(e); } catch (NamingException e) { throw new ConfigurationException(e); } }
private void mergeWebApps(ConfigurationChanges diffs, Device prevDev, Device dev, String deviceDN) throws NamingException { Collection<String> names = dev.getWebApplicationNames(); for (String aet : prevDev.getWebApplicationNames()) { if (!names.contains(aet)) { String aetDN = aetDN(aet, deviceDN); destroySubcontextWithChilds(aetDN); ConfigurationChanges.addModifiedObject(diffs, aetDN, ConfigurationChanges.ChangeType.D); } } Collection<String> prevNames = prevDev.getWebApplicationNames(); for (WebApplication webapp : dev.getWebApplications()) { String name = webapp.getApplicationName(); if (!prevNames.contains(name)) { store(diffs, webapp, deviceDN); } else merge(diffs, prevDev.getWebApplication(name), webapp, deviceDN); } }
private void mergeAEs(ConfigurationChanges diffs, Device prevDev, Device dev, String deviceDN, boolean preserveVendorData) throws NamingException { Collection<String> aets = dev.getApplicationAETitles(); for (String aet : prevDev.getApplicationAETitles()) { if (!aets.contains(aet)) { String aetDN = aetDN(aet, deviceDN); destroySubcontextWithChilds(aetDN); ConfigurationChanges.addModifiedObject(diffs, aetDN, ConfigurationChanges.ChangeType.D); } } Collection<String> prevAETs = prevDev.getApplicationAETitles(); for (ApplicationEntity ae : dev.getApplicationEntities()) { String aet = ae.getAETitle(); if (!prevAETs.contains(aet)) { store(diffs, ae, deviceDN); } else merge(diffs, prevDev.getApplicationEntity(aet), ae, deviceDN, preserveVendorData); } }
private void mergeWebApps(ConfigurationChanges diffs, Device prevDev, Device dev, String deviceDN) throws NamingException { Collection<String> names = dev.getWebApplicationNames(); for (String aet : prevDev.getWebApplicationNames()) { if (!names.contains(aet)) { String aetDN = aetDN(aet, deviceDN); destroySubcontextWithChilds(aetDN); ConfigurationChanges.addModifiedObject(diffs, aetDN, ConfigurationChanges.ChangeType.D); } } Collection<String> prevNames = prevDev.getWebApplicationNames(); for (WebApplication webapp : dev.getWebApplications()) { String name = webapp.getApplicationName(); if (!prevNames.contains(name)) { store(diffs, webapp, deviceDN); } else merge(diffs, prevDev.getWebApplication(name), webapp, deviceDN); } }
private void mergeAEs(ConfigurationChanges diffs, Device prevDev, Device dev, String deviceDN, boolean preserveVendorData) throws NamingException { Collection<String> aets = dev.getApplicationAETitles(); for (String aet : prevDev.getApplicationAETitles()) { if (!aets.contains(aet)) { String aetDN = aetDN(aet, deviceDN); destroySubcontextWithChilds(aetDN); ConfigurationChanges.addModifiedObject(diffs, aetDN, ConfigurationChanges.ChangeType.D); } } Collection<String> prevAETs = prevDev.getApplicationAETitles(); for (ApplicationEntity ae : dev.getApplicationEntities()) { String aet = ae.getAETitle(); if (!prevAETs.contains(aet)) { store(diffs, ae, deviceDN); } else merge(diffs, prevDev.getApplicationEntity(aet), ae, deviceDN, preserveVendorData); } }
@Override protected void mergeChilds(ConfigurationChanges diffs, Device prev, Device device, String deviceDN) throws NamingException { AuditRecordRepository prevARR = prev.getDeviceExtension(AuditRecordRepository.class); AuditRecordRepository arr = device.getDeviceExtension(AuditRecordRepository.class); if (arr == null && prevARR == null) return; String dn = CN_AUDIT_RECORD_REPOSITORY + deviceDN; if (arr == null) { config.destroySubcontextWithChilds(dn); ConfigurationChanges.addModifiedObject(diffs, dn, ConfigurationChanges.ChangeType.D); } else if (prevARR == null) { store(diffs, deviceDN, arr); } else { ConfigurationChanges.ModifiedObject ldapObj = ConfigurationChanges.addModifiedObject(diffs, dn, ConfigurationChanges.ChangeType.U); config.modifyAttributes(dn, storeDiffs(ldapObj, prevARR, arr, deviceDN, new ArrayList<ModificationItem>())); ConfigurationChanges.removeLastIfEmpty(diffs, ldapObj); } }
@Override protected void mergeChilds(ConfigurationChanges diffs, Device prev, Device device, String deviceDN) throws NamingException { AuditRecordRepository prevARR = prev.getDeviceExtension(AuditRecordRepository.class); AuditRecordRepository arr = device.getDeviceExtension(AuditRecordRepository.class); if (arr == null && prevARR == null) return; String dn = CN_AUDIT_RECORD_REPOSITORY + deviceDN; if (arr == null) { config.destroySubcontextWithChilds(dn); ConfigurationChanges.addModifiedObject(diffs, dn, ConfigurationChanges.ChangeType.D); } else if (prevARR == null) { store(diffs, deviceDN, arr); } else { ConfigurationChanges.ModifiedObject ldapObj = ConfigurationChanges.addModifiedObject(diffs, dn, ConfigurationChanges.ChangeType.U); config.modifyAttributes(dn, storeDiffs(ldapObj, prevARR, arr, deviceDN, new ArrayList<ModificationItem>())); ConfigurationChanges.removeLastIfEmpty(diffs, ldapObj); } }
if (rollback) { try { destroySubcontextWithChilds(deviceDN); } catch (NamingException e) { LOG.warn("Rollback failed:", e);
@Override protected void mergeChilds(ConfigurationChanges diffs, Device prev, Device device, String deviceDN) throws NamingException { ImageReaderExtension prevExt = prev.getDeviceExtension(ImageReaderExtension.class); ImageReaderExtension ext = device.getDeviceExtension(ImageReaderExtension.class); if (ext == null && prevExt == null) return; String dn = CN_IMAGE_READER_FACTORY + deviceDN; if (ext == null) { config.destroySubcontextWithChilds(dn); ConfigurationChanges.addModifiedObject(diffs, dn, ConfigurationChanges.ChangeType.D); } else if (prevExt == null) { store(diffs, deviceDN, ext.getImageReaderFactory()); } else { merge(diffs, prevExt.getImageReaderFactory(), ext.getImageReaderFactory(), dn); } }
@Override protected void mergeChilds(ConfigurationChanges diffs, Device prev, Device device, String deviceDN) throws NamingException { ImageWriterExtension prevExt = prev.getDeviceExtension(ImageWriterExtension.class); ImageWriterExtension ext = device.getDeviceExtension(ImageWriterExtension.class); if (ext == null && prevExt == null) return; String dn = CN_IMAGE_WRITER_FACTORY + deviceDN; if (ext == null) { config.destroySubcontextWithChilds(dn); ConfigurationChanges.addModifiedObject(diffs, dn, ConfigurationChanges.ChangeType.D); } else if (prevExt == null) { store(diffs, deviceDN, ext.getImageWriterFactory()); } else { merge(diffs, prevExt.getImageWriterFactory(), ext.getImageWriterFactory(), dn); } }
if (rollback) { try { destroySubcontextWithChilds(deviceDN); } catch (NamingException e) { LOG.warn("Rollback failed:", e);
@Override protected void mergeChilds(ConfigurationChanges diffs, Device prev, Device device, String deviceDN) throws NamingException { AuditLoggerDeviceExtension prevAuditLoggerExt = prev.getDeviceExtension(AuditLoggerDeviceExtension.class); AuditLoggerDeviceExtension auditLoggerExt = device.getDeviceExtension(AuditLoggerDeviceExtension.class); if (prevAuditLoggerExt != null) for (String appName : prevAuditLoggerExt.getAuditLoggerNames()) { if (auditLoggerExt == null || !auditLoggerExt.containsAuditLogger(appName)) { String dn = auditLoggerDN(appName, deviceDN); config.destroySubcontextWithChilds(dn); ConfigurationChanges.addModifiedObject(diffs, dn, ConfigurationChanges.ChangeType.D); } } if (auditLoggerExt == null) return; for (AuditLogger logger : auditLoggerExt.getAuditLoggers()) { String appName = logger.getCommonName(); if (prevAuditLoggerExt == null || !prevAuditLoggerExt.containsAuditLogger(appName)) { store(diffs, deviceDN, logger); } else merge(diffs, prevAuditLoggerExt.getAuditLogger(appName), logger, deviceDN); } }
@Override protected void mergeChilds(ConfigurationChanges diffs, Device prev, Device device, String deviceDN) throws NamingException { AuditLoggerDeviceExtension prevAuditLoggerExt = prev.getDeviceExtension(AuditLoggerDeviceExtension.class); AuditLoggerDeviceExtension auditLoggerExt = device.getDeviceExtension(AuditLoggerDeviceExtension.class); if (prevAuditLoggerExt != null) for (String appName : prevAuditLoggerExt.getAuditLoggerNames()) { if (auditLoggerExt == null || !auditLoggerExt.containsAuditLogger(appName)) { String dn = auditLoggerDN(appName, deviceDN); config.destroySubcontextWithChilds(dn); ConfigurationChanges.addModifiedObject(diffs, dn, ConfigurationChanges.ChangeType.D); } } if (auditLoggerExt == null) return; for (AuditLogger logger : auditLoggerExt.getAuditLoggers()) { String appName = logger.getCommonName(); if (prevAuditLoggerExt == null || !prevAuditLoggerExt.containsAuditLogger(appName)) { store(diffs, deviceDN, logger); } else merge(diffs, prevAuditLoggerExt.getAuditLogger(appName), logger, deviceDN); } }
@Override protected void mergeChilds(ConfigurationChanges diffs, Device prev, Device device, String deviceDN) throws NamingException { HL7DeviceExtension prevHL7Ext = prev.getDeviceExtension(HL7DeviceExtension.class); HL7DeviceExtension hl7Ext = device.getDeviceExtension(HL7DeviceExtension.class); if (prevHL7Ext != null) for (String appName : prevHL7Ext.getHL7ApplicationNames()) { if (hl7Ext == null || !hl7Ext.containsHL7Application(appName)) { config.destroySubcontextWithChilds(hl7appDN(appName, deviceDN)); ConfigurationChanges.addModifiedObject(diffs, hl7appDN(appName, deviceDN), ConfigurationChanges.ChangeType.D); } } if (hl7Ext == null) return; for (HL7Application hl7app : hl7Ext.getHL7Applications()) { String appName = hl7app.getApplicationName(); if (prevHL7Ext == null || !prevHL7Ext.containsHL7Application(appName)) { store(diffs, hl7app, deviceDN); } else merge(diffs, prevHL7Ext.getHL7Application(appName), hl7app, deviceDN); } }