-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathInstaller.cls
213 lines (187 loc) · 5.72 KB
/
Installer.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
Include %occInclude
Class App.Installer
{
XData setup
{
<Manifest>
<Default Name="NAMESPACE" Value="IRISAPP"/>
<Default Name="DBNAME" Value="IRISAPP"/>
<Default Name="APPPATH" Dir="/opt/irisapp" />
<Default Name="SOURCESPATH" Dir="${APPPATH}/src" />
<Default Name="CSPURL" Value="/csp/irisapp" />
<Default Name="RESOURCE" Value="%DB_${DBNAME}" />
<Default Name="RESTPATH" Value="/csp/irisapp/api" />
<Default Name="REST_UNAUTH_APPNAME" Value="/irisrad/unauth" />
</Manifest>
}
ClassMethod setup(ByRef pVars, pLogLevel As %Integer = 3, pInstaller As %Installer.Installer, pLogger As %Installer.AbstractLogger) As %Status [ CodeMode = objectgenerator, Internal ]
{
#; Let XGL document generate code for this method.
Quit ##class(%Installer.Manifest).%Generate(%compiledclass, %code, "setup")
}
ClassMethod SetAppProperties(pApp As %String, pPath As %String) As %Status
{
New $Namespace
Set $Namespace = "%SYS"
Set tSC = ##class(Security.Applications).Get(pApp, .webProperties)
If $$$ISERR(tSC) {
Quit tSC
}
Set webProperties("Path") = pPath
Set webProperties("Resource") = ""
Set webProperties("AutheEnabled") = 32
Set webProperties("AutoCompile") = 1
Set webProperties("ServeFiles") = 1
Set webProperties("iKnowEnabled") = 1
Set webProperties("DeepSeeEnabled") = 1
Set tSC = ##class(Security.Applications).Modify(pApp, .webProperties)
Quit tSC
}
ClassMethod CompileCSP(pApp As %String, pNamespace As %String) As %Status
{
New $Namespace
Set $Namespace = pNamespace
Set list(pApp_"/*.csp") = ""
Do $System.OBJ.CompileList(.list,"ck")
Quit $$$OK
}
/*
ClassMethod createRESTApp(appName As %String, pNamespace As %String) As %Status
{
#dim sc As %Status = $$$OK
New $Namespace
Set $Namespace = "%SYS"
If '##class(Security.Applications).Exists(appName) {
Set props("AutheEnabled") = $$$AutheUnauthenticated
Set props("NameSpace") = pNamespace
Set props("IsNameSpaceDefault") = $$$NO
Set props("DispatchClass") = "diashenrique.REST.Dispatch"
Set props("MatchRoles")=":%All"
Set sc = ##class(Security.Applications).Create(appName, .props)
}
Quit sc
}
*/
ClassMethod CreateFavorite() As %Status
{
New $Namespace
Set $Namespace = "IRISAPP"
Set status = ##class(diashenrique.util.Favorite).%AddFavorite("AnalyticsPortal","/csp/irisapp/analytics.csp")
Quit status
}
ClassMethod createRESTApp(pAppName As %String, pNamespace As %String, pDispatchClass As %String, pRoles As %String, pAutheEnabled As %Integer = 8192) As %Status
{
Set sc = $$$OK
Set originalNS = $NAMESPACE
Try {
New $NAMESPACE
Set $NAMESPACE = "%SYS"
#; Set props("AutheEnabled") = 8224
Set props("AutheEnabled") = pAutheEnabled
Set props("NameSpace") = pNamespace
Set props("IsNameSpaceDefault") = $$$NO
Set props("DispatchClass") = pDispatchClass
Set props("MatchRoles") = pRoles
If '##class(Security.Applications).Exists(pAppName) {
Set sc = ##class(Security.Applications).Create(pAppName, .props)
}
Set app = ##class(Security.Applications).%OpenId(pAppName)
Do app.MatchRoles.Clear()
Do app.MatchRoles.Insert(props("MatchRoles"))
Set sc = app.%Save()
}
Catch ex {
Set sc=ex.AsStatus()
}
Set $NAMESPACE = originalNS
Return sc
}
/// Grant access to all tables which must be accessed by unauthorized users
ClassMethod GrantTablesRoleUnAuth(pNamespace As %String = "%SYS", ByRef pRoleInfoArray) As %Status
{
Set sc = $$$OK
Set originalNS = $NAMESPACE
Try {
ZNspace pNamespace
For i=1:1:pRoleInfoArray {
Set stmt = ##class(%SQL.Statement).%New()
// GRANT * ON Data.Countries TO %DB_TEST3_APP
Set sql = "GRANT "_$LG(pRoleInfoArray(i), 1)_" ON "_$LG(pRoleInfoArray(i), 2)_" TO "_$LG(pRoleInfoArray(i), 3)
zw sql
$$$TOE(st, stmt.%Prepare(sql))
Set rs = stmt.%Execute()
Do rs.%Next()
Throw:((rs.%SQLCODE '= 0) && (rs.%SQLCODE '= 100)) ##class(%Exception.SQL).CreateFromSQLCODE(rs.%SQLCODE, %msg)
Kill rs
Kill stmt
}
}
Catch ex {
Set sc = ex.AsStatus()
}
ZNspace originalNS
Return sc
}
ClassMethod InstallZPM(pPackageName As %String, pNamespace As %String = "") As %Status
{
zw pPackageName,pNamespace
Set sc = $$$OK
Set originalNS = $NAMESPACE
Try {
If (pNamespace '= "") {
New $NAMESPACE
Set $NAMESPACE = pNamespace
}
ZPm "install "_pPackageName
}
Catch ex {
Set sc=ex.AsStatus()
}
zw sc
Set $NAMESPACE = originalNS
Return sc
}
ClassMethod EnableCSPApp(pCSPApp As %String, pNamespace As %String = "") As %Status
{
Set sc = $$$OK
Set originalNS = $NAMESPACE
Try {
If (pNamespace '= "") {
New $NAMESPACE
Set $NAMESPACE = pNamespace
}
Do EnableDeepSee^%SYS.cspServer(pCSPApp)
}
Catch ex {
Set sc=ex.AsStatus()
}
Set $NAMESPACE = originalNS
Return sc
}
ClassMethod EnableDelegatedAuth() As %Status
{
Set sc = $$$OK
set sc = ##Class(Security.System).Get("SYSTEM",.Properties)
zw sc
set Properties("AutheEnabled") = $ZB(Properties("AutheEnabled"), 8192, 7)
set sc = ##Class(Security.System).Modify("SYSTEM",.Properties)
Return sc
}
ClassMethod FixAppCSPPath() As %Status
{
Set sc = $$$OK
set webName = "/csp/irisapp"
set webProperties("Path") = "/opt/irisapp/src/csp/"
set sc = ##class(Security.Applications).Modify(webName, .webProperties)
Return sc
}
ClassMethod GrantRolesForUnauthAcess(pNamespace As %String) As %Status
{
Set sc = $$$OK
Kill roleInfoArray
Set roleInfoArray($I(roleInfoArray)) = $LB("SELECT,INSERT", "dc_irisrad_default.UserForm", "IRIS_RAD_UNAUTH")
Set roleInfoArray($I(roleInfoArray)) = $LB("SELECT,INSERT", "dc_irisrad_data.RADUser", "IRIS_RAD_UNAUTH")
Set sc = ##class(App.Installer).GrantTablesRoleUnAuth(pNamespace, .roleInfoArray)
Return sc
}
}