@Test public void addBinding(){ BindingConfiguration configuration = new BindingConfiguration(); configuration.setUrl("junit-test"); dao.addBinding(configuration); }
public BindingConfiguration addBinding(BindingConfiguration configuration){ JabbotConfiguration jabbotConfiguration; try { jabbotConfiguration = mapper.readValue(resource,JabbotConfiguration.class); } catch (IOException e) { logger.warn("unable to read source config, creating a new one"); jabbotConfiguration = new JabbotConfiguration(); } if(configuration.getId() == null){ logger.debug("generating a new binding identifier"); String identifier = UUID.randomUUID().toString(); configuration.setId(identifier); } if(jabbotConfiguration.getServerList() == null){ jabbotConfiguration.setServerList(new HashSet<BindingConfiguration>()); }else{ for (BindingConfiguration bindingConfiguration : jabbotConfiguration.getServerList()) { if(bindingConfiguration.equals(configuration)){ logger.info("a similar binding already exists"); } } } jabbotConfiguration.getServerList().add(configuration); try { write(jabbotConfiguration); } catch (IOException e) { logger.error("failed to add binding %",configuration,e); } return configuration; }
FileConfigurationDao implements ConfigurationDao { public BindingConfiguration addBinding(BindingConfiguration configuration){ JabbotConfiguration jabbotConfiguration; try { jabbotConfiguration = mapper.readValue(resource,JabbotConfiguration.class); } catch (IOException e) { logger.warn("unable to read source config, creating a new one"); jabbotConfiguration = new JabbotConfiguration(); } if(configuration.getId() == null){ logger.debug("generating a new binding identifier"); String identifier = UUID.randomUUID().toString(); configuration.setId(identifier); } if(jabbotConfiguration.getServerList() == null){ jabbotConfiguration.setServerList(new HashSet<BindingConfiguration>()); }else{ for (BindingConfiguration bindingConfiguration : jabbotConfiguration.getServerList()) { if(bindingConfiguration.equals(configuration)){ logger.info("a similar binding already exists"); } } } jabbotConfiguration.getServerList().add(configuration); try { write(jabbotConfiguration); } catch (IOException e) { logger.error("failed to add binding %",configuration,e); } return configuration; } }
FileConfigurationDao implements ConfigurationDao { public BindingConfiguration addBinding(BindingConfiguration configuration){ JabbotConfiguration jabbotConfiguration; try { jabbotConfiguration = mapper.readValue(resource,JabbotConfiguration.class); } catch (IOException e) { logger.warn("unable to read source config, creating a new one"); jabbotConfiguration = new JabbotConfiguration(); } if(configuration.getId() == null){ logger.debug("generating a new binding identifier"); String identifier = UUID.randomUUID().toString(); configuration.setId(identifier); } if(jabbotConfiguration.getServerList() == null){ jabbotConfiguration.setServerList(new HashSet<BindingConfiguration>()); }else{ for (BindingConfiguration bindingConfiguration : jabbotConfiguration.getServerList()) { if(bindingConfiguration.equals(configuration)){ logger.info("a similar binding already exists"); } } } jabbotConfiguration.getServerList().add(configuration); try { write(jabbotConfiguration); } catch (IOException e) { logger.error("failed to add binding %",configuration,e); } return configuration; } FileConfigurationDao(File configFile); }
FileConfigurationDao implements ConfigurationDao { public BindingConfiguration addBinding(BindingConfiguration configuration){ JabbotConfiguration jabbotConfiguration; try { jabbotConfiguration = mapper.readValue(resource,JabbotConfiguration.class); } catch (IOException e) { logger.warn("unable to read source config, creating a new one"); jabbotConfiguration = new JabbotConfiguration(); } if(configuration.getId() == null){ logger.debug("generating a new binding identifier"); String identifier = UUID.randomUUID().toString(); configuration.setId(identifier); } if(jabbotConfiguration.getServerList() == null){ jabbotConfiguration.setServerList(new HashSet<BindingConfiguration>()); }else{ for (BindingConfiguration bindingConfiguration : jabbotConfiguration.getServerList()) { if(bindingConfiguration.equals(configuration)){ logger.info("a similar binding already exists"); } } } jabbotConfiguration.getServerList().add(configuration); try { write(jabbotConfiguration); } catch (IOException e) { logger.error("failed to add binding %",configuration,e); } return configuration; } FileConfigurationDao(File configFile); JabbotConfiguration getConfiguration(); JabbotConfiguration saveConfiguration(JabbotConfiguration configuration); BindingConfiguration[] getBindings(); BindingConfiguration getBinding(String identifier); BindingConfiguration addBinding(BindingConfiguration configuration); }
FileConfigurationDao implements ConfigurationDao { public BindingConfiguration addBinding(BindingConfiguration configuration){ JabbotConfiguration jabbotConfiguration; try { jabbotConfiguration = mapper.readValue(resource,JabbotConfiguration.class); } catch (IOException e) { logger.warn("unable to read source config, creating a new one"); jabbotConfiguration = new JabbotConfiguration(); } if(configuration.getId() == null){ logger.debug("generating a new binding identifier"); String identifier = UUID.randomUUID().toString(); configuration.setId(identifier); } if(jabbotConfiguration.getServerList() == null){ jabbotConfiguration.setServerList(new HashSet<BindingConfiguration>()); }else{ for (BindingConfiguration bindingConfiguration : jabbotConfiguration.getServerList()) { if(bindingConfiguration.equals(configuration)){ logger.info("a similar binding already exists"); } } } jabbotConfiguration.getServerList().add(configuration); try { write(jabbotConfiguration); } catch (IOException e) { logger.error("failed to add binding %",configuration,e); } return configuration; } FileConfigurationDao(File configFile); JabbotConfiguration getConfiguration(); JabbotConfiguration saveConfiguration(JabbotConfiguration configuration); BindingConfiguration[] getBindings(); BindingConfiguration getBinding(String identifier); BindingConfiguration addBinding(BindingConfiguration configuration);  }