@@ -47,6 +47,9 @@ Property defaultMergeBranch As %String [ InitialExpression = {##class(SourceCont
47
47
/// Compile using the configured pull event handler when "Import All" is run
48
48
Property compileOnImport As %Boolean [ InitialExpression = {##class (SourceControl.Git.Utils ).CompileOnImport ()} ];
49
49
50
+ /// Define a namespace-level web application allowing access to multiple git repos across separate namespaces
51
+ Property namespaceLevelGitWebApp As %Boolean [ InitialExpression = {##class (SourceControl.Git.Settings ).HasNamespaceWebApp ()} ];
52
+
50
53
Property Mappings [ MultiDimensional ];
51
54
52
55
Method %OnNew () As %Status
@@ -160,6 +163,75 @@ ClassMethod Configure() As %Boolean [ CodeMode = objectgenerator ]
160
163
do %code .WriteLine (" quit 1" )
161
164
}
162
165
166
+ Method ConfigureNamespaceWebApplication ()
167
+ {
168
+ Set root = ##class (%Library.File ).NormalizeDirectory (##class (SourceControl.Git.Utils ).TempFolder ())
169
+ Set deleteWebApp = ..HasNamespaceWebApp (.appDirectory ) && '..namespaceLevelGitWebApp
170
+ Set createWebApp = ..namespaceLevelGitWebApp && '..HasNamespaceWebApp ()
171
+ Do ..WebAppOperation (" /git/" _$Namespace _" /" , createWebApp , deleteWebApp , root )
172
+ }
173
+
174
+ Method WebAppOperation (name , create As %Boolean , delete As %Boolean , root As %String ) [ Private ]
175
+ {
176
+ Set namespace = $Namespace
177
+ New $Namespace
178
+ Set $Namespace = " %SYS"
179
+ If $Extract (name ) = " /" {
180
+ Set name = $Extract (name ,1 ,*-1 )
181
+ }
182
+ If delete {
183
+ If ##class (Security.Applications ).Exists (name ) {
184
+ $$$ThrowOnError(##class (Security.Applications ).Delete (name ))
185
+ Write !," Removed web application " _name
186
+ }
187
+ Quit
188
+ }
189
+
190
+ // These are the only things we want to coerce.
191
+ Set props (" AutheEnabled" )=0 // No auth methods enabled = impossible to use
192
+ Set props (" InbndWebServicesEnabled" )=0
193
+ Set props (" ServeFiles" )=0
194
+ Set props (" Enabled" )=1
195
+ Set props (" Name" )=name
196
+ Set props (" NameSpace" )=namespace
197
+ Set props (" Path" )=root
198
+ Set props (" Type" )=2
199
+ Set props (" Recurse" )=1
200
+ If create {
201
+ Write !," Creating web application: " _name _" ... "
202
+ $$$ThrowOnError(##class (Security.Applications ).Create (name ,.props ))
203
+ Write " done."
204
+ } ElseIf ##class (Security.Applications ).Exists (name ) {
205
+ Write !," Web application '" _name _" ' already exists."
206
+ $$$ThrowOnError(##class (Security.Applications ).Get (name ,.existingProps ))
207
+ Set changes = 0
208
+ Set key = " "
209
+ For {
210
+ Set key = $Order (props (key ),1 ,value )
211
+ Quit :key =" "
212
+ If (value '= $Get (existingProps (key ))) {
213
+ Write !," Changing " _key _" : " _$Get (existingProps (key ))_" -> " _value
214
+ Set changes = 1
215
+ }
216
+ }
217
+ If changes {
218
+ $$$ThrowOnError(##class (Security.Applications ).Modify (name ,.props ))
219
+ Write !," Web application '" _name _" ' updated."
220
+ } Else {
221
+ Write !," No changes made to web application."
222
+ }
223
+ }
224
+ }
225
+
226
+ ClassMethod HasNamespaceWebApp (Output webAppDirectory ) As %Boolean
227
+ {
228
+ Set webAppDirectory = $System .CSP .GetFileName (" /git/" _$Namespace _" /" )
229
+ If (webAppDirectory '= " " ) {
230
+ Set webAppDirectory = ##class (%Library.File ).NormalizeDirectory (webAppDirectory )
231
+ }
232
+ Quit (webAppDirectory '= " " )
233
+ }
234
+
163
235
Method OnAfterConfigure () As %Boolean
164
236
{
165
237
set defaultPromptFlag = $$$DisableBackupCharMask + $$$TrapCtrlCMask + $$$EnableQuitCharMask + $$$DisableHelpCharMask + $$$DisableHelpContextCharMask + $$$TrapErrorMask
@@ -186,6 +258,8 @@ Method OnAfterConfigure() As %Boolean
186
258
}
187
259
}
188
260
261
+ do ..ConfigureNamespaceWebApplication ()
262
+
189
263
set gitDir = ##class (%File ).NormalizeDirectory (..namespaceTemp )_" .git"
190
264
if '##class (%File ).DirectoryExists (gitDir ) {
191
265
set list (1 ) = " Initialize empty repo"
0 commit comments