Bug 248269 - Add contains API for repository managers
Summary: Add contains API for repository managers
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: p2 (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.5 M4   Edit
Assignee: John Arthorne CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks: 247664 248056
  Show dependency tree
 
Reported: 2008-09-23 09:59 EDT by Andrew Cattle CLA
Modified: 2008-11-12 14:39 EST (History)
4 users (show)

See Also:


Attachments
Adds functionality for RepoManagers to check if URL is already loaded as a repository (3.61 KB, patch)
2008-09-23 16:06 EDT, Andrew Cattle CLA
no flags Details | Diff
Added new API, and removed all places where we were downcasting (8.37 KB, patch)
2008-11-12 14:37 EST, John Arthorne CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Cattle CLA 2008-09-23 09:59:41 EDT
To fix bug Bug 247664 while respecting Bug 248056 we need to be able to know if a repository is loaded. There's a couple ways do do this but it would be better if it was included in the API
Comment 1 Susan McCourt CLA 2008-09-23 11:25:24 EDT
If we end up doing API for this, let's consider something more detailed than a boolean, such as LOADED, NOT_LOADED, NOT_FOUND, LOADING, etc.  

The UI could probably take advantage of this in certain places.
Comment 2 Andrew Cattle CLA 2008-09-23 13:54:24 EDT
I agree that that would be good functionality but I actually discovered that the exact functionality I needed is contained in the ArtifactRepositoryManager contains(URL) method. As a temporary fix I've simply added this method to the IArtifactRepositoryManager class on my local machine.
Comment 3 Andrew Cattle CLA 2008-09-23 16:06:19 EDT
Created attachment 113296 [details]
Adds functionality for RepoManagers to check if URL is already loaded as a repository

in both cases the functionality was already coded into the concrete classes, all I did was change private to public for metadata and add public in front of boolean for artifact.

Also I added the method "public boolean contains(URL location);" to both IArtifactRepositoryManager and IMetadatarepositoryManager.

My patches for Bug 247664 and Bug 248056 both currently rely on this code.
Comment 4 Pascal Rapicault CLA 2008-09-23 21:14:21 EDT
I think Susan's requirement makes sense. CC'ing John as he will be working on the API side of that.
Comment 5 John Arthorne CLA 2008-09-25 17:02:45 EDT
I will take this because I am currently heavily refactoring the repository manager classes.
Comment 6 John Arthorne CLA 2008-11-12 13:22:00 EST
What Andrew meant here was not to know if a repository is loaded, but just to determine if a repository is already in the list of known repositories. I.e., it's just a contains() method that he needs. The problem with returning information on whether a repositories is "loaded" (in memory), is that with our caching behaviour a repository that is loaded at one moment could be flushed from memory immediately afterwards. So an isLoaded() method would an answer that could immediately become invalid.

The only other thing I considered was combining a contains() method with isEnabled(). I..,e a getState() method that returns EXISTS, ENABLED, etc as bit-masks. Although this removes a method and enables us to add extra values in the future, I don't think this is very useable for clients. So, I'm leaning towards just adding the single contains() method (returning a boolean), that returns "is this a known repository".
Comment 7 John Arthorne CLA 2008-11-12 14:37:30 EST
Created attachment 117697 [details]
Added new API, and removed all places where we were downcasting
Comment 8 John Arthorne CLA 2008-11-12 14:39:03 EST
Released.