Skip to content

Commit

Permalink
Remember referenced repositories as system repositories instead of user
Browse files Browse the repository at this point in the history
Currently there is a quite surprising behavior, that if a user adds an
updatesite that contains a referenced repository, that after an
update-check additional repositories are visible. Even worse these are
now used additionally to check for updates and if they contain other
references these are also added and so on. This can result not only in a
long list of sites the user never has added and has no clue where they
are coming from but even pulling in unwanted or conflicting updates.

This now distinguishes two cases:

1) A repository is discovered by the RepositoryAction it is handled as a
user added repository and becomes visible
2) A repository is discovered by a reference in that case it is handled
as a system repository and not becomes visible

that way the list of user visible repositories stay clean from
referenced repositories and unexpected side effects on update checks.
  • Loading branch information
laeubi committed May 11, 2024
1 parent 5487867 commit 53a9d71
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public void publishRepositoryReferences() {
List<IRepositoryReference> repositoriesSnapshot = createRepositoriesSnapshot();
for (IRepositoryReference reference : repositoriesSnapshot) {
RepositoryEvent event = RepositoryEvent.newDiscoveryEvent(reference.getLocation(), reference.getNickname(),
reference.getType(), reference.isEnabled());
reference.getType(), reference.isEnabled(), true);
bus.publishEvent(event);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,7 @@ public void notify(EventObject o) {
info.location = event.getRepositoryLocation();
info.isEnabled = event.isRepositoryEnabled();
info.nickname = event.getRepositoryNickname();
info.isSystem = event.isSystem();
addRepository(info, true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
Expand All @@ -21,27 +21,27 @@
/**
* An event indicating a repository was added, removed, changed,
* or discovered.
*
*
* @see IProvisioningEventBus
* @noextend This class is not intended to be subclassed by clients.
*/
public class RepositoryEvent extends EventObject {
private static final long serialVersionUID = 3082402920617281765L;

/**
* A change kind constant (value 0), indicating a repository was added to the
* A change kind constant (value 0), indicating a repository was added to the
* list of repositories known to a repository manager.
*/
public static final int ADDED = 0;

/**
* A change kind constant (value 1), indicating a repository was removed from
* A change kind constant (value 1), indicating a repository was removed from
* the list of repositories known to a repository manager.
*/
public static final int REMOVED = 1;

/**
* A change kind constant (value 2), indicating a repository known to a
* A change kind constant (value 2), indicating a repository known to a
* repository manager was modified.
*/
public static final int CHANGED = 2;
Expand All @@ -67,6 +67,7 @@ public class RepositoryEvent extends EventObject {
private final int kind, type;
private boolean isEnabled;
private String nickname;
private boolean system;

/**
* Creates and returns a new repository discovery event.
Expand All @@ -77,15 +78,17 @@ public class RepositoryEvent extends EventObject {
* @return A new repository discovery event
* @see IRepository#PROP_NICKNAME
*/
public static RepositoryEvent newDiscoveryEvent(URI location, String nickname, int repositoryType, boolean enabled) {
public static RepositoryEvent newDiscoveryEvent(URI location, String nickname, int repositoryType, boolean enabled,
boolean system) {
RepositoryEvent event = new RepositoryEvent(location, repositoryType, DISCOVERED, enabled);
event.nickname = nickname;
event.system = system;
return event;
}

/**
* Creates a new repository event.
*
*
* @param location the location of the repository that changed.
* @param repositoryType the type of repository that was changed
* @param kind the kind of change that occurred.
Expand Down Expand Up @@ -121,9 +124,19 @@ public String getRepositoryNickname() {
return nickname;
}

/**
* Returns if the repository is a system type see
* {@link IRepository#PROP_SYSTEM}. This method is only applicable for the
* {@link #DISCOVERED} event type. For other event types this method returns
* <code>false</code>.
*/
public boolean isSystem() {
return system;
}

/**
* Returns the location of the repository associated with this event.
*
*
* @return the location of the repository associated with this event.
*/
public URI getRepositoryLocation() {
Expand All @@ -134,7 +147,7 @@ public URI getRepositoryLocation() {
* Returns the type of repository associated with this event. Clients
* should not assume that the set of possible repository types is closed;
* clients should ignore events from repository types they don't know about.
*
*
* @return the type of repository associated with this event.
* ({@link IRepository#TYPE_METADATA} or {@link IRepository#TYPE_ARTIFACT}).
*/
Expand All @@ -144,7 +157,7 @@ public int getRepositoryType() {

/**
* Returns whether the affected repository is enabled.
*
*
* @return <code>true</code> if the repository is enabled,
* and <code>false</code> otherwise.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ protected RepositoryEvent createEvent(Map<String, Object> parameters) throws Cor
// default is to be enabled
String enablement = (String) parameters.get(ActionConstants.PARM_REPOSITORY_ENABLEMENT);
boolean enabled = enablement == null ? true : Boolean.parseBoolean(enablement);
return RepositoryEvent.newDiscoveryEvent(location, name, type, enabled);
return RepositoryEvent.newDiscoveryEvent(location, name, type, enabled, false);
}

/**
Expand Down

0 comments on commit 53a9d71

Please sign in to comment.