Loading...
Searching...
No Matches
registerkey.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Register a new licence key
4 @details
5
6 <h4> SAS Macros </h4>
7 @li mpeinit.sas
8 @li bitemporal_dataloader.sas
9 @li mp_abort.sas
10 @li mf_getuser.sas
11 @li mpe_getgroups.sas
12
13 @version 9.3
14 @author 4GL Apps Ltd
15 @copyright 4GL Apps Ltd. This code may only be used within Data Controller
16 and may not be re-distributed or re-sold without the express permission of
17 4GL Apps Ltd.
18
19 @test
20
21 echo '{"keyupload":[{"activation_key":"slfdjasfda;dslf","licence_key":"asdfasdlfkajsfdas"}]}'>in.json
22 sasjs request admin/registerkey -d in.json
23
24 @sasjslint {"maxLineLength": 107}
25
26**/
27
28%mpeinit()
29
30/* determine users group membership */
31%mpe_getgroups(user=%mf_getuser(),outds=work.groups)
32%global admin_check;
33proc sql;
34select count(*) into: admin_check
35 from groups where groupname="&mpeadmins";
36
37%mp_abort(iftrue= (&admin_check = 0)
38 ,mac=%str(&_program)
39 ,msg=%str(Only members of &mpeadmins may register a key)
40)
41
42%global licencekey activation_key;
43data _null_;
44 set work.keyupload;
45 call symputx('activation_key',activation_key);
46 call symputx('licencekey',licence_key);
47 call symputx('activlen',length(activation_key));
48 call symputx('liclen',length(licence_key));
49run;
50
51%mp_abort(iftrue= (&activlen< 10)
52 ,mac=%str(&_program)
53 ,msg=%str(Invalid activation_key)
54)
55%mp_abort(iftrue= (&liclen < 10)
56 ,mac=%str(&_program)
57 ,msg=%str(Invalid licencekey)
58)
59
60data work.loadme;
61 if 0 then set &mpelib..mpe_config;
62 VAR_SCOPE='DC';
63 VAR_NAME='DC_ACTIVATION_KEY';
64 VAR_VALUE=symget('activation_key');
65 VAR_ACTIVE=1;
66 output;
67 VAR_NAME='DC_LICENCE_KEY';
68 VAR_VALUE=symget('licencekey');
69 VAR_ACTIVE=1;
70 output;
71 keep VAR_: ;
72run;
73
74%bitemporal_dataloader(
75 tech_from=tx_from
76 ,tech_to = tx_to
77 ,base_lib=&mpelib
78 ,base_dsn=mpe_config
79 ,append_lib=WORK
80 ,append_dsn=loadme
81 ,PK= VAR_SCOPE VAR_NAME
82 ,ETLSOURCE=%str(&_program STP)
83 ,LOADTYPE=TXTEMPORAL
84 ,dclib=&mpelib
85)
86
87data work.return;
88 msg='SUCCESS';
89run;
90
91%webout(OPEN)
92%webout(OBJ,return)
93%webout(CLOSE)