Skip to content

Commit ec476d5

Browse files
committed
scan AllUsers when doing project lookup to find the entry for the owner of the project ...
1 parent 5a382ba commit ec476d5

File tree

2 files changed

+50
-11
lines changed

2 files changed

+50
-11
lines changed

tonel/Rowan-GemStone/RwGsImage.class.st

+49-9
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,39 @@ Class {
1010
{ #category : 'private' }
1111
RwGsImage class >> _projectRegistry [
1212

13+
^ self _projectRegistryForUserId: self currentUserId
14+
]
15+
16+
{ #category : 'private' }
17+
RwGsImage class >> _projectRegistryForUserId: aUserId [
18+
1319
| ug |
14-
ug := self objectNamed: #'UserGlobals'.
20+
ug := (AllUsers userWithId: aUserId) objectNamed: #'UserGlobals'.
1521
^ ug
1622
at: #'RwGsProjectRegistry'
17-
ifAbsent: [ ug at: #'RwGsProjectRegistry' put: StringKeyValueDictionary new ]
23+
ifAbsent: [
24+
(self canWrite: ug)
25+
ifFalse: [ ^ nil ].
26+
ug at: #'RwGsProjectRegistry' put: StringKeyValueDictionary new ]
1827
]
1928

2029
{ #category : 'querying' }
2130
RwGsImage class >> addProject: aRwProjectSpecification [
2231

2332
"Register a project"
2433

25-
| projectName |
34+
| projectName projectRegistry |
2635
projectName := aRwProjectSpecification specName.
27-
self _projectRegistry
36+
projectRegistry := self
37+
_projectRegistryForUserId:
38+
(aRwProjectSpecification platformSpec at: 'gemstone') projectOwnerId.
39+
projectRegistry
2840
at: projectName
2941
ifPresent: [ :aLoadedProject |
3042
self
3143
error:
3244
'There is already a project named ' , projectName printString , ' registered' ].
33-
^ self _projectRegistry at: projectName put: aRwProjectSpecification
45+
^ projectRegistry at: projectName put: aRwProjectSpecification
3446
]
3547

3648
{ #category : 'modifying image' }
@@ -52,6 +64,12 @@ RwGsImage class >> applyModification: aPackageSetModification for: aRwProjectLoa
5264
patchSet apply
5365
]
5466

67+
{ #category : 'testing' }
68+
RwGsImage class >> canWrite: anObject [
69+
70+
^ System canWrite: anObject
71+
]
72+
5573
{ #category : 'querying' }
5674
RwGsImage class >> currentUserId [
5775

@@ -120,9 +138,27 @@ RwGsImage class >> objectNamed: aSymbol [
120138
{ #category : 'querying' }
121139
RwGsImage class >> projectNamed: aString ifAbsent: absentBlock [
122140

123-
"Look up a project"
124-
125-
^ self _projectRegistry at: aString ifAbsent: absentBlock
141+
"Look up a project. First in current users project registry, then scan AllUsers for the project ... note that the user needs to be the project owner."
142+
143+
| currentUserId |
144+
currentUserId = self currentUserId.
145+
^ self _projectRegistry
146+
at: aString
147+
ifAbsent: [
148+
AllUsers
149+
do: [ :userProfile |
150+
| userId |
151+
userId := userProfile userId.
152+
userId ~= currentUserId
153+
ifTrue: [
154+
(self _projectRegistryForUserId: userId)
155+
ifNotNil: [ :projectRegistry |
156+
projectRegistry
157+
at: aString
158+
ifPresent: [ :projectSpec |
159+
(projectSpec platformSpect at: 'gemstone') projectOwnerId = userId
160+
ifTrue: [ ^ projectSpec ] ] ] ] ].
161+
^ absentBlock value ]
126162
]
127163

128164
{ #category : 'querying' }
@@ -132,7 +168,11 @@ RwGsImage class >> removeProject: aRwProjectSpecification [
132168

133169
| projectName |
134170
projectName := aRwProjectSpecification specName.
135-
self _projectRegistry removeKey: projectName ifAbsent: [ ]
171+
(self
172+
_projectRegistryForUserId:
173+
(aRwProjectSpecification platformSpec at: 'gemstone') projectOwnerId)
174+
removeKey: projectName
175+
ifAbsent: [ ]
136176
]
137177

138178
{ #category : 'querying' }

tonel/Rowan-Tode/RwGemStoneSpecification.class.st

+1-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ RwGemStoneSpecification >> postCopy [
103103
{ #category : 'accessing' }
104104
RwGemStoneSpecification >> projectOwnerId [
105105

106-
^projectOwnerId
107-
106+
^ projectOwnerId ifNil: [ RwGsImage currentUserId ]
108107
]
109108

110109
{ #category : 'accessing' }

0 commit comments

Comments
 (0)