/** * remove Registry url to url list and update the file * * @param info */ public void removeRegistryUrl(RegistryURLInfo info) { if (urlList.contains(info)) { urlList.remove(info); saveUrlsToFile(); removeRegistryPropertyFile(info.getUrl().getHost() + "." + info.getUrl().getPort()); } }
public void modifyRegistryUrl(String registryUrl, String username, String oldUser) { Iterator<RegistryURLInfo> iterator = urlList.iterator(); while (iterator.hasNext()) { RegistryURLInfo reginfo = iterator.next(); if (registryUrl.equals(reginfo.getUrl().toString()) && (oldUser == null || oldUser.equals(reginfo.getUsername()))) { reginfo.setUsername(username); } } saveUrlsToFile(); }
/** save newly added registry url to the url file */ private void saveUrlsToFile() { if (urlListFile.exists()) { urlListFile.delete(); } if (!urlListFile.getParentFile().exists()) { urlListFile.getParentFile().mkdirs(); } Writer output = null; try { output = new BufferedWriter(new FileWriter(urlListFile)); for (RegistryURLInfo registryURLInfo : urlList) { try { output.write( registryURLInfo.getUrl().toString() + " " + Boolean.toString(registryURLInfo.isEnabled()) + " " + registryURLInfo.getUsername() + " " + registryURLInfo.getPath() + "\n"); } catch (IOException e) { log.error(e); } } } catch (IOException e) { log.error(e); } finally { if (output != null) try { output.close(); } catch (IOException e) { log.error(e); } } }