Skip to content

Commit fa30992

Browse files
all namespace mapping test (no need in writable CACHELIB anymore)
1 parent bbb02b4 commit fa30992

File tree

3 files changed

+48
-32
lines changed

3 files changed

+48
-32
lines changed

export/template.xml

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Export generator="Cache" version="25">
3-
<Class name="%WebTerminal.Engine">
3+
<Class name="WebTerminal.Engine">
44
<Description>
55
Cache WEB Terminal vX.X.X/*build.replace:pkg.version*/
66
This class is the core of web terminal application.</Description>
@@ -928,20 +928,23 @@ the client - it includes authorization key.</Description>
928928
/*
929929
* Find given CSPSessionCookie in WebTerminal auth global. If found, grant access.
930930
*/
931-
SET key = $ORDER(^WebTerminal.AuthUser(""))
931+
SET key = $ORDER(^%WebTerminal.AuthUser(""))
932932
WHILE (key '= "") {
933-
set lb = $GET(^WebTerminal.AuthUser(key))
933+
set lb = $GET(^%WebTerminal.AuthUser(key))
934934
if ((lb '= "") && (key = authKey)) {
935935
936936
// setup privileges
937937
set username = $LISTGET(lb, 1) // user name
938+
set ns = $namespace
939+
zn "%SYS"
938940
do ##class(Security.Users).Get(username, .userProps)
941+
zn ns
939942
continue:($order(userProps("")) = "")
940943
941944
set namespace = $case(namespace, "":userProps("NameSpace"), :namespace)
942945
set loginStatus = ##class(%SYSTEM.Security).Login(username) // login user
943946
944-
kill ^WebTerminal.AuthUser(key)
947+
kill ^%WebTerminal.AuthUser(key)
945948
946949
set ok = loginStatus
947950
@@ -950,10 +953,10 @@ the client - it includes authorization key.</Description>
950953
// kill "old" auth tickets
951954
set time = $LISTGET(lb, 2)
952955
if (time '= "") && ($SYSTEM.SQL.DATEDIFF("s", time, $h) > 100) { // if older than 100 sec
953-
kill ^WebTerminal.AuthUser(key)
956+
kill ^%WebTerminal.AuthUser(key)
954957
}
955958
956-
SET key = $ORDER(^WebTerminal.AuthUser(key))
959+
SET key = $ORDER(^%WebTerminal.AuthUser(key))
957960
}
958961
959962
if (namespace '= "") {
@@ -1102,15 +1105,16 @@ New connection established: require auth key, login and start client loop.</Desc
11021105
</Class>
11031106

11041107

1105-
<Class name="%WebTerminal.Installer">
1108+
<Class name="WebTerminal.Installer">
11061109
<Description>
11071110
Importing this class will install Cache WEB Terminal properly.</Description>
11081111
<CompileAfter>Engine,Router,StaticContent</CompileAfter>
11091112
<Super>%Projection.AbstractProjection</Super>
1113+
<TimeChanged>63898,2021.685611</TimeChanged>
11101114
<TimeCreated>63890,71053.144208</TimeCreated>
11111115

11121116
<Parameter name="DispatchClass">
1113-
<Default>%WebTerminal.Router</Default>
1117+
<Default>WebTerminal.Router</Default>
11141118
</Parameter>
11151119

11161120
<Projection name="Reference">
@@ -1128,7 +1132,7 @@ This method is invoked when a class is compiled.</Description>
11281132
zn:ns'="%SYS" "%SYS"
11291133
do ##class(Security.System).GetInstallationSecuritySetting(.security)
11301134
set cspProperties("AutheEnabled") = 32 // password by default, 64 for no password
1131-
set cspProperties("NameSpace") = "%SYS" // terminal works only in %SYS namespace, only in % package
1135+
set cspProperties("NameSpace") = ns // terminal works only in %SYS namespace, only in % package
11321136
set cspProperties("Description") = "A WEB application for Cache WEB Terminal."
11331137
set cspProperties("IsNameSpaceDefault") = 0
11341138
set cspProperties("DispatchClass") = ..#DispatchClass
@@ -1137,7 +1141,7 @@ This method is invoked when a class is compiled.</Description>
11371141
set tSC = ##class(Security.Applications).Create("/terminal", .cspProperties)
11381142
if $$$ISERR(tSC) throw ##class(%Installer.Exception).CreateFromStatus(tSC)
11391143
w !, "WEB application ""/terminal"" is created."
1140-
set ^SYS("Security", "CSP", "AllowClass", "/terminal/", ..#DispatchClass) = 1
1144+
//set ^SYS("Security", "CSP", "AllowClass", "/terminal/", ..#DispatchClass) = 1
11411145
} else {
11421146
do ##class(Security.Applications).Get("/terminal", .props)
11431147
if (props("DispatchClass") '= ..#DispatchClass) {
@@ -1148,7 +1152,6 @@ This method is invoked when a class is compiled.</Description>
11481152
w !, "WEB application ""/terminal"" already exists, so it is ready to use."
11491153
}
11501154
}
1151-
w !, "Mapping %WebTerminal package to %All namespace..."
11521155
set status = ##Class(Config.Namespaces).Get("%All")
11531156
if ($$$ISERR(status)) { // no namespace %All
11541157
w !, "Creating %All namespace..."
@@ -1163,20 +1166,22 @@ This method is invoked when a class is compiled.</Description>
11631166
do $SYSTEM.Status.DisplayError(status)
11641167
quit status
11651168
} else {
1166-
w !, "%All namespace created."
1169+
w !, "%All namespace is created."
11671170
}
11681171
}
1172+
w !, "Mapping %WebTerminal package into all namespaces:"
1173+
set mapTo = $LISTBUILD("%All", "SAMPLES", "DOCBOOK")
11691174
set Properties("Database") = "CACHETEMP"
1170-
set status=##Class(Config.MapPackages).Create("%All", "%WebTerminal", .Properties)
1171-
if ($$$ISERR(status)) {
1172-
do $SYSTEM.Status.DisplayError(status)
1173-
}
1174-
set Properties("Database") = "CACHELIB"
1175-
set status=##Class(Config.MapPackages).Create("%SYS", "%WebTerminal", .Properties)
1176-
if ($$$ISERR(status)) {
1177-
do $SYSTEM.Status.DisplayError(status)
1175+
set ptr = 0
1176+
while $LISTNEXT(mapTo, ptr, value) {
1177+
w " ", value
1178+
set status = ##Class(Config.MapPackages).Create(value, "WebTerminal", .Properties)
1179+
if ($$$ISERR(status)) {
1180+
do $SYSTEM.Status.DisplayError(status)
1181+
}
11781182
}
1179-
w !, "%WebTerminal package successfully mapped into %All namespace."
1183+
w ".", !, "Mapping complete."
1184+
w !, "WebTerminal package successfully mapped into all namespaces."
11801185
zn:ns'="%SYS" ns
11811186
quit $$$OK
11821187
]]></Implementation>
@@ -1203,6 +1208,17 @@ This method is invoked when a class is 'uncompiled'.</Description>
12031208
w !, "WEB application ""/terminal"" was successfully removed."
12041209
}
12051210
}
1211+
w !, "Unmapping %WebTerminal package from all namespaces:"
1212+
set mapTo = $LISTBUILD("%All", "SAMPLES", "DOCBOOK")
1213+
set ptr = 0
1214+
while $LISTNEXT(mapTo, ptr, value) {
1215+
w " ", value
1216+
set status = ##Class(Config.MapPackages).Delete(value, "WebTerminal")
1217+
if ($$$ISERR(status)) {
1218+
do $SYSTEM.Status.DisplayError(status)
1219+
}
1220+
}
1221+
w ".", !, "Unmapping complete."
12061222
kill ^%WebTerminal.Autocomplete
12071223
zn:ns'="%SYS" ns
12081224
QUIT $$$OK
@@ -1211,7 +1227,7 @@ This method is invoked when a class is 'uncompiled'.</Description>
12111227
</Class>
12121228

