@@ -10,27 +10,39 @@ Class {
10
10
{ #category : ' private' }
11
11
RwGsImage class >> _projectRegistry [
12
12
13
+ ^ self _projectRegistryForUserId: self currentUserId
14
+ ]
15
+
16
+ { #category : ' private' }
17
+ RwGsImage class >> _projectRegistryForUserId: aUserId [
18
+
13
19
| ug |
14
- ug := self objectNamed: #' UserGlobals' .
20
+ ug := ( AllUsers userWithId: aUserId) objectNamed: #' UserGlobals' .
15
21
^ ug
16
22
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 ]
18
27
]
19
28
20
29
{ #category : ' querying' }
21
30
RwGsImage class >> addProject: aRwProjectSpecification [
22
31
23
32
" Register a project"
24
33
25
- | projectName |
34
+ | projectName projectRegistry |
26
35
projectName := aRwProjectSpecification specName.
27
- self _projectRegistry
36
+ projectRegistry := self
37
+ _projectRegistryForUserId:
38
+ (aRwProjectSpecification platformSpec at: ' gemstone' ) projectOwnerId.
39
+ projectRegistry
28
40
at: projectName
29
41
ifPresent: [ :aLoadedProject |
30
42
self
31
43
error:
32
44
' There is already a project named ' , projectName printString , ' registered' ].
33
- ^ self _projectRegistry at: projectName put: aRwProjectSpecification
45
+ ^ projectRegistry at: projectName put: aRwProjectSpecification
34
46
]
35
47
36
48
{ #category : ' modifying image' }
@@ -52,6 +64,12 @@ RwGsImage class >> applyModification: aPackageSetModification for: aRwProjectLoa
52
64
patchSet apply
53
65
]
54
66
67
+ { #category : ' testing' }
68
+ RwGsImage class >> canWrite: anObject [
69
+
70
+ ^ System canWrite: anObject
71
+ ]
72
+
55
73
{ #category : ' querying' }
56
74
RwGsImage class >> currentUserId [
57
75
@@ -120,9 +138,27 @@ RwGsImage class >> objectNamed: aSymbol [
120
138
{ #category : ' querying' }
121
139
RwGsImage class >> projectNamed: aString ifAbsent: absentBlock [
122
140
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 ]
126
162
]
127
163
128
164
{ #category : ' querying' }
@@ -132,7 +168,11 @@ RwGsImage class >> removeProject: aRwProjectSpecification [
132
168
133
169
| projectName |
134
170
projectName := aRwProjectSpecification specName.
135
- self _projectRegistry removeKey: projectName ifAbsent: [ ]
171
+ (self
172
+ _projectRegistryForUserId:
173
+ (aRwProjectSpecification platformSpec at: ' gemstone' ) projectOwnerId)
174
+ removeKey: projectName
175
+ ifAbsent: [ ]
136
176
]
137
177
138
178
{ #category : ' querying' }
0 commit comments