private void setProtocol(Protocol protocol) { conn.setProtocol(protocol); arr.addConnection(conn); }
private List<ModificationItem> storeDiffs(ConfigurationChanges.ModifiedObject ldapObj, AuditRecordRepository a, AuditRecordRepository b, String deviceDN, ArrayList<ModificationItem> mods) { LdapUtils.storeDiff(ldapObj, mods, "dicomNetworkConnectionReference", a.getConnections(), b.getConnections(), deviceDN); LdapUtils.storeDiffObject(ldapObj, mods, "dicomInstalled", a.getInstalled(), b.getInstalled(), null); return mods; }
private void reconfigure(AuditRecordRepository from) { setInstalled(from.installed); device.reconfigureConnections(conns, from.conns); }
private void loadFrom(AuditRecordRepository arr, JsonReader reader, List<Connection> conns) { while (reader.next() == JsonParser.Event.KEY_NAME) { switch (reader.getString()) { case "dicomInstalled": arr.setInstalled(reader.booleanValue()); break; case "dicomNetworkConnectionReference": for (String connRef : reader.stringArray()) arr.addConnection(conns.get(JsonReader.toConnectionIndex(connRef))); break; default: reader.skipUnknownProperty(); } } } }
@Override protected void loadChilds(Device device, String deviceDN) throws NamingException { Attributes attrs; try { attrs = config.getAttributes(CN_AUDIT_RECORD_REPOSITORY + deviceDN); } catch (NameNotFoundException e) { return; } AuditRecordRepository arr = new AuditRecordRepository(); loadFrom(arr, attrs); for (String connDN : LdapUtils.stringArray( attrs.get("dicomNetworkConnectionReference"))) arr.addConnection( LdapUtils.findConnection(connDN, deviceDN, device)); device.addDeviceExtension(arr); }
private synchronized ActiveConnection activeConnection() throws IncompatibleConnectionException { ActiveConnection activeConnection = this.activeConnection; if (activeConnection != null) return activeConnection; Device arrDev = this.arrDevice; if (arrDevice == null) throw new IllegalStateException("No AuditRecordRepositoryDevice initalized"); AuditRecordRepository arr = arrDev.getDeviceExtension(AuditRecordRepository.class); if (arr == null) throw new IllegalStateException("AuditRecordRepositoryDevice " + arrDevice.getDeviceName() + " does not provide Audit Record Repository"); for (Connection remoteConn : arr.getConnections()) if (remoteConn.isInstalled() && remoteConn.isServer()) for (Connection conn : conns) if (conn.isInstalled() && conn.isCompatible(remoteConn)) { return (this.activeConnection = conn.getProtocol().isTCP() ? new TCPConnection(conn, remoteConn) : new UDPConnection(conn, remoteConn)); } throw new IncompatibleConnectionException( "No compatible connection to AuditRecordRepository @ Device " + arr.getDevice().getDeviceName() + " available on AuditLogger @ Device " + device.getDeviceName()); }
@Override public boolean loadDeviceExtension(Device device, JsonReader reader, ConfigurationDelegate config) { if (!reader.getString().equals("dcmAuditRecordRepository")) return false; reader.next(); reader.expect(JsonParser.Event.START_OBJECT); AuditRecordRepository arr = new AuditRecordRepository(); loadFrom(arr, reader, device.listConnections()); device.addDeviceExtension(arr); reader.expect(JsonParser.Event.END_OBJECT); return true; }
private static void onMessage(AuditRecordRepository arr, byte[] data, int offset, int length, Connection conn, InetAddress from) { if (LOG.isDebugEnabled()) { LOG.debug(prompt(data, MSG_PROMPT_LEN)); } int xmlOffset = indexOfXML(data, offset, Math.min(MAX_MSG_PREFIX, length)); if (xmlOffset != -1) { int xmlLength = length - xmlOffset + offset; arr.onMessage(data, xmlOffset, xmlLength, conn, from); } else { LOG.warn("Ignore unexpected message from {}: {}", from, prompt(data, MAX_MSG_PREFIX)); } }
private void loadFrom(AuditRecordRepository arr, JsonReader reader, List<Connection> conns) { while (reader.next() == JsonParser.Event.KEY_NAME) { switch (reader.getString()) { case "dicomInstalled": arr.setInstalled(reader.booleanValue()); break; case "dicomNetworkConnectionReference": for (String connRef : reader.stringArray()) arr.addConnection(conns.get(JsonReader.toConnectionIndex(connRef))); break; default: reader.skipUnknownProperty(); } } } }
@Override protected void loadChilds(Device device, String deviceDN) throws NamingException { Attributes attrs; try { attrs = config.getAttributes(CN_AUDIT_RECORD_REPOSITORY + deviceDN); } catch (NameNotFoundException e) { return; } AuditRecordRepository arr = new AuditRecordRepository(); loadFrom(arr, attrs); for (String connDN : LdapUtils.stringArray( attrs.get("dicomNetworkConnectionReference"))) arr.addConnection( LdapUtils.findConnection(connDN, deviceDN, device)); device.addDeviceExtension(arr); }
private synchronized ActiveConnection activeConnection() throws IncompatibleConnectionException { ActiveConnection activeConnection = this.activeConnection; if (activeConnection != null) return activeConnection; Device arrDev = this.arrDevice; if (arrDevice == null) throw new IllegalStateException("No AuditRecordRepositoryDevice initalized"); AuditRecordRepository arr = arrDev.getDeviceExtension(AuditRecordRepository.class); if (arr == null) throw new IllegalStateException("AuditRecordRepositoryDevice " + arrDevice.getDeviceName() + " does not provide Audit Record Repository"); for (Connection remoteConn : arr.getConnections()) if (remoteConn.isInstalled() && remoteConn.isServer()) for (Connection conn : conns) if (conn.isInstalled() && conn.isCompatible(remoteConn)) { return (this.activeConnection = conn.getProtocol().isTCP() ? new TCPConnection(conn, remoteConn) : new UDPConnection(conn, remoteConn)); } throw new IncompatibleConnectionException( "No compatible connection to AuditRecordRepository @ Device " + arr.getDevice().getDeviceName() + " available on AuditLogger @ Device " + device.getDeviceName()); }
@Override public boolean loadDeviceExtension(Device device, JsonReader reader, ConfigurationDelegate config) { if (!reader.getString().equals("dcmAuditRecordRepository")) return false; reader.next(); reader.expect(JsonParser.Event.START_OBJECT); AuditRecordRepository arr = new AuditRecordRepository(); loadFrom(arr, reader, device.listConnections()); device.addDeviceExtension(arr); reader.expect(JsonParser.Event.END_OBJECT); return true; }
private static void onMessage(AuditRecordRepository arr, byte[] data, int offset, int length, Connection conn, InetAddress from) { if (LOG.isDebugEnabled()) { LOG.debug(prompt(data, MSG_PROMPT_LEN)); } int xmlOffset = indexOfXML(data, offset, Math.min(MAX_MSG_PREFIX, length)); if (xmlOffset != -1) { int xmlLength = length - xmlOffset + offset; arr.onMessage(data, xmlOffset, xmlLength, conn, from); } else { LOG.warn("Ignore unexpected message from {}: {}", from, prompt(data, MAX_MSG_PREFIX)); } }
private List<ModificationItem> storeDiffs(ConfigurationChanges.ModifiedObject ldapObj, AuditRecordRepository a, AuditRecordRepository b, String deviceDN, ArrayList<ModificationItem> mods) { LdapUtils.storeDiff(ldapObj, mods, "dicomNetworkConnectionReference", a.getConnections(), b.getConnections(), deviceDN); LdapUtils.storeDiffObject(ldapObj, mods, "dicomInstalled", a.getInstalled(), b.getInstalled(), null); return mods; }
private static void configure(Syslogd main, CommandLine cl) throws Exception, MalformedURLException, ParseException, IOException { if (!cl.hasOption("ignore")) main.setStorageDirectory( cl.getOptionValue("directory", ".")); configureBindServer(main.conn, cl); main.setProtocol(toProtocol(cl)); main.arr.addConnection(main.conn); CLIUtils.configure(main.conn, cl); }
private void loadFrom(AuditRecordRepository arr, Attributes attrs) throws NamingException { arr.setInstalled( LdapUtils.booleanValue(attrs.get("dicomInstalled"), null)); }
private Attributes storeTo(ConfigurationChanges.ModifiedObject ldapObj, AuditRecordRepository arr, String deviceDN, Attributes attrs) { attrs.put(new BasicAttribute("objectclass", "dcmAuditRecordRepository")); LdapUtils.storeConnRefs(ldapObj, attrs, arr.getConnections(), deviceDN); LdapUtils.storeNotNullOrDef(ldapObj, attrs, "dicomInstalled", arr.getInstalled(), null); return attrs; }
private void setProtocol(Connection.Protocol protocol) { conn.setProtocol(protocol); remote.setProtocol(protocol); auditLogger.addConnection(conn); arr.addConnection(remote); }
private void reconfigure(AuditRecordRepository from) { setInstalled(from.installed); device.reconfigureConnections(conns, from.conns); }
private Attributes storeTo(ConfigurationChanges.ModifiedObject ldapObj, AuditRecordRepository arr, String deviceDN, Attributes attrs) { attrs.put(new BasicAttribute("objectclass", "dcmAuditRecordRepository")); LdapUtils.storeConnRefs(ldapObj, attrs, arr.getConnections(), deviceDN); LdapUtils.storeNotNullOrDef(ldapObj, attrs, "dicomInstalled", arr.getInstalled(), null); return attrs; }