Skip to content

Commit

Permalink
AbstractRepositoryManager does not pass the nickname
Browse files Browse the repository at this point in the history
Currently if a discovery event would define a nickname it is not passed
by the add repository method resulting in an updatesite to have an empty
name.

This adds a new method that allows to pass a custom RepositoryInfo so
the nickname can be set.
  • Loading branch information
laeubi committed May 11, 2024
1 parent 36e305b commit 6cd1b69
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,23 @@ private boolean addRepository(URI location, boolean isEnabled, boolean signalAdd
RepositoryInfo<T> info = new RepositoryInfo<>();
info.location = location;
info.isEnabled = isEnabled;
return addRepository(info, signalAdd);
}

private boolean addRepository(RepositoryInfo<T> info, boolean signalAdd) {

boolean added = true;
synchronized (repositoryLock) {
if (repositories == null)
restoreRepositories();
if (contains(location))
if (contains(info.location))
return false;
added = repositories.put(getKey(location), info) == null;
added = repositories.put(getKey(info.location), info) == null;
// save the given repository in the preferences.
remember(info, true);
}
if (added && signalAdd)
broadcastChangeEvent(location, getRepositoryType(), RepositoryEvent.ADDED, isEnabled);
broadcastChangeEvent(info.location, getRepositoryType(), RepositoryEvent.ADDED, info.isEnabled);
return added;
}

Expand Down Expand Up @@ -837,8 +842,13 @@ private boolean matchesFlags(RepositoryInfo<T> info, int flags) {
public void notify(EventObject o) {
if (o instanceof RepositoryEvent) {
RepositoryEvent event = (RepositoryEvent) o;
if (event.getKind() == RepositoryEvent.DISCOVERED && event.getRepositoryType() == getRepositoryType())
addRepository(event.getRepositoryLocation(), event.isRepositoryEnabled(), true);
if (event.getKind() == RepositoryEvent.DISCOVERED && event.getRepositoryType() == getRepositoryType()) {
RepositoryInfo<T> info = new RepositoryInfo<>();
info.location = event.getRepositoryLocation();
info.isEnabled = event.isRepositoryEnabled();
info.nickname = event.getRepositoryNickname();
addRepository(info, true);
}
}
}

Expand Down

0 comments on commit 6cd1b69

Please sign in to comment.