12131229

1214-
<Class name="%WebTerminal.Router">
1230+
<Class name="WebTerminal.Router">
12151231
<Description>
12161232
The REST interface: class that routes HTTP requests</Description>
12171233
<Super>%CSP.REST</Super>
@@ -1311,7 +1327,7 @@ Method writes application HTML.</Description>
13111327
<Implementation><![CDATA[
13121328
set cookie = %session.CSPSessionCookie
13131329
// Put the name of authorized user in a global to authorize WebSocket WebTerminal connection
1314-
set ^WebTerminal.AuthUser(cookie) = $LB(
1330+
set ^%WebTerminal.AuthUser(cookie) = $LB(
13151331
$LISTGET(%session.SecurityContext, 1), // username
13161332
$horolog // granting ticket date
13171333
)
@@ -1322,7 +1338,7 @@ Method writes application HTML.</Description>
13221338
</Class>
13231339

13241340

1325-
<Class name="%WebTerminal.StaticContent">
1341+
<Class name="WebTerminal.StaticContent">
13261342
<Description>
13271343
This class holds whole application static content like scripts and styles.
13281344
Do not edit this file - use external tool to generate it.</Description>
@@ -1336,7 +1352,7 @@ Write the contents of xData tag</Description>
13361352
<ReturnType>%Status</ReturnType>
13371353
<Implementation><![CDATA[
13381354
set Auth = $get(Auth, "")
1339-
set obj = ##class(%Dictionary.CompiledXData).%OpenId("%WebTerminal.StaticContent||"_Const)
1355+
set obj = ##class(%Dictionary.CompiledXData).%OpenId("WebTerminal.StaticContent||"_Const)
13401356
quit:(obj = "") $$$OK
13411357
set xdata = obj.Data
13421358
set status=##class(%XML.TextReader).ParseStream(xdata, .textreader)
@@ -1387,10 +1403,10 @@ Write the contents of xData tag</Description>
13871403

13881404
<Project name="WEBTerminal" LastModified="2015-12-06 12:10:07.906721">
13891405
<Items>
1390-
<ProjectItem name="%WebTerminal.Engine" type="CLS"></ProjectItem>
1391-
<ProjectItem name="%WebTerminal.Installer" type="CLS"></ProjectItem>
1392-
<ProjectItem name="%WebTerminal.Router" type="CLS"></ProjectItem>
1393-
<ProjectItem name="%WebTerminal.StaticContent" type="CLS"></ProjectItem>
1406+
<ProjectItem name="WebTerminal.Engine" type="CLS"></ProjectItem>
1407+
<ProjectItem name="WebTerminal.Installer" type="CLS"></ProjectItem>
1408+
<ProjectItem name="WebTerminal.Router" type="CLS"></ProjectItem>
1409+
<ProjectItem name="WebTerminal.StaticContent" type="CLS"></ProjectItem>
13941410
</Items>
13951411
</Project>
13961412
</Export>

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"title": "Cache WEB Terminal",
44
"description": "Web-based terminal emulator for Caché administering.",
55
"author": "ZitRo",
6-
"version": "3.0.1",
7-
"releaseNumber": 12,
6+
"version": "3.1.0",
7+
"releaseNumber": 13,
88
"repository": {
99
"type": "git",
1010
"url": "https://github.com/intersystems-ru/webterminal.git"

webSource/js/CacheWebTerminalServer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var CacheWebTerminalServer = function (CONTROLLER, WS_PROTOCOL, IP, PORT) {
1818
/**
1919
* @type {string}
2020
*/
21-
this.CACHE_CLASS_NAME = "%WebTerminal.Engine.cls";
21+
this.CACHE_CLASS_NAME = "WebTerminal.Engine.cls";
2222

2323
/**
2424
* @type {string}

0 commit comments

Comments
 (0)