}
PluginRepositoryList[] lists = PortletManager.getCurrentServer(request).getPluginRepositoryLists();
// Check for duplicates
for (int i = 0; i < lists.length; i++) {
PluginRepositoryList test = lists[i];
URL[] all = test.getRepositories();
for (int j = 0; j < all.length; j++) {
String existing = all[j].toString();
if(!existing.endsWith("/")) {
existing = existing + "/";
}
if(repo.equals(existing)) {
response.setRenderParameter("repoError", "Already have an entry for repository "+repo);
return false;
}
}
}
// Verify the repository and add it if valid
if(lists.length > 0) {
URL url;
try {
url = new URL(repo);
} catch (MalformedURLException e) {
response.setRenderParameter("repoError", "Invalid repository URL "+repo);
return false;
}
URL test = new URL(repo+"geronimo-plugins.xml");
log.debug("Checking repository "+test);
URLConnection urlConnection = test.openConnection();
if(urlConnection instanceof HttpURLConnection) {
HttpURLConnection con = (HttpURLConnection) urlConnection;
try {
con.connect();
} catch (ConnectException e) {