Bug 261731 - [publisher] Should attempt to create repo before load repo
Summary: [publisher] Should attempt to create repo before load repo
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: p2 (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M6   Edit
Assignee: P2 Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 248951
Blocks: 241441
  Show dependency tree
 
Reported: 2009-01-20 17:49 EST by Andrew Niefer CLA
Modified: 2009-02-18 18:30 EST (History)
1 user (show)

See Also:


Attachments
patch (5.20 KB, patch)
2009-01-20 18:24 EST, Andrew Niefer CLA
no flags Details | Diff
Patch that follows John's suggestion (7.13 KB, patch)
2009-02-12 15:08 EST, Ian Bull CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Niefer CLA 2009-01-20 17:49:44 EST
The Publisher.createArtifactRepository and Publisher.createMetadataRepository currently both try loading the repository before creating it.

If you are publishing in-place, or over an old site.xml, this can result in getting either a UpdatesiteArtifactRepository or a ExtensionLocationArtifactRepository.  This leads to an inevitable "Artifact Repository is not writable" IllegalArgumentException.

See bug 227383 where this used to be a problem in the metadata generator.

The fix is to first try creating a simple repository, if that fails (repo exists), then load the existing repo.
Comment 1 Andrew Niefer CLA 2009-01-20 18:24:42 EST
Created attachment 123139 [details]
patch
Comment 2 Andrew Niefer CLA 2009-01-21 15:46:30 EST
done
Comment 3 Ian Bull CLA 2009-02-09 18:34:08 EST
Andrew, we always try to create a simple repo. What if it wasn't a simple repo that user was trying to load? In this case the create passes, even though we were not trying to create, but rather load the repository.

Re-opening the bug.
Comment 4 John Arthorne CLA 2009-02-11 15:22:14 EST
I suggest something like:

 - attempt to load the repository
 - if load fails or !repo.isModifiable(), then create a simple repo

Ian can you provide a patch for this? Our other headless apps may also have the same problem..
Comment 5 Ian Bull CLA 2009-02-11 16:36:56 EST
 > Ian can you provide a patch for this? 

Yep.
Comment 6 Ian Bull CLA 2009-02-12 15:08:06 EST
Created attachment 125577 [details]
Patch that follows John's suggestion

This patch addresses the problem using John's suggestions.
Comment 7 Andrew Niefer CLA 2009-02-12 21:53:14 EST
released a slightly modified version of the patch.  
I added Publisher.loadMetadataRepository and Publisher.loadArtifactRepository methods that I want for bug 259792.  
Comment 8 Andrew Niefer CLA 2009-02-13 18:35:38 EST
Reopening.
As mentioned in comment #0, loading first can result in an UpdatesiteArtifactRepository or a ExtensionLocationArtifactRepository.  While we no longer throw an exception on !isModifiable, we are still loading those repositories and potentially generating a pile of metadata on any artifacts that may exist there.  At best this is a huge performance hit for nothing, in worse cases, if that generated metadata is not thrown away, it could interfere with publishing.
Comment 9 Ian Bull CLA 2009-02-13 18:56:00 EST
Thinking about the "real" problem here.  Is there anyway we can lookup a repository, before loading it, to see if it is "publishable" (I guess this would be modifiable)? 
Comment 10 Ian Bull CLA 2009-02-13 19:02:28 EST
It might  be a big change, but maybe the definition of the repository (in the extension point) should specifically state if the repository is "publishable". If we are given a repository that we can publish into, great.  If not, we create a simple one.
Comment 11 Ian Bull CLA 2009-02-13 19:48:14 EST
Actually, a slightly easier approach may be to add an isModifiable() method to the Metadata / Artifact Factory.  It would be up to the factory to figure out if a repository is writable or not.  In the manager we could even create a loadRepositoryForWrite(...), which would (fast-fail) and throw a provisioning exception if the repository is not modifiable.  

Do you think it is reasonable for the factories to figure out if their repositories are writable?  (Before actually loading them).
Comment 12 Andrew Niefer CLA 2009-02-18 18:30:30 EST
done by using IRepositoryManager.REPOSITORY_HINT_MODIFIABLE