forked from intersystems-community/DeepSeeWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DSW.Installer.xml
210 lines (180 loc) · 7.07 KB
/
DSW.Installer.xml
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
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2016.1 (Build 656U)" ts="2016-06-13 09:17:47">
<Class name="DSW.Installer">
<IncludeCode>%occInclude</IncludeCode>
<TimeChanged>64082,33185.871662</TimeChanged>
<TimeCreated>63986,58811.369564</TimeCreated>
<XData name="Install">
<Description>
You can see generated method in zsetup+1^App.Installer.1</Description>
<XMLNamespace>INSTALLER</XMLNamespace>
<Data><![CDATA[
<Manifest>
<IfNotDef Var="Namespace">
<Var Name="Namespace" Value="mdx2json"/>
<Log Text="Set namespace to ${Namespace}" Level="0"/>
</IfNotDef>
<If Condition='(##class(Config.Namespaces).Exists("${Namespace}")=0)'>
<Log Text="Creating namespace ${Namespace}" Level="0"/>
<Namespace Name="${Namespace}" Create="yes" Code="${Namespace}" Ensemble="0" Data="${Namespace}">
<Configuration>
<Database Name="${Namespace}" Dir="${MGRDIR}${Namespace}" Create="yes"/>
</Configuration>
</Namespace>
<Log Text="End Creating namespace ${Namespace}" Level="0"/>
</If>
<Role Name="AppRole" Description="Role to access and use the App" Resources="%DB_CACHESYS:RW,%Admin_Secure:U" />
<Namespace Name="${Namespace}" Create="no">
<CSPApplication Url="/dsw" Recurse="1" Directory="${CSPDIR}dsw" AuthenticationMethods="64" IsNamespaceDefault="true" Grant="AppRole" />
<Log Text="Copying web application files" Level="0"/>
<RunInstall Class="DSW.Installer" Method="CopyFiles"/>
</Namespace>
<If Condition='(##class(Config.Namespaces).Exists("%All")=0)'>
<Log Text="Creating namespace %All" Level="0"/>
<Namespace Name="%All" Create="yes" Code="CACHETEMP" Data="CACHETEMP" Ensemble="0">
<Configuration>
<Log Text="Mapping DSW and DSW.Addons packages to %All namespace" Level="0"/>
<ClassMapping From="${Namespace}" Package="DSW"/>
</Configuration>
</Namespace>
</If>
<If Condition='(##class(Config.Namespaces).Exists("%All")=1)'>
<Namespace Name="%All" Create="no" Code="CACHETEMP" Data="CACHETEMP" Ensemble="0">
<Configuration>
<Log Text="Mapping DSW and DSW.Addons packages to %All namespace" Level="0"/>
<ClassMapping From="${Namespace}" Package="DSW"/>
</Configuration>
</Namespace>
</If>
<Log Text="Mapping DSW and DSW.Addons packages to Samples namespace" Level="0"/>
<If Condition='##class(Config.Namespaces).Exists("Samples")'>
<Namespace Name="Samples" Create="no" Code="SAMPLES" Data="SAMPLES" Ensemble="0">
<Configuration>
<ClassMapping From="${Namespace}" Package="DSW"/>
</Configuration>
</Namespace>
</If>
</Manifest>
]]></Data>
</XData>
<Method name="setup">
<Description>
Entry point method, you need to call
At class compile time it generate Cach? ObjectScript code from the manifest
After that you can run this installer from a terminal:
Do ##class(App.Installer).setup(.pVars)</Description>
<Internal>1</Internal>
<ClassMethod>1</ClassMethod>
<CodeMode>objectgenerator</CodeMode>
<FormalSpec><![CDATA[&pVars,pLogLevel:%Integer=0,pInstaller:%Installer.Installer]]></FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
Quit ##class(%Installer.Manifest).%Generate(%compiledclass, %code, "Install")
]]></Implementation>
</Method>
<Method name="CopyFiles">
<Description>
Copy files from XData placed inside DSW.InstallerData class</Description>
<ClassMethod>1</ClassMethod>
<FormalSpec>pVars,pLogLevel,tInstaller</FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
s csp = tInstaller.Evaluate("${CSPDIR}")
s path = ##class(%File).NormalizeDirectory(csp _ "dsw")
// Get path seporator
s r = ##class(%File).NormalizeDirectory("\")
if ($find(r, "/") = 0) {
s r = "\"
} else {
s r = "/"
}
s i = 0
while 1 {
s id = "DSW.InstallerData||File" _ i
if (##class(%Dictionary.CompiledXData).%ExistsId(id) = 0) Q
s file = ##class(%Dictionary.CompiledXData).%OpenId(id)
s data = $zcvt(file.Data.Read(file.Data.Size), "O", "UTF8")
s fileName = ##class(%File).NormalizeFilename(path _ file.Description)
s fileName = $replace(fileName, "\", r)
s fileName = $replace(fileName, "/", r)
s dir = ##class(%File).ParentDirectoryName(fileName)
if ('##class(%File).DirectoryExists(dir)) {
d ##class(%File).CreateDirectory(dir)
}
d tInstaller.Log(pLogLevel, "Creating file", fileName)
s f = ##class(%Stream.FileBinary).%New()
d f.LinkToFile(fileName)
d f.Write($System.Encryption.Base64Decode(data))
d f.%Save()
/*s f = ##class(%File).%New(fileName)
d f.Open("NW")
d f.Write($System.Encryption.Base64Decode(data))
d f.Close()*/
s i = i + 1
}
]]></Implementation>
</Method>
<Method name="update">
<Description>
Update DSW from latest github release</Description>
<ClassMethod>1</ClassMethod>
<FormalSpec><![CDATA[&pVars]]></FormalSpec>
<Implementation><![CDATA[
w !,"Updating DSW"
s latest = "releases/latest"
s SSLConfig = "GitHub"
s ns = $Namespace
zn "%SYS"
s SSLConfig = "GitHub"
Do:'##class(Security.SSLConfigs).Exists(SSLConfig) ##class(Security.SSLConfigs).Create(SSLConfig)
zn ns
s req=##class(%Net.HttpRequest).%New()
s req.Https=1
s req.SSLConfiguration=SSLConfig
d req.SetHeader("Accept","application/vnd.github.v3+json")
w !,"Getting last release..."
Set req.Server="api.github.com"
Set req.Location = "repos/intersystems-ru/DeepSeeWeb/" _ latest
s st = req.Get()
Return:$$$ISERR(st) st
s st = ##class(%ZEN.Auxiliary.jsonProvider).%ConvertJSONToObject(req.HttpResponse.Data,,.release,1)
Return:$$$ISERR(st) st
Return:(req.HttpResponse.StatusCode = 404) $$$ERROR($$$GeneralError,"Repository doesn't exist OR you don't have access")
Return:((req.HttpResponse.StatusCode = 403) && (req.HttpResponse.GetHeader("X-RATELIMIT-REMAINING")=0)) $$$ERROR($$$GeneralError,"API rate limit exceeded. Try logging in.")
Return:(req.HttpResponse.StatusCode '= 200) $$$ERROR($$$GeneralError,"Received " _ req.HttpResponse.StatusCode _ " status, expected 200")
// Download release
s req=##class(%Net.HttpRequest).%New()
s req.Https=1
s req.SSLConfiguration=SSLConfig
d req.SetHeader("Accept","application/vnd.github.v3+json")
s url = release.assets.GetAt(1).%data("browser_download_url")
w !,"Last relese is: ",url
w !,"Downloading..."
s req.Server = "github.com"
s req.Location = $replace(url, "https://github.com/" , "")
s st = req.Get()
// Copy data into file
s temp = ##class(%File).TempFilename("xml")
s f = ##class(%File).%New(temp)
d f.Open("NW")
s data = req.HttpResponse.Data
if (($IsObject(data)) && (data.%IsA("%Stream.GlobalBinary"))) {
while 'data.AtEnd {
s str = data.Read(data.Size)
d f.Write(str)
}
} else {
d f.Write(data)
}
d f.Close()
w !,temp
// Import file
w !,"Import classes"
d $SYSTEM.OBJ.Load(temp, "c")
d ##class(%File).Delete(temp)
d ##class(DSW.Installer).setup()
w !,"Update was done successfully!"
]]></Implementation>
</Method>
</Class>
</Export>