@@ -97,7 +97,64 @@ do ##class(MDX2JSON.Installer).setup(.pVars)</Description>
9797 Set tSC = ##class(Security.Applications).Create("/"_Namespace, .cspProperties)
9898 Do tInstaller.PopNS()
9999 If $$$ISERR(tSC) Throw ##class(%Installer.Exception).CreateFromStatus(tSC)
100- quit $$$OK
100+ Quit $$$OK
101+ ]]> </Implementation >
102+ </Method >
103+
104+ <Method name =" DeleteNamespace" >
105+ <ClassMethod >1</ClassMethod >
106+ <FormalSpec >Namespace=$Namespace</FormalSpec >
107+ <ReturnType >%Status</ReturnType >
108+ <Implementation ><![CDATA[
109+ // Based on %CSP.UI.Portal.Dialog.NamespaceDelete:SaveData
110+ Try {
111+ Set st = ##class(MDX2JSON.AbstractREST).CheckNamespace(.Namespace)
112+ Return:$$$ISERR(st) st
113+
114+ Set ns=$Namespace
115+ zn:ns'="%SYS" "%SYS"
116+ Set st = ##class(Config.Namespaces).Delete(Namespace)
117+ Return:$$$ISERR(st) st
118+
119+ #; clear application
120+ /*&sql(DECLARE C1 CURSOR FOR SELECT Name,Path INTO :Name,:Path FROM Security.Applications)
121+ &sql(OPEN C1)
122+ &sql(FETCH C1)
123+
124+ While (SQLCODE = 0) {
125+ #; delete csp application from security
126+ Set st = ##Class(Security.Applications).Delete(Name)
127+ #; delete csp pages and physical path
128+ If (Path '= "") {
129+ #; delete csp pages in this directory
130+ Set RS = ##class(%ResultSet).%New("%File:FileSet")
131+ Do RS.Execute(cspPath,"*.csp")
132+ While RS.Next() {
133+ Do ##class(%File).Delete(RS.Get("Name"))
134+ }
135+ #; delete this directory - If there are no files left and no subdirectory, then it's deleted.
136+ Do ##class(%File).RemoveDirectory(Path)
137+ }
138+
139+ &sql(FETCH C1)
140+ }
141+
142+ &sql(CLOSE C1)*/
143+
144+ #; remove Ensemble namespace
145+ If ((##class(%Library.EnsembleMgr).IsEnsembleInstalled() || ##class(%Library.EnsembleMgr).IsHealthShareInstalled())) {
146+ Set tSC = ##class(%Library.EnsembleMgr).DisableNamespace(Namespace)
147+ Return:$$$ISERR(st) st
148+ }
149+
150+ #; remove the session data so System link (from locator bar) will not have the old namespace built into URL.
151+ Kill %session.Data("$NAMESPACE")
152+ } catch Error {
153+ Set st = er.AsStatus()
154+ }
155+ zn:((ns'="%SYS") && (ns'=Namespace)) ns
156+
157+ Quit st
101158]]> </Implementation >
102159</Method >
103160
0 commit comments