|
| 1 | +Class Blocks.BlocksInstaller Extends %Projection.AbstractProjection |
| 2 | +{ |
| 3 | + |
| 4 | +Projection Reference As BlocksInstaller; |
| 5 | + |
| 6 | +Parameter CSPAPP As %String = "/blocks"; |
| 7 | + |
| 8 | +Parameter CSPAPPDESCRIPTION As %String = "A WEB application for Cache Blocks Explorer."; |
| 9 | + |
| 10 | +Parameter ROUTER As %String = "Blocks.Router"; |
| 11 | + |
| 12 | +/// This method is invoked when a class is compiled. |
| 13 | +ClassMethod CreateProjection(cls As %String, ByRef params) As %Status |
| 14 | +{ |
| 15 | + set ns=$namespace |
| 16 | + new $namespace |
| 17 | + znspace "%SYS" |
| 18 | + |
| 19 | + if ('##class(Security.Applications).Exists(..#CSPAPP)) { |
| 20 | + do ##class(Security.System).GetInstallationSecuritySetting(.security) |
| 21 | + set cspProperties("AutheEnabled") = $select((security="None"):64,1:32) |
| 22 | + set cspProperties("NameSpace") = ns |
| 23 | + set cspProperties("Description") = ..#CSPAPPDESCRIPTION |
| 24 | + set cspProperties("DispatchClass") = ..#ROUTER |
| 25 | + write !, "Creating WEB application """_..#CSPAPP_"""..." |
| 26 | + $$$ThrowOnError(##class(Security.Applications).Create(..#CSPAPP, .cspProperties)) |
| 27 | + write !, "WEB application """_..#CSPAPP_""" created." |
| 28 | + if ##class(%Studio.General).GetWebServerPort(,,,.url) { |
| 29 | + write !, "You can now open it with a link: "_url_$p(..#CSPAPP,"/",2,*)_"/" |
| 30 | + } |
| 31 | + } else { |
| 32 | + write !, "WEB application """_..#CSPAPP_""" already exists, so it is ready to use." |
| 33 | + } |
| 34 | + Quit $$$OK |
| 35 | +} |
| 36 | + |
| 37 | +/// This method is invoked when a class is 'uncompiled'. |
| 38 | +ClassMethod RemoveProjection(cls As %String, ByRef params, recompile As %Boolean) As %Status |
| 39 | +{ |
| 40 | + new $namespace |
| 41 | + znspace "%SYS" |
| 42 | + |
| 43 | + if (##class(Security.Applications).Exists(..#CSPAPP)) { |
| 44 | + w !, "Deleting WEB application """_..#CSPAPP_"""..." |
| 45 | + do ##class(Security.Applications).Delete(..#CSPAPP) |
| 46 | + w !, "WEB application """_..#CSPAPP_""" was successfully removed." |
| 47 | + } |
| 48 | + QUIT $$$OK |
| 49 | +} |
| 50 | + |
| 51 | +} |
0 commit comments