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 =" 2015-12-20 14:44:54 " >
2+ <Export generator =" Cache" version =" 25" zv =" Cache for Windows (x86-64) 2016.2 (Build 559U )" ts =" 2016-02-06 20:50:57 " >
33<Class name =" WebTerminal.Installer" >
44<Description >
55Importing this class will install Cache WEB Terminal properly.</Description >
66<Super >%Projection.AbstractProjection</Super >
7- <TimeChanged >63906,53063.112672 </TimeChanged >
7+ <TimeChanged >63954,74786.153524 </TimeChanged >
88<TimeCreated >63890,71053.144208</TimeCreated >
99<DependsOn >Common,Engine,Router,StaticContent</DependsOn >
1010
@@ -16,13 +16,60 @@ Importing this class will install Cache WEB Terminal properly.</Description>
1616<Type >Installer</Type >
1717</Projection >
1818
19+ <Method name =" RegisterWebApplication" >
20+ <ClassMethod >1</ClassMethod >
21+ <FormalSpec >name:%String,spec</FormalSpec >
22+ <Implementation ><![CDATA[
23+ set ns = $NAMESPACE
24+ zn:ns'="%SYS" "%SYS"
25+ 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."
30+ } else {
31+ do ##class(Security.Applications).Get(name, .props)
32+ if (props("DispatchClass") '= ..#DispatchClass) && (name = "/terminal") {
33+ w !, "WARNING! WEB application """_name_""" exists but does not refer to ",
34+ ..#DispatchClass, ".", !,
35+ "Please, set correct dispatch class for this application ",
36+ "or create a terminal WEB-application manually."
37+ } else {
38+ w !, "WEB application """_name_""" already exists, so it should be ready to use. If not - remove this application manually and recompile."
39+ }
40+ }
41+ zn:ns'="%SYS" ns
42+ ]]> </Implementation >
43+ </Method >
44+
45+ <Method name =" RemoveWebApplication" >
46+ <ClassMethod >1</ClassMethod >
47+ <FormalSpec >name:%String</FormalSpec >
48+ <Implementation ><![CDATA[
49+ set ns = $NAMESPACE
50+ zn:ns'="%SYS" "%SYS"
51+ if (##class(Security.Applications).Exists(name)) {
52+ do ##class(Security.Applications).Get(name, .props)
53+ if (props("DispatchClass") '= ..#DispatchClass) && (name = "/terminal") {
54+ w !, "Won't delete WEB-application """_name_""" because it does not refer to dispatch class anymore."
55+ } else {
56+ w !, "Deleting WEB application """_name_"""..."
57+ do ##class(Security.Applications).Delete(name)
58+ w !, "WEB application """_name_""" was successfully deleted."
59+ }
60+ }
61+ zn:ns'="%SYS" ns
62+ ]]> </Implementation >
63+ </Method >
64+
1965<Method name =" CreateProjection" >
2066<Description >
2167This method is invoked when a class is compiled.</Description >
2268<ClassMethod >1</ClassMethod >
2369<FormalSpec ><![CDATA[ cls:%String,¶ms]]> </FormalSpec >
2470<ReturnType >%Status</ReturnType >
2571<Implementation ><![CDATA[
72+ write !, "Installing WebTerminal application to " _ $NAMESPACE
2673 set ns = $NAMESPACE // has to be package home namespace!
2774 zn:ns'="%SYS" "%SYS"
2875 do ##class(Security.System).GetInstallationSecuritySetting(.security)
@@ -31,22 +78,11 @@ This method is invoked when a class is compiled.</Description>
3178 set cspProperties("Description") = "A WEB application for Cache WEB Terminal."
3279 set cspProperties("IsNameSpaceDefault") = 0
3380 set cspProperties("DispatchClass") = ..#DispatchClass
34- if ('##class(Security.Applications).Exists("/terminal")) {
35- w !, "Creating WEB application ""/terminal""..."
36- set tSC = ##class(Security.Applications).Create("/terminal", .cspProperties)
37- if $$$ISERR(tSC) throw ##class(%Installer.Exception).CreateFromStatus(tSC)
38- w !, "WEB application ""/terminal"" is created."
39- //set ^SYS("Security", "CSP", "AllowClass", "/terminal/", ..#DispatchClass) = 1
40- } else {
41- do ##class(Security.Applications).Get("/terminal", .props)
42- if (props("DispatchClass") '= ..#DispatchClass) {
43- w !, "WARNING! WEB application ""/terminal"" exists but does not refer to ",
44- DispatchClass, ".", !, "Please, set correct dispatch class for this application ",
45- "or create a terminal WEB-application manually."
46- } else {
47- w !, "WEB application ""/terminal"" already exists, so it is ready to use."
48- }
49- }
81+ do ..RegisterWebApplication("/terminal", .cspProperties)
82+ set cspProperties("AutheEnabled") = 64
83+ 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."
84+ set cspProperties("DispatchClass") = ""
85+ do ..RegisterWebApplication("/terminalsocket", .cspProperties)
5086 set status = ##Class(Config.Namespaces).Get("%All")
5187 if ($$$ISERR(status)) { // no namespace %All
5288 w !, "Creating %All namespace..."
@@ -91,20 +127,11 @@ This method is invoked when a class is 'uncompiled'.</Description>
91127<FormalSpec ><![CDATA[ cls:%String,¶ms,recompile:%Boolean]]> </FormalSpec >
92128<ReturnType >%Status</ReturnType >
93129<Implementation ><![CDATA[
130+ write !, "Uninstalling WebTerminal application from " _ $NAMESPACE
94131 set ns = $NAMESPACE // has to be package home namespace!
95132 zn:ns'="%SYS" "%SYS"
96- if (##class(Security.Applications).Exists("/terminal")) {
97- do ##class(Security.Applications).Get("/terminal", .props)
98- if (props("DispatchClass") '= ..#DispatchClass) {
99- w !, "Won't remove WEB-application ""/terminal"" because it does not refer to ",
100- "dispatch class anymore."
101- } else {
102- w !, "Deleting WEB application ""/terminal""..."
103- do ##class(Security.Applications).Delete("/terminal")
104- kill ^SYS("Security", "CSP", "AllowClass", "/terminal/", ..#DispatchClass)
105- w !, "WEB application ""/terminal"" was successfully removed."
106- }
107- }
133+ do ..RemoveWebApplication("/terminal")
134+ do ..RemoveWebApplication("/terminalsocket")
108135 w !, "Unmapping %WebTerminal package from all namespaces:"
109136 set mapTo = $LISTBUILD("%All", "SAMPLES", "DOCBOOK")
110137 set ptr = 0
@@ -124,4 +151,4 @@ This method is invoked when a class is 'uncompiled'.</Description>
124151]]> </Implementation >
125152</Method >
126153</Class >
127- </Export >
154+ </Export >
0 commit comments