Community
Participate
Working Groups
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.
Created attachment 123139 [details] patch
done
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.
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..
> Ian can you provide a patch for this? Yep.
Created attachment 125577 [details] Patch that follows John's suggestion This patch addresses the problem using John's suggestions.
released a slightly modified version of the patch. I added Publisher.loadMetadataRepository and Publisher.loadArtifactRepository methods that I want for bug 259792.
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.
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)?
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.
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).
done by using IRepositoryManager.REPOSITORY_HINT_MODIFIABLE