forked from intersystems/FirstLook-REST
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Installer.cls
75 lines (64 loc) · 2.12 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
Class App.Installer
{
XData setup
{
<Manifest>
<Default Name="APPDIR" Dir="#{$system.Process.CurrentDirectory()}" />
<Default Name="SourceDir" Dir="${APPDIR}/src" />
<Default Name="NAMESPACE" Value="COFFEE" />
<Default Name="APPURL" Value="/csp/coffee" />
<Default Name="RESTURL" Value="/rest/coffeemakerapp" />
<Default Name="CSPPATH" Dir="${APPDIR}/csp" />
<Default Name="DBRESOURCE" Value="%DB_${NAMESPACE}" />
<Resource
Name="${DBRESOURCE}"
Description="CoffeeMaker"
Permission="RW"/>
<Namespace Name="${NAMESPACE}" Code="${NAMESPACE}-CODE" Data="${NAMESPACE}-DATA" Create="yes" Ensemble="no">
<Configuration>
<Database
Name="${NAMESPACE}-CODE"
Dir="${APPDIR}/db/code"
Resource="${DBRESOURCE}"
Create="yes" />
<Database
Name="${NAMESPACE}-DATA"
Dir="${APPDIR}/db/data"
Resource="${DBRESOURCE}"
Create="yes" />
<Import File="${SourceDir}" Flags="ck" Recurse="1"/>
</Configuration>
<CSPApplication
Url="${APPURL}"
Description=""
Directory="${CSPPATH}"
Resource=""
Grant="${DBRESOURCE}"
Recurse="1"
LoginClass=""
CookiePath="${APPURL}"
AuthenticationMethods="32" />
</Namespace>
<Invoke Class="App.Installer" Method="SetupREST" CheckStatus="1">
<Arg Value="${NAMESPACE}"/>
<Arg Value="${RESTURL}"/>
<Arg Value="${DBRESOURCE}"/>
<Arg Value="Demo.CoffeeMakerRESTServer"/>
</Invoke>
</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 SetupREST(pNameSpace As %String, pUrl As %String, pResource As %String, pClass As %String) As %Status
{
New $Namespace
Set $Namespace = "%SYS"
Set p("NameSpace") = pNameSpace
Set p("MatchRoles") = ":"_pResource
Set p("DispatchClass") = pClass
Quit ##class(Security.Applications).Create(pUrl, .p)
}
}