Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 260411 - [composite] Unable to create non-local repo or child
Summary: [composite] Unable to create non-local repo or child
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: p2 (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.5 M5   Edit
Assignee: DJ Houghton CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 257783
  Show dependency tree
 
Reported: 2009-01-08 11:21 EST by DJ Houghton CLA
Modified: 2009-01-21 12:17 EST (History)
3 users (show)

See Also:


Attachments
patch (4.04 KB, patch)
2009-01-19 17:49 EST, DJ Houghton CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description DJ Houghton CLA 2009-01-08 11:21:39 EST
We need to be able to create a composite repository which isn't local. Currently the constructor code tries to save the repo one it is created. This will fail because the repo is not modifiable.

Currently the code also will not allow for the addition of a non-local child.

Note that the code is the same for artifact and metadata repos.
Comment 1 DJ Houghton CLA 2009-01-08 14:33:55 EST
Jeff I'll move this bug to me but if you want it, then feel free to grab it.
Comment 2 Jeff McAffer CLA 2009-01-08 17:54:28 EST
Thanks for opening this DJ.  I was thinking that we could address the first problem by simply checking isModifiable() before calling save().
Comment 3 DJ Houghton CLA 2009-01-09 10:41:52 EST
Yeah I was going to do that and then I was wondering if we just wanted to change #save method so it didn't throw the assertion failed exception... I mean if all the callers are going to do the check then why not change the lower code.

Basically:

private void save() {
  if (!isModifiable())
    return;
  ...
}

I find that I am getting conflicting feelings in the way we should go on this. If you are creating Composite Repositories in scripts or via Ant or as part of a build or mirroring process, then I would argue that you would want to fail if the user tries to save an unmodifiable repository. 

But on the other hand if I'm just spoofing one up in memory and plan to throw it away later, then I shouldn't be required to persist it.

Adding John to CC in case he has some thoughts as he worked with Andrew on this a bit.

Comment 4 Jeff McAffer CLA 2009-01-11 21:46:16 EST
I see your points.  The quirkiness comes from the case where you have a persistent repo that is NOT modifiable.  If someone calls save() they should likely be spanked in the same way as someone calling a write method on a read only file.  For in memory repos (a real usecase) what you do in save (or whether save is even called) is likely irrelevant.

So I would make the save()s private and put the isModifiable() test in the callers.
Comment 5 DJ Houghton CLA 2009-01-19 17:32:00 EST
Sorry for the delay in this Jeff but I read your comment a bunch of times and am still a little confused. Unless you meant to say:

"So I would make the save()s public and put the isModifiable() test in the
callers."

This would make it so that we can add things to a repo in memory but if someone explicitly tries to save a non-modifiable repo, then it would throw an exception.

Comment 6 DJ Houghton CLA 2009-01-19 17:49:08 EST
Created attachment 123010 [details]
patch

Here is a patch with a public save method and all the local callers checking first to see if the repository is modifiable... in case we're thinking the same thing?
Comment 7 Jeff McAffer CLA 2009-01-20 21:32:54 EST
I really did mean that the save()s should be private.  No one calls them externally.  save() is not part of the repository API and is only called by internal lifecycle methods.  
Comment 8 DJ Houghton CLA 2009-01-21 12:17:33 EST
I think my confusion comes when you say that people calling #save should be spanked in the case where they have a non-local repo. 

So I have removed the spanking (e.g. call to #assertModifiable) in #save and changed it to only do work if the repo is modifiable. (we've spent way too much time on this bug which I thought was a simple fix :-)

I figure if the method is private and all callers are calling #isModifiable then we might as well put the check in #save itself.

I released the change but if that's not what you're thinking then please make changes and re-release.