Bug 202630 - [api][persistence] SystemProfileManager.getDefaultPrivateSystemProfile() is inconsistent with ensureDefaultPrivateProfile()
Summary: [api][persistence] SystemProfileManager.getDefaultPrivateSystemProfile() is i...
Status: RESOLVED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.0 M6   Edit
Assignee: David Dykstal CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords: api, investigate
Depends on:
Blocks:
 
Reported: 2007-09-07 09:54 EDT by Martin Oberhuber CLA
Modified: 2012-05-23 16:44 EDT (History)
3 users (show)

See Also:


Attachments
ensure the same default private profile for all clients (12.75 KB, patch)
2007-09-18 05:43 EDT, Tobias Schwarz CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Oberhuber CLA 2007-09-07 09:54:32 EDT
A user is running RSE on multiple UNIX machines, sharing the same
workspace through a network file system on all those machines.

Starting RSE first on machine A, generates a default private profile named A.
Starting RSE on machine B now,
   ensureDefaultPrivateProfile() uses profile A because it is marked
   "default private".

But getDefaultPrivateSystemProfile() returns null, because no profile with name B exists.

This is inconsistent. It is unclear, how programmatic access to RSE should treat the default private system profile in such a scenario. Javadoc does document getDefaultPrivateSystemProfile() correctly as it works now, but this way is currently questionable. 

This also shows in the usage where getDefaultPrivateSystemProfile() is used: on host B, several functionality of RSE will not be available because it returns null (e.g. systemSearchPage will not find a default host to search).

We'll need to understand and specify what exactly we mean by the "default private system profile" and how it is intended to be used. 

Dave can you give a comment on this?
Comment 1 Martin Oberhuber CLA 2007-09-07 10:02:52 EDT
Currently Javadoc says this:

	/**
	 * @return the default private profile created at first touch.
	 * Will return null if it has been renamed.
	 */
	public ISystemProfile getDefaultPrivateSystemProfile();

Perhaps it would be sufficient to tell clients what they should do in case they get null, and that they can get null in any of the following cases:

  * default private profile has been deleted (while running rse, i.e. after
    ensureDefaultPrivateProfile has been called)
  * default private profile has been renamed
  * We're running on a different host than the original one on which the 
    default private profile had been created

I think it would make sense if RSE profile manager could ensure that at any given time, there is exactly one active "default private" profile. But we should discuss this.
Comment 2 Tobias Schwarz CLA 2007-09-18 05:43:59 EDT
Created attachment 78624 [details]
ensure the same default private profile for all clients

i did some changes on the SystemProfileManager that should solve the problem of different private system profiles.

the private system profile is now "calculated" when ensureDefaultPrivateProfile is called. getDefaultPrivateSystemProfile() always returns this profile (and can never return null up to now).

the algorithm to "calculate" the default private system profile does the following:
- take the list of all active profiles (without the team profile)

- first of all the profile with the machines name is used when 
  - it is the only one, 
  - it is marked as default private,
  - or no other profile is marked as default private
- otherwise the first profile marked as default private is used
- otherwise the first available profile is used
- otherwise no profile exists, so a new one with the machines name will be created

the used profile will be marked as default private, all other profiles will be marked as NON default private


additionally i removed some unused private methods from the SystemProfileManager.
Comment 3 Martin Oberhuber CLA 2007-09-18 06:29:49 EDT
We'll probably need to discuss this again, but from the discussions we've had so far my understanding is this:

1.) The attribute that's persisted with the profiles ("isDefaultPrivate()")
    is not named correctly. It should better be named "isPrivate()" indicating
    that it should not be team-shared.
    We cannot make the renaming now since it would be an API change, but we
    should understand that this is the real meaning of this attribute.
    In an environment of multiple profiles and persistence providers, which
    can be made active/inactive, we cannot really guarantee that one given
    profile is the "default". Being the default or not can only be done
    dynamically, but it cannot be persisted.

2.) The persisted attribute should not be changed. It is a property of the
    profile, indicating how it was generated (automatically) and that it
    is not meant to be team-shared. You cannot go and set/reset this.

3.) I think that de-activating the default private profile does not make 
    sense (it should always be active, the UI should even forbid de-activating
    it). Therefore, I think the algorithm for finding the default private 
    profile should be allowed to activate a private one if it finds one.

Because of this, I think the algorithm needs to be different:

* Assemble a list of all profiles marked "private".
* If it contains the profile with current host name, this is the default
  private one. Activate it if necessary.
* Otherwise, the first active one is default private.
* If no active one, the first one is default prrivate. Activate it.

If the list was empty, create a new profile:
- Try current host name; modify the name by appending a number until no
  profile is found by that name which is not marked private.

Comment 4 David Dykstal CLA 2008-03-12 17:26:00 EDT
getDefaultPrivateSystemProfile now returns the same profile as that which was ensured.
Fixed with bug 222376.

*** This bug has been marked as a duplicate of bug 222376 ***
Comment 5 Martin Oberhuber CLA 2008-03-13 04:59:38 EDT
I don't think it's a good idea to mark an API-bug as duplicate of a non-API bug. This could give the impression that the API change has not been made (because it's a duplicate of some other API change request somewhere).

Better mark it as dup the other way round.
Comment 6 Martin Oberhuber CLA 2008-03-13 05:00:47 EDT
Fixed with bug 222376.
Comment 7 Martin Oberhuber CLA 2008-03-13 05:32:22 EDT
Tobias can you review and verify the fix please.
Comment 8 Martin Oberhuber CLA 2008-03-13 05:36:15 EDT
Dave: With your current code, what happens if the user makes the default private system profile inactive? 

It's probably not possible by UI but I think the API should also ensure that either this cannot happen, or the default private profile is chosen again just as if a profile is deleted.

Reopen to clarify.
Comment 9 David Dykstal CLA 2008-03-13 18:25:14 EDT
Good question. I think the API should make sure this cannot happen. This should probably hold true as well for delete.
Comment 10 David Dykstal CLA 2008-03-14 13:25:42 EDT
Updates include comments in the javadoc for various levels of deletion and set activation. Actions for delete and activate were modified to disable them when the selected profile is the default profile.
Comment 11 David Dykstal CLA 2008-03-14 14:50:04 EDT
Added testcases for profiles
Comment 12 Martin Oberhuber CLA 2012-05-23 16:44:37 EDT
Comment on attachment 78624 [details]
ensure the same default private profile for all clients

Patch is obsolete since this was fixed differently as per comment 4.