Skip to content

Commit 074e64a

Browse files
committed
Merge pull request #56 from intersystems-ru/Installer-improvements
Installer improvements
2 parents 1e33bdd + 0bf1299 commit 074e64a

1 file changed

Lines changed: 139 additions & 85 deletions

File tree

export/WebTerminal/Installer.xml

Lines changed: 139 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2015.1.1 (Build 505U)" ts="2016-02-15 12:28:08">
2+
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2015.1.1 (Build 505U)" ts="2016-02-19 21:03:21">
33
<Class name="WebTerminal.Installer">
44
<Description>
55
Importing this class will install Cache WEB Terminal properly.</Description>
66
<Super>%Projection.AbstractProjection</Super>
7-
<TimeChanged>63963,44872.55628</TimeChanged>
7+
<TimeChanged>63967,75756.360549</TimeChanged>
88
<TimeCreated>63890,71053.144208</TimeCreated>
99
<DependsOn>Common,Engine,Router,StaticContent,Autocomplete,Trace</DependsOn>
1010

@@ -19,46 +19,46 @@ Importing this class will install Cache WEB Terminal properly.</Description>
1919
<Method name="RegisterWebApplication">
2020
<ClassMethod>1</ClassMethod>
2121
<FormalSpec>name:%String,spec</FormalSpec>
22+
<ReturnType>%Status</ReturnType>
2223
<Implementation><![CDATA[
23-
set ns = $NAMESPACE
24-
zn:ns'="%SYS" "%SYS"
24+
new $Namespace
25+
set $Namespace = "%SYS"
26+
set st = $$$OK
2527
if ('##class(Security.Applications).Exists(name)) {
26-
w !, "Creating WEB application """_name_"""..."
27-
set tSC = ##class(Security.Applications).Create(name, .spec)
28-
if $$$ISERR(tSC) throw ##class(%Installer.Exception).CreateFromStatus(tSC)
29-
w !, "WEB application """_name_""" is created."
28+
write !,"Creating WEB application """_name_"""..."
29+
set st = ##class(Security.Applications).Create(name, .spec)
30+
write !, "WEB application """_name_""" is created."
3031
} else {
3132
do ##class(Security.Applications).Get(name, .props)
3233
if (props("DispatchClass") '= ..#DispatchClass) && (name = "/terminal") {
33-
w !, "WARNING! WEB application """_name_""" exists but does not refer to ",
34+
write !, "WARNING! WEB application """_name_""" exists but does not refer to ",
3435
..#DispatchClass, ".", !,
3536
"Please, set correct dispatch class for this application ",
3637
"or create a terminal WEB-application manually."
3738
} else {
38-
w !, "WEB application """_name_""" already exists, so it should be ready to use. If not - remove this application manually and recompile."
39+
write !, "WEB application """_name_""" already exists, so it should be ready to use. If not - remove this application manually and recompile."
3940
}
4041
}
41-
zn:ns'="%SYS" ns
42+
return st
4243
]]></Implementation>
4344
</Method>
4445

4546
<Method name="RemoveWebApplication">
4647
<ClassMethod>1</ClassMethod>
4748
<FormalSpec>name:%String</FormalSpec>
4849
<Implementation><![CDATA[
49-
set ns = $NAMESPACE
50-
zn:ns'="%SYS" "%SYS"
50+
new $Namespace
51+
set $Namespace = "%SYS"
5152
if (##class(Security.Applications).Exists(name)) {
5253
do ##class(Security.Applications).Get(name, .props)
5354
if (props("DispatchClass") '= ..#DispatchClass) && (name = "/terminal") {
54-
w !, "Won't delete WEB-application """_name_""" because it does not refer to dispatch class anymore."
55+
write !, "Won't delete WEB-application """_name_""" because it does not refer to dispatch class anymore."
5556
} else {
56-
w !, "Deleting WEB application """_name_"""..."
57+
write !, "Deleting WEB application """_name_"""..."
5758
do ##class(Security.Applications).Delete(name)
58-
w !, "WEB application """_name_""" was successfully deleted."
59+
write !, "WEB application """_name_""" was successfully deleted."
5960
}
6061
}
61-
zn:ns'="%SYS" ns
6262
]]></Implementation>
6363
</Method>
6464

@@ -69,58 +69,45 @@ This method is invoked when a class is compiled.</Description>
6969
<FormalSpec><![CDATA[cls:%String,&params]]></FormalSpec>
7070
<ReturnType>%Status</ReturnType>
7171
<Implementation><![CDATA[
72-
write !, "Installing WebTerminal application to " _ $NAMESPACE
73-
set ns = $NAMESPACE // ought to be package home namespace!
72+
new $Namespace
73+
set ns = $Namespace // ought to be package home namespace!
7474
set ^WebTerminal("HomeNamespace") = ns
75+
write !, "Installing WebTerminal application to " _ ns
7576
set dbdir = $$$defdir
76-
zn:ns'="%SYS" "%SYS"
77-
do ##class(Security.System).GetInstallationSecuritySetting(.security)
78-
set cspProperties("AutheEnabled") = 32 // password by default, 64 for no password
79-
set cspProperties("NameSpace") = ns // terminal works only in %SYS namespace, only in % package
77+
set $Namespace = "%SYS"
78+
79+
set cspProperties("AutheEnabled") = $$$AutheCache
80+
set cspProperties("NameSpace") = ns
8081
set cspProperties("Description") = "A WEB application for Cache WEB Terminal."
81-
set cspProperties("IsNameSpaceDefault") = 0
82+
set cspProperties("IsNameSpaceDefault") = $$$NO
8283
set cspProperties("DispatchClass") = ..#DispatchClass
83-
do ..RegisterWebApplication("/terminal", .cspProperties)
84-
set cspProperties("AutheEnabled") = 64
84+
set st = ..RegisterWebApplication("/terminal", .cspProperties)
85+
quit:$$$ISERR(st) st
86+
87+
set cspProperties("AutheEnabled") = $$$AutheUnauthenticated
8588
set cspProperties("Description") = "An application representing the open socket for /terminal application. Required since 2016.* Cache versions changed WebSocket behavior. PLEASE LEAVE THIS APPLICATION UNAUTHENTICATED, but do not worry: the socket won't accept anyone without the key."
8689
set cspProperties("DispatchClass") = ""
8790
set role = ..GetDBRole(dbdir)
8891
set cspProperties("MatchRoles")=":%DB_CACHESYS" _ $case($get(role)'="", 1: ":"_role, :"")
89-
do ..RegisterWebApplication("/terminalsocket", .cspProperties)
90-
set status = ##Class(Config.Namespaces).Get("%All")
91-
if ($$$ISERR(status)) { // no namespace %All
92-
w !, "Creating %All namespace..."
93-
set Properties("Globals") = "CACHETEMP"
94-
set Properties("Library") = "CACHELIB"
95-
set Properties("Routines") = "CACHETEMP"
96-
set Properties("SysGlobals") = "CACHESYS"
97-
set Properties("SysRoutines") = "CACHESYS"
98-
set Properties("TempGlobals") = "CACHETEMP"
99-
set status = ##Class(Config.Namespaces).Create("%All", .Properties)
100-
if ($$$ISERR(status)) {
101-
do $System.Status.DisplayError(status)
102-
quit status
103-
} else {
104-
w !, "%All namespace is created."
105-
}
92+
set st = ..RegisterWebApplication("/terminalsocket", .cspProperties)
93+
quit:$$$ISERR(st) st
94+
95+
set st = ..CreateAllNamespace()
96+
if ($$$ISERR(st)) {
97+
do $System.Status.DisplayError(st)
98+
} else {
99+
write !, "%All namespace is created."
106100
}
107-
w !, "Mapping %WebTerminal package into all namespaces:"
108-
set mapTo = $LISTBUILD("%All", "SAMPLES", "DOCBOOK")
109-
do ##Class(Config.Namespaces).Get("USER", .InstallNSProps)
110-
set Properties("Database") = $get(InstallNSProps("Routines"))
111-
set ptr = 0
112-
while $LISTNEXT(mapTo, ptr, value) {
113-
continue:(ns = value)
114-
w " ", value
115-
set status = ##Class(Config.MapPackages).Create(value, "WebTerminal", .Properties)
116-
if ($$$ISERR(status)) { do $SYSTEM.Status.DisplayError(status) }
117-
set status = ##Class(Config.MapGlobals).Create(value, "WebTerminal", .Properties)
118-
if ($$$ISERR(status)) { do $SYSTEM.Status.DisplayError(status) }
101+
102+
write !, "Mapping %WebTerminal package into all namespaces:"
103+
set st = ..Map(ns)
104+
if ($$$ISERR(st)) {
105+
do $System.Status.DisplayError(st)
106+
} else {
107+
write !, "WebTerminal package successfully mapped into all namespaces."
119108
}
120-
w ".", !, "Mapping complete."
121-
w !, "WebTerminal package successfully mapped into all namespaces."
122-
zn:ns'="%SYS" ns
123-
quit $$$OK
109+
110+
quit st
124111
]]></Implementation>
125112
</Method>
126113

@@ -131,34 +118,28 @@ This method is invoked when a class is 'uncompiled'.</Description>
131118
<FormalSpec><![CDATA[cls:%String,&params,recompile:%Boolean]]></FormalSpec>
132119
<ReturnType>%Status</ReturnType>
133120
<Implementation><![CDATA[
134-
write !, "Uninstalling WebTerminal application from " _ $NAMESPACE
135-
set ns = $NAMESPACE // has to be package home namespace!
136-
if ($get(^WebTerminal("HomeNamespace")) = "") {
137-
set msg = "Please, set ^WebTerminal(""HomeNamespace"") global equal to " _
138-
"the namespace WebTerminal was installed to before uninstalling."
139-
quit $$$ERROR($$$GeneralError, msg)
140-
} else {
141-
set ns = ^WebTerminal("HomeNamespace")
142-
}
143-
zn:ns'="%SYS" "%SYS"
121+
new $Namespace
122+
123+
set ns = $get(^WebTerminal("HomeNamespace"))
124+
set msg = "Please, set ^WebTerminal(""HomeNamespace"") global equal to " _
125+
"the namespace WebTerminal was installed to before uninstalling." _ $Namespace
126+
quit:'ns $$$ERROR($$$GeneralError, msg)
127+
write !, "Uninstalling WebTerminal application from "
128+
zn "%SYS"
144129
do ..RemoveWebApplication("/terminal")
145130
do ..RemoveWebApplication("/terminalsocket")
146-
w !, "Unmapping %WebTerminal package from all namespaces:"
147-
set mapTo = $LISTBUILD("%All", "SAMPLES", "DOCBOOK")
148-
set ptr = 0
149-
while $LISTNEXT(mapTo, ptr, value) {
150-
continue:(ns = value)
151-
w " ", value
152-
set status = ##Class(Config.MapPackages).Delete(value, "WebTerminal")
153-
if ($$$ISERR(status)) { do $SYSTEM.Status.DisplayError(status) }
154-
set status = ##Class(Config.MapGlobals).Delete(value, "WebTerminal")
155-
if ($$$ISERR(status)) { do $SYSTEM.Status.DisplayError(status) }
131+
132+
write !, "Unmapping %WebTerminal package from all namespaces:"
133+
set st = ..UnMap(ns)
134+
if ($$$ISERR(st)) {
135+
do $System.Status.DisplayError(st)
136+
} else {
137+
write !, "Unmapping complete."
156138
}
157-
w ".", !, "Unmapping complete."
158-
zn:ns'="%SYS" ns
159-
kill ^WebTerminal
160-
w !, "Global ^WebTerminal removed."
161-
QUIT $$$OK
139+
140+
kill:st ^WebTerminal
141+
write !, "Global ^WebTerminal removed."
142+
quit st
162143
]]></Implementation>
163144
</Method>
164145

@@ -168,7 +149,7 @@ This method is invoked when a class is 'uncompiled'.</Description>
168149
<ReturnType>%String</ReturnType>
169150
<Implementation><![CDATA[
170151
quit:'$d(directory) ""
171-
new $NAMESPACE
152+
new $Namespace
172153
set $Namespace = "%SYS"
173154
#dim db As SYS.Database
174155
set db=##class(SYS.Database).%OpenId(directory)
@@ -181,5 +162,78 @@ This method is invoked when a class is 'uncompiled'.</Description>
181162
quit role
182163
]]></Implementation>
183164
</Method>
165+
166+
<Method name="CreateAllNamespace">
167+
<ClassMethod>1</ClassMethod>
168+
<ReturnType>%Status</ReturnType>
169+
<Implementation><![CDATA[
170+
new $Namespace
171+
set $Namespace = "%SYS"
172+
set ns = "%All"
173+
set st = $$$OK
174+
if ('##Class(Config.Namespaces).Exists(ns)) {
175+
set Properties("Globals") = "CACHETEMP"
176+
set Properties("Library") = "CACHELIB"
177+
set Properties("Routines") = "CACHETEMP"
178+
set Properties("SysGlobals") = "CACHESYS"
179+
set Properties("SysRoutines") = "CACHESYS"
180+
set Properties("TempGlobals") = "CACHETEMP"
181+
set st = ##Class(Config.Namespaces).Create(ns, .Properties)
182+
}
183+
return st
184+
]]></Implementation>
185+
</Method>
186+
187+
<Method name="Map">
188+
<ClassMethod>1</ClassMethod>
189+
<FormalSpec>fromNS=""</FormalSpec>
190+
<ReturnType>%Status</ReturnType>
191+
<Implementation><![CDATA[
192+
new $Namespace
193+
set $Namespace = "%SYS"
194+
set st = $$$OK
195+
196+
set mapTo = $LISTBUILD("%All", "SAMPLES", "DOCBOOK")
197+
do ##Class(Config.Namespaces).Get(fromNS, .InstallNSProps)
198+
set Properties("Database") = $get(InstallNSProps("Routines"))
199+
set ptr = 0
200+
while $LISTNEXT(mapTo, ptr, namespace) {
201+
continue:(fromNS = namespace)
202+
write " ", namespace
203+
if ('##Class(Config.MapPackages).Exists(namespace, "WebTerminal")) {
204+
set st1 = ##Class(Config.MapPackages).Create(namespace, "WebTerminal", .Properties)
205+
}
206+
if ('##Class(Config.MapGlobals).Exists(namespace, "WebTerminal")) {
207+
set st2 = ##Class(Config.MapGlobals).Create(namespace, "WebTerminal", .Properties)
208+
}
209+
set st = $$$ADDSC(st,$$$ADDSC($get(st1,$$$OK),$get(st2,$$$OK)))
210+
}
211+
quit st
212+
]]></Implementation>
213+
</Method>
214+
215+
<Method name="UnMap">
216+
<ClassMethod>1</ClassMethod>
217+
<ReturnType>%Status</ReturnType>
218+
<Implementation><![CDATA[
219+
new $Namespace
220+
set $Namespace = "%SYS"
221+
set st = $$$OK
222+
223+
set mapTo = $LISTBUILD("%All", "SAMPLES", "DOCBOOK")
224+
set ptr = 0
225+
while $LISTNEXT(mapTo, ptr, namespace) {
226+
write " ", namespace
227+
if (##Class(Config.MapPackages).Exists(namespace, "WebTerminal")) {
228+
set st1 = ##Class(Config.MapPackages).Delete(namespace, "WebTerminal", .Properties)
229+
}
230+
if (##Class(Config.MapGlobals).Exists(namespace, "WebTerminal")) {
231+
set st2 = ##Class(Config.MapGlobals).Delete(namespace, "WebTerminal", .Properties)
232+
}
233+
set st = $$$ADDSC(st,$$$ADDSC($get(st1,$$$OK),$get(st2,$$$OK)))
234+
}
235+
quit st
236+
]]></Implementation>
237+
</Method>
184238
</Class>
185239
</Export>

0 commit comments

Comments
 (0)