Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 230322

Summary: [ui] Repository name incorrect until repository is first loaded
Product: [Eclipse Project] Equinox Reporter: Nick Boldt <nboldt>
Component: p2Assignee: Susan McCourt <susan>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: cfraser, irbull, pascal, susan
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Bug Depends on: 259598    
Bug Blocks:    

Description Nick Boldt CLA 2008-05-05 22:24:35 EDT
Apologies if this is a dupe.

Steps to repro:

1. Install Eclipse 3.4M7
2. Install EMF 2.4M7 (or a post-M6 I build) from all in one sdk zip into dropins/
3. Start up Eclipse
4. Ignore these errors:

  !ENTRY org.eclipse.equinox.p2.directorywatcher 2 0 2008-05-05 21:18:05.588
  !MESSAGE Feature references invalid site: org.eclipse.emf.ecore.sdo.source
  !STACK 0
  java.net.MalformedURLException: no protocol: %EMFTUpdateSiteName

as they're apparently fixed by building with releng.basebuilder from the M7_34 tag (bug 229916) though there's a wrinkle there (bug 229916 comment 5)

5. Help > Software Updates... > Available Software

6. Note the URL http://download.eclipse.org/modeling/emf/updates/, which was loaded as per various feature.xmls files (eg., org.eclipse.emf-feature/feature.xml):

   <url>
      <update label="%EMFUpdateSiteName" url="http://download.eclipse.org/modeling/emf/updates/"/>
      <discovery label="%EMFUpdateSiteName" url="http://download.eclipse.org/modeling/emf/updates/"/>
      <discovery label="%EMFTUpdateSiteName" url="http://download.eclipse.org/modeling/emft/updates/"/>
   </url>

Instead of seeing "Eclipse Modeling Framework (EMF) Updates", we see the URL. EMFUpdateSiteName is defined in feature.properties thus:

  EMFUpdateSiteName=Eclipse Modeling Framework (EMF) Updates

Note also that none of the Discovery URLs are shown.
Comment 1 John Arthorne CLA 2008-05-06 17:48:04 EDT
> Note also that none of the Discovery URLs are shown.

There are three sites here with the same URL. p2 uniquely identifies repositories by URL, so these three are all the same repository and you will only see one "site" in the Manage Sites dialog.
Comment 2 John Arthorne CLA 2008-05-06 18:07:36 EDT
The difference here is that p2 repositories know their own name, whereas UM update sites did not contain a human-readable name. So, there is a conceptual mismatch here that would be difficult to resolve. If you call the repo "foo", but the repo calls itself "bar", then "bar" will win.  With update sites that are not yet p2-enabled, they do not know their name so this results in the less than optimal behavior that the name becomes simply the URL. This will likely be WONTFIX.
Comment 3 Nick Boldt CLA 2008-05-06 19:44:13 EDT
Actually, it's TWO sites. EMF and EMFT are different sites, and they're BOTH p2-enabled, as per bug 229913.

So, if I install a feature, and it includes a reference to an update site, even if that site is p2-enabled, I still see the URL, not the site's name. Shouldn't p2 be able to show either the label defined in the feature.xml / feature.properties, or the value in the artifacts.jar / content.jar on the remote site? 

I can call it bar or foo, but it still shows me http://.../.

(I don't care which one wins, as long as something is shown. If the site knows its name, great. If not, show me the value specified by the feature. Which ought to take precedence is another issue entirely.)

Or... maybe I'm not setting the site name correctly in the p2 metadata? You can check here:

http://download.eclipse.org/modeling/emf/updates/interim/artifacts.jar
http://download.eclipse.org/modeling/emf/updates/interim/content.jar
Comment 4 John Arthorne CLA 2008-05-08 18:11:21 EDT
This looks like some kind of transient problem in the UI. If I close and reopen the dialog after adding the repository, the correct name shows up. Needs more investigation...
Comment 5 John Arthorne CLA 2008-05-08 18:30:51 EDT
I have debugged this, and I can see what happens.

- When the user first adds a repository, the UI just calls IMetadataRepository#add(URL). At this point we don't know the repository name, because we have never loaded it.
- If the user expands the repository, or if it is loaded for any other reason, then we discover the repository name and store the result in the preferences
- In subsequent sessions, we retrieve the repository name from the preferences, so we can display the correct name without loading the repository.

So, this is just an issue when a repository is first added, and it has never been loaded. The only way to fix this is to force loading the repository when it is added. We intentionally are not doing this because it forces a large performance hit. If the user never cares about the contents of that repository, it is loaded for no reason.
Comment 6 John Arthorne CLA 2008-05-09 10:56:34 EDT
Susan, one small potential improvement here: currently the user needs to close and reopen the dialog to see the correct repository name. It would be a slight improvement if the repository name was refreshed when a repository load occurs.
Comment 7 Susan McCourt CLA 2008-05-09 12:32:28 EDT
Agree...John, on first glance of the code in MetadataRepositoryManager, it doesn't seem like I get a CHANGED event (or whatever the appropriate one would be) when a repo is loaded.  Should we have LOAD event?  
Comment 8 Susan McCourt CLA 2008-05-09 12:34:17 EDT
Another point as far as usability is concerned...in practice the name would change as a result of the user expanding the tree.  Might be disconcerting to do it instantly.  I'd have to see how this plays in practice...
Comment 9 John Arthorne CLA 2008-05-21 10:20:39 EDT
Removing milestone. I don't think we'll get to this.
Comment 10 Susan McCourt CLA 2008-10-27 13:24:29 EDT
*** Bug 252190 has been marked as a duplicate of this bug. ***
Comment 11 Susan McCourt CLA 2008-12-23 15:00:30 EST
What I see doing here, assuming we implement bug #259598 is:
- the UI should query the name property from the repo manager
- this would show any name the user had typed when adding the repo, or the repo producer's name if the repo is loaded, or nothing/location (depending on the context).
- the views that show repo names could update dynamically but we need to understand what event would fire (maybe a changed event showing the name changing from nothing to the loaded name?)

I'll take this bug from John since I just opened bug #259598 for the repo manager side of this.
Comment 12 Pascal Rapicault CLA 2009-02-20 10:50:24 EST
How does that relate to bug 194224.
Comment 13 Susan McCourt CLA 2009-02-23 12:18:05 EST
(In reply to comment #12)
> How does that relate to bug 194224.
> 
If we support nicknames that are kept by the repo manager, then things here will improve.  

The only time the name would change would be on the very first repo load if there was no nickname set and the repo provider had specified a name.  At that point the UI would make the nickname be the producer-name and then users wouldn't see this happen again.  (Depends on whether we force a nickname in the UI).

marking this M6 as I plan to deal with this and the nickname issue together.
Comment 14 Susan McCourt CLA 2009-03-18 13:39:40 EDT
Marking WONTFIX.  

Now that we prompt for and store nicknames, the worst case is that this happens the first time a repo is added by the user, and only if the user does not specify a nickname.  In this case, no name is shown until the repo is loaded.  

However, once a site loads, if there is a name specified in the repo and not a nickname set by the user, we set the nickname to be the site name.  This way, the name is permanently stored with the repo manager and on subsequent runs of the product, the name will appear even when the repo is not loaded.

When this bug was reported, this happened on every startup and could even happen more than once during an Eclipse session.
Comment 15 Susan McCourt CLA 2009-03-18 13:41:57 EDT
> When this bug was reported, this happened on every startup and could even
> happen more than once during an Eclipse session.
> 
Actually, I think I'm wrong about this.  It seems the repo manager was storing the name so this has always been a "first time only" issue.  The difference now is that the user can add a name from the start and if they do so, it shows right away.