public ConnectorConfiguration(ConnectorId id, ConnectorDescription content) { this.metaData = id.toMetaData(); this.content = content; }
private void checkForExistingServices(ConnectorId id) { try { List<ConnectorConfiguration> list = getConfigPersistence().load(id.toMetaData()); if (!list.isEmpty()) { throw new IllegalArgumentException("connector already exists"); } } catch (PersistenceException e) { throw new RuntimeException(e); } }
@Override public ConnectorDescription getAttributeValues(ConnectorId id) { try { List<ConnectorConfiguration> list = getConfigPersistence().load(id.toMetaData()); if (list.isEmpty()) { throw new IllegalArgumentException("no connector with metadata: " + id + " found"); } if (list.size() < 1) { LOGGER.error("multiple values found for the same meta-data"); throw new IllegalStateException("multiple connectors with metadata: " + id + " found"); } return list.get(0).getContent(); } catch (PersistenceException e) { throw new RuntimeException(e); } }
private ConnectorDescription getOldConfig(ConnectorId id) { List<ConnectorConfiguration> list; try { list = getConfigPersistence().load(id.toMetaData()); } catch (PersistenceException e) { throw new RuntimeException(e); } if (list.isEmpty()) { throw new IllegalArgumentException("no connector with id " + id + " found"); } if (list.size() > 1) { throw new IllegalStateException("multiple connectors with id " + id + " found"); } return list.get(0).getContent(); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() == obj.getClass()) { ConnectorId other = (ConnectorId) obj; return equals(other); } if (Map.class.isInstance(obj)) { Map<?, ?> metadata = (Map<?, ?>) obj; return toMetaData().equals(metadata); } if (obj instanceof String) { return toFullID().equals(obj); } return false; }
@Override public void delete(ConnectorId id) throws PersistenceException { registrationManager.remove(id); getConfigPersistence().remove(id.toMetaData()); }