/
Administrator.cfc
executable file
·3078 lines (2777 loc) · 104 KB
/
Administrator.cfc
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
component {
/**
** @hint constructor of the component
* @type type contex type, valid values are "server" or "web"
* @password password for current context
*/
function init(required string type,required string password, string remoteClients){
variables.type=arguments.type;
variables.password=arguments.password;
variables.remoteClients=!isNull(arguments.remoteClients)?arguments.remoteClients:"";
}
/**
* @hint returns Regional information about current context, this includes the locale, the timezone,a timeserver address and if the timeserver is used or not
*/
public struct function getRegional(){
admin
action="getRegional"
type="#variables.type#"
password="#variables.password#"
returnVariable="local.rtn";
return rtn;
}
/**
* @hint updates the regional settings of current context
* @timezone timezone used for this context, this can be for example "gmt+1" or "Europe/Zurich", use the function "getAvailableTimeZones" to get a list of available timezones
* @locale the locale used for this context, this can be for example "de_ch", use the function getAvailableLocales() to get a list of all possible locales.
* @timeserver timeserver used for this context, this can be for example "swisstime.ethz.ch"
* @usetimeserver defines if the timeserver is used or not
*/
public void function updateRegional(string timezone, string locale,string timeserver,boolean usetimeserver){
var regional="";
// check timezone
if(isNull(arguments.timezone) || isEmpty(arguments.timezone)) {
regional=getRegional();
arguments.timezone=regional.timezone;
}
// check locale
if(isNull(arguments.locale) || isEmpty(arguments.locale)) {
if(isSimpleValue(regional))regional=getRegional();
arguments.locale=regional.locale;
}
// check timeserver
if(isNull(arguments.timeserver) || isEmpty(arguments.timeserver)) {
if(isSimpleValue(regional))regional=getRegional();
arguments.timeserver=regional.timeserver;
}
// check usetimeserver
if(isNull(arguments.usetimeserver)) {
if(isSimpleValue(regional))regional=getRegional();
arguments.usetimeserver=regional.usetimeserver;
}
admin
action="updateRegional"
type="#variables.type#"
password="#variables.password#"
timezone="#arguments.timezone#"
locale="#arguments.locale#"
timeserver="#arguments.timeserver#"
usetimeserver="#arguments.usetimeserver#"
remoteClients="#variables.remoteClients#";
}
/**
* @hint remove web specific regional settings and set back to server context settings, this function only works with type "web" and is ignored with type "server"
*/
public void function resetRegional(){
if(variables.type != "web") {
throw "reset Regional function supports only in web";
}
admin
action="updateRegional"
type="#variables.type#"
password="#variables.password#"
timezone=""
locale=""
timeserver=""
usetimeserver=""
remoteClients="#variables.remoteClients#";
}
/**
* @hint returns charset information about current context
*/
public struct function getCharset(){
admin
action="getCharset"
type="#variables.type#"
password="#variables.password#"
returnVariable="local.rtn";
return rtn;
}
/**
* @hint updates the charset settings of current context
* @resourceCharset default charset used for read/write resources (cffile,filewrite ...)
* @templateCharset default charset used for read CFML Templates (cfm,cfc)
* @webCharset default charset used for the response stream and for reading data from request
*/
public void function updateCharset(string resourceCharset, string templateCharset,string webCharset){
var charset="";
// check resourceCharset
if(isNull(arguments.resourceCharset) || isEmpty(arguments.resourceCharset)) {
charset=getCharset();
arguments.resourceCharset=charset.resourceCharset;
}
// check templateCharset
if(isNull(arguments.templateCharset) || isEmpty(arguments.templateCharset)) {
if(isSimpleValue(charset))charset=getCharset();
arguments.templateCharset=charset.templateCharset;
}
// check webCharset
if(isNull(arguments.webCharset) || isEmpty(arguments.webCharset)) {
if(isSimpleValue(charset))charset=getCharset();
arguments.webCharset=charset.webCharset;
}
admin
action="updateCharset"
type="#variables.type#"
password="#variables.password#"
templateCharset="#arguments.templateCharset#"
webCharset="#arguments.webCharset#"
resourceCharset="#arguments.resourceCharset#"
remoteClients="#variables.remoteClients#";
}
/**
* @hint remove web specific charset settings and set back to server context settings, this function only works with type "web" and is ignored with type "server"
*/
public void function resetCharset(){
if(variables.type != "web") {
throw "reset resetCharset function supports only in web";
}
admin
action="updateCharset"
type="#variables.type#"
password="#variables.password#"
templateCharset=""
webCharset=""
resourceCharset=""
remoteClients="#variables.remoteClients#";
}
/**
* @hint returns output settings for current context
*/
public struct function getOutputSetting(){
admin
action="getOutputSetting"
type="#variables.type#"
password="#variables.password#"
returnVariable="local.rtn";
return rtn;
}
/**
* @hint updates output settings for current context
* @cfmlWriter Whitespace management in lucee Output settings
* @suppressContent suppressContent in lucee Output settings
* @allowCompression allowCompression in lucee Output settings
* @bufferOutput bufferOutput in lucee Output settings
*/
public void function updateOutputSetting( required string cfmlWriter, boolean suppressContent, boolean allowCompression, boolean bufferOutput ){
var existing = getOutputSetting();
admin
action="updateOutputSetting"
type="#variables.type#"
password="#variables.password#"
cfmlWriter="#arguments.cfmlWriter#"
suppressContent=isNull(arguments.suppressContent) || isEmpty(arguments.suppressContent) ? existing.suppressContent : arguments.suppressContent
allowCompression=isNull(arguments.allowCompression) || isEmpty(arguments.allowCompression) ? existing.allowCompression : arguments.allowCompression
bufferOutput=isNull(arguments.bufferOutput) || isEmpty(arguments.bufferOutput) ? existing.bufferOutput : arguments.bufferOutput
contentLength=""
remoteClients="#variables.remoteClients#";
}
/**
* @hint resets output settings for current context
*/
public void function resetOutputSetting() {
admin
action="updateOutputSetting"
type="#variables.type#"
password="#variables.password#"
cfmlWriter=""
suppressContent=""
showVersion=""
allowCompression=""
bufferOutput=""
contentLength=""
remoteClients="#variables.remoteClients#";
}
/**
* @hint returns all available timezones
*/
public query function getAvailableTimeZones(){
admin
type="#variables.type#"
password="#variables.password#"
returnVariable="local.rtn"
action="getTimeZones";
querySort(rtn,"id,display");
return rtn;
}
/**
* @hint returns all available locales
*/
public struct function getAvailableLocales(){
admin
type="#variables.type#"
password="#variables.password#"
returnVariable="local.rtn"
action="getLocales";
return rtn;
}
/**
* @hint returns Preserve single quotes (") settings
*/
public struct function getDatasourceSetting() {
admin
action="getDatasourceSetting"
type="#variables.type#"
password="#variables.password#"
returnVariable="local.dbSetting";
return local.dbSetting;
}
/**
* @hint update general datasource settings
* @psq if set to true, lucee preserves all single quotes within a query tag and escapes them
*/
public void function updateDatasourceSetting(boolean psq ){
var existing = getDatasourceSetting();
admin
action="updatePSQ"
type="#variables.type#"
password="#variables.password#"
psq=isNull(arguments.psq) || isEmpty(arguments.psq) ? existing.psq : arguments.psq
remoteClients="#variables.remoteClients#";
}
/**
* @hint resets the Preserve single quotes setting
*/
public void function resetDatasourceSetting(){
admin
action="updatePSQ"
type="#variables.type#"
password="#variables.password#"
psq=""
remoteClients="#variables.remoteClients#";
}
/**
* @hint returns the all the datasources defined for current context
*/
public query function getDatasources(){
admin
action="getDatasources"
type="#variables.type#"
password="#variables.password#"
returnVariable="local.datasources";
return local.datasources;
}
/**
* @hint returns the datasource information for for current context
* @name Specifies the name of the datasource
*/
public struct function getDatasource( required string name ){
admin
action="getDatasource"
type="#variables.type#"
password="#variables.password#"
name="#arguments.name#"
returnVariable="local.rtn";
return rtn;
}
/**
* @hint updates a specific datasource defined for current context
* @name name of the datasouce to be updated
* @type type of the datasource to be updated
* @newName target name to be replaced with current datasource name
* @host Host name where the database server is located
* @database Name of the database to connect
* @port The port to connect the database
* @timezone timezone of the database server
* @username The username for the database
* @password The password for the database
* @ConnectionLimit Restricts the maximum number of simultaneous connections at one time
* @ConnectionTimeout To define a time in minutes for how long a connection is kept alive before it will be closed
* @metaCacheTimeout To define how long Stored Procedures Meta Data are stored in cache
* @blob Enable binary large object retrieval (BLOB)
* @clob Enable long text retrieval (CLOB)
* @validate Validate the connection before use (only works with JDBC 4.0 Drivers)
* @allowedSelect allow database permission for select
* @allowedInsert allow database permission for insert
* @allowedUpdate allow database permission for update
* @allowedDelete allow database permission for delete
* @allowedAlter allow database permission for alter
* @allowedDrop allow database permission for drop
* @allowedRevoke allow database permission for revoke
* @allowedCreate allow database permission for create
* @allowedGrant allow database permission for grant
* @storage Allow to use this datasource as client/session storage.
* @customUseUnicode Should the driver use Unicode character encodings when handling strings?
* @customCharacterEncoding Should only be used when the driver can't determine the character set mapping, or you are trying to 'force' the driver to use a character set that MySQL either doesn't natively support (such as UTF-8)If it is set to true, what character encoding should the driver use when dealing with strings?
* @customUseOldAliasMetadataBehavior Should the driver use the legacy behavior for "AS" clauses on columns and tables, and only return aliases (if any) rather than the original column/table name? In 5.0.x, the default value was true.
* @customAllowMultiQueries Allow the use of ";" to delimit multiple queries during one statement
* @customZeroDateTimeBehavior What should happen when the driver encounters DATETIME values that are composed entirely of zeroes (used by MySQL to represent invalid dates)? Valid values are "exception", "round" and "convertToNull"
* @customAutoReconnect Should the driver try to re-establish stale and/or dead connections?
* @customJdbcCompliantTruncation If set to false then values for table fields are automatically truncated so that they fit into the field.
* @customTinyInt1isBit if set to "true" (default) tinyInt(1) is converted to a bit value otherwise as integer.
* @customUseLegacyDatetimeCode Use code for DATE/TIME/DATETIME/TIMESTAMP handling in result sets and statements
* @verify whether connection needs to be verified
*/
public void function updateDatasource(
required string name,
required string type,
required string newName,
required string host,
required string database,
required numeric port,
required string username,
required string password,
string timezone="",
numeric ConnectionLimit=-1,
numeric ConnectionTimeout=0,
numeric metaCacheTimeout=60000,
boolean blob=false,
boolean clob=false,
boolean validate=false,
boolean storage=false,
boolean verify=false,
boolean allowedSelect=false,
boolean allowedInsert=false,
boolean allowedUpdate=false,
boolean allowedDelete=false,
boolean allowedAlter=false,
boolean allowedDrop=false,
boolean allowedRevoke=false,
boolean allowedCreate=false,
boolean allowedGrant=false,
boolean customUseUnicode=false,
string customCharacterEncoding=false,
boolean customUseOldAliasMetadataBehavior=false,
boolean customAllowMultiQueries=false,
string customZeroDateTimeBehavior=false,
boolean customAutoReconnect=false,
boolean customJdbcCompliantTruncation=false,
boolean customTinyInt1isBit=false,
boolean customUseLegacyDatetimeCode=false
){
var driverNames=structnew("linked");
driverNames=ComponentListPackageAsStruct("lucee-server.admin.dbdriver",driverNames);
driverNames=ComponentListPackageAsStruct("lucee.admin.dbdriver",driverNames);
driverNames=ComponentListPackageAsStruct("dbdriver",driverNames);
var driver=createObject("component", drivernames[ arguments.type ]);
var custom=structNew();
loop collection="#arguments#" item="key"{
if(findNoCase("custom",key) EQ 1){
l=len(key);
custom[mid(key,8,l-8+1)]=arguments[key];
}
}
if( arguments.type == "MSSQL" ){
custom["databaseName"] = arguments.database;
}
admin
action="updateDatasource"
type="#variables.type#"
password="#variables.password#"
id="#isNull(driver.getId)?'':driver.getId()#"
classname="#driver.getClass()#"
dsn="#driver.getDSN()#"
customParameterSyntax="#isNull(driver.customParameterSyntax)?nullValue():driver.customParameterSyntax()#"
literalTimestampWithTSOffset="#isNull(driver.literalTimestampWithTSOffset)?false:driver.literalTimestampWithTSOffset()#"
alwaysSetTimeout="#isNull(driver.alwaysSetTimeout)?false:driver.alwaysSetTimeout()#"
name="#arguments.name#"
newName="#arguments.newName#"
host="#arguments.host#"
database="#arguments.database#"
port="#arguments.port#"
timezone="#arguments.timezone#"
dbusername="#arguments.username#"
dbpassword="#arguments.password#"
connectionLimit="#arguments.connectionLimit#"
connectionTimeout="#arguments.connectionTimeout#"
metaCacheTimeout="#arguments.metaCacheTimeout#"
blob="#getArguments(arguments, 'blob',false)#"
clob="#getArguments(arguments, 'clob',false)#"
validate="#getArguments(arguments, 'validate',false)#"
storage="#getArguments(arguments, 'storage',false)#"
allowed_select="#getArguments(arguments, 'allowedSelect',false)#"
allowed_insert="#getArguments(arguments, 'allowedInsert',false)#"
allowed_update="#getArguments(arguments, 'allowedUpdate',false)#"
allowed_delete="#getArguments(arguments, 'allowedDelete',false)#"
allowed_alter="#getArguments(arguments, 'allowedAlter',false)#"
allowed_drop="#getArguments(arguments, 'allowedDrop',false)#"
allowed_revoke="#getArguments(arguments, 'allowedRevoke',false)#"
allowed_create="#getArguments(arguments, 'allowedCreate',false)#"
allowed_grant="#getArguments(arguments, 'allowedGrant',false)#"
verify="#arguments.verify#"
custom="#custom#"
dbdriver="#arguments.type#"
remoteClients="#variables.remoteClients#";
}
/**
* @hint removes a specific datasource defined for current context
* @dsn name of the datasource to be removed from current context
*/
public void function removeDatasource( required string dsn ){
admin
action="removeDatasource"
type="#variables.type#"
password="#variables.password#"
name="#arguments.dsn#"
remoteClients="#variables.remoteClients#";
}
/**
* @hint verifies whether it is datasource or not
* @name name of the datasource to be verified
* @dbusername username of the database
* @dbpassword password of the database
*/
public void function verifyDatasource( required string name, required string dbusername, required string dbpassword ){
admin
action="verifyDatasource"
type="#variables.type#"
password="#variables.password#"
name="#arguments.name#"
dbusername="#arguments.dbusername#"
dbpassword="#arguments.dbpassword#";
}
/**
* @hint returns the list of datasource driver details
*/
public query function getDatasourceDriverList(){
admin
action="getDatasourceDriverList"
type="#variables.type#"
password="#variables.password#"
returnVariable="local.rtn";
return rtn;
}
/**
* @hint returns a list mail servers defined for current context
*/
public query function getMailservers(){
admin
action="getMailservers"
type="#variables.type#"
password="#variables.password#"
returnVariable="local.mailservers";
return local.mailservers;
}
/**
* @hint updates a specific mail server defined for current context
* @host Mail server host name (for example smtp.gmail.com).
* @port Port of the mail server (for example 587).
* @username Username of the mail server.
* @password Password of the mail server.
* @tls Enable Transport Layer Security.
* @ssl Enable secure connections via SSL.
* @life Overall timeout for the connections established to the mail server.
* @idle Idle timeout for the connections established to the mail server.
*/
public void function updateMailServer( required string host, required string port, string username="", string password="", boolean tls=false, boolean ssl=false, timespan life=CreateTimeSpan(0, 0, 1, 0), timespan idle=CreateTimeSpan(0, 0, 0, 10) ){
var mailServers = getMailservers();
if( structKeyExists(arguments, 'username') && arguments.username == '' ){
query name="existing" dbtype="query"{
echo("SELECT * FROM mailservers WHERE hostName = '#arguments.host#' and port = '#arguments.port#' ")
}
} else{
query name="existing" dbtype="query"{
echo("SELECT * FROM mailservers WHERE hostName = '#arguments.host#' and port = '#arguments.port#' and username = '#arguments.username#' ")
}
}
admin
action="updateMailServer"
type="#variables.type#"
password="#variables.password#"
hostname="#arguments.host#"
dbusername=isNull(arguments.username) || isEmpty(arguments.username) ? existing.username : arguments.username
dbpassword=isNull(arguments.password) || isEmpty(arguments.password) ? existing.password : arguments.password
life=isNull(arguments.life) || isEmpty(arguments.life) ? existing.life : arguments.life
idle=isNull(arguments.idle) || isEmpty(arguments.idle) ? existing.idle : arguments.idle
port="#arguments.port#"
id="new"
tls=isNull(arguments.tls) || isEmpty(arguments.tls) ? existing.tls : arguments.tls
ssl=isNull(arguments.ssl) || isEmpty(arguments.ssl) ? existing.ssl : arguments.ssl
remoteClients="#variables.remoteClients#";
}
/**
* @hint verifies whether it is mail server or not
* @hostname name of the host server to be verified
* @port port number of the host
* @mailusername username of the mail
* @mailpassword password of the mail
*/
public void function verifyMailServer( required string hostname, required string port, required string mailusername, required string mailpassword ){
admin
action="verifyMailServer"
type="#variables.type#"
password="#variables.password#"
hostname="#arguments.hostname#"
port="#arguments.port#"
mailusername="#arguments.mailusername#"
mailpassword="#arguments.mailpassword#";
}
/**
* @hint removes a specific mailserver defined for current context.
* @host hostname for the mail server to be removed.
* @username username of the mail server to be removed.
*/
public void function removeMailServer( required string host, required string username ){
admin
action="removeMailServer"
type="#variables.type#"
password="#variables.password#"
hostname="#arguments.host#"
username="#arguments.username#"
remoteClients="#variables.remoteClients#";
}
/**
* @hint returns mail settings for current context.
*/
public struct function getMailSetting(){
admin
action="getMailSetting"
type="#variables.type#"
password="#variables.password#"
returnVariable="local.mail";
return local.mail;
}
/**
* @hint updates the mail settings for current context
* @defaultEncoding Default encoding used for mail servers
* @spoolenable If enabled the mails are sent in a background thread and the main request does not have to wait until the mails are sent.
* @timeout Time in seconds that the Task Manager waits to send a single mail, when the time is reached the Task Manager stops the thread and the mail gets moved to unsent folder, where the Task Manager will pick it up later to try to send it again.
*/
public void function updateMailSetting( string defaultEncoding="UTF-8", boolean spoolEnable, numeric timeOut ){
var existing = getMailSetting();
admin
action="updateMailSetting"
type="#variables.type#"
password="#variables.password#"
spoolEnable=isNull(arguments.spoolEnable) || isEmpty(arguments.spoolEnable) ? existing.spoolEnable : arguments.spoolEnable
timeout=isNull(arguments.timeout) || isEmpty(arguments.timeout) ? existing.timeout : arguments.timeout
defaultEncoding=isNull(arguments.defaultEncoding) || isEmpty(arguments.defaultEncoding) ? existing.defaultEncoding : arguments.defaultEncoding
remoteClients="#variables.remoteClients#";
}
/**
* @hint resets the mail settings for current context
*/
public void function resetMailSetting(){
admin
action="updateMailSetting"
type="#variables.type#"
password="#variables.password#"
spoolEnable=""
timeout=""
defaultEncoding=""
remoteClients="#variables.remoteClients#";
}
/**
* @hint returns the list of mappings defined for current context
*/
public query function getMappings(){
admin
action="getMappings"
type="#variables.type#"
password="#variables.password#"
returnVariable="local.mappings";
return local.mappings;
}
/**
* @hint returns the details about mapping
* @virtual specifies the virtual name for the mapping
*/
public struct function getMapping( required string virtual ){
admin
action="getMapping"
type="#variables.type#"
password="#variables.password#"
virtual = "#arguments.virtual#"
returnVariable="local.providers";
return providers;
}
/**
* @hint updates/inserts a specific mapping for current context
* @virtual virtual name for the mapping
* @physical physical path for the mapping
* @archive archive path for the mapping, if needed.
* @primary type of mapping ( physical/archive )
* @inspect type of inspection for the mapping(never/once/always/"").
*/
public void function updateMapping(required string virtual, string physical=nullValue(),
string archive=nullValue(), string primary=nullValue(), string inspect=nullValue()) {
// get default values
if(isNull(data.physical) || isNull(data.archive) || isNull(data.primary) || isNull(data.inspect)) {
var done=false;
try {
var mapping = getMapping(arguments.virtual);
if(isNull(arguments.physical))arguments.physical=mapping.physical;
if(isNull(arguments.archive))arguments.archive=mapping.archive;
if(isNull(arguments.primary))arguments.primary=mapping.primary;
if(isNull(arguments.inspect))arguments.inspect=mapping.inspect;
done=true;
}
catch(e) { // throws an exception when not exist yet
}
}
if(!done) { // throws an exception when not exist yet
if(isNull(arguments.physical))arguments.physical="";
if(isNull(arguments.archive))arguments.archive="";
if(isNull(arguments.primary))arguments.physical="";
if(isNull(arguments.inspect))arguments.inspect="";
}
admin
action="updateMapping"
type=variables.type
password=variables.password
virtual=arguments.virtual
physical=arguments.physical
archive=arguments.archive
primary=arguments.primary
inspect=arguments.inspect
toplevel=true
remoteClients=variables.remoteClients;
}
/**
* @hint removes a mapping defined in current context
* @virtual virtual name for the mapping to be removed.
*/
public void function removeMapping(required string virtual){
admin
action="removeMapping"
type="#variables.type#"
password="#variables.password#"
virtual="#arguments.virtual#"
remoteClients="#variables.remoteClients#";
}
/**
* @hint compiles the mapping for any errors
* @virtual virtual name for the mapping to be compiled.
*/
public void function compileMapping(required string virtual, boolean stopOnError=true){
admin
action="compileMapping"
type="#variables.type#"
password="#variables.password#"
virtual="#arguments.virtual#"
stoponerror="#stopOnError#"
remoteClients="#variables.remoteClients#";
}
/**
* @hint compiles the CTmapping for any errors
* @virtual virtual name for the CTmapping to be compiled.
*/
public void function compileCTMapping(required string virtual){
admin
action="compileCTMapping"
type="#variables.type#"
password="#variables.password#"
virtual="#arguments.virtual#"
remoteClients="#variables.remoteClients#";
}
/**
* @hint compiles the component mapping for any errors
* @virtual virtual name for the component mapping to be compiled.
*/
public void function compileComponentMapping(required string virtual){
admin
action="compileComponentMapping"
type="#variables.type#"
password="#variables.password#"
virtual="#arguments.virtual#"
remoteClients="#variables.remoteClients#";
}
/**
* @hint creates new archieve for the mapping
* @virtual virtual name for the mapping.
* @addCFMLFile Add all CFML Source Templates as well (.cfm,.cfc,.cfml).
* @addNonCFMLFile Add all Non CFML Source Templates as well (.js,.css,.gif,.png ...)
*/
public void function createArchiveFromMapping(required string virtual, required string target, boolean addCFMLFile=true, boolean addNonCFMLFile=true){
var ext="lar";
var filename=arguments.virtual;
filename=mid(filename,2,len(filename));
if(len(filename)){
filename="archive-"&filename&"."&ext;
}else{
filename="archive-root."&ext;
}
filename=Replace(filename,"/","-","all");
var target=expandPath("#cgi.context_path#/lucee/"&filename);
count=0;
while(fileExists(target)){
count=count+1;
target="#cgi.context_path#/lucee/"&filename;
target=replace(target,'.'&ext,count&'.'&ext);
target=expandPath(target);
}
admin
action="createArchive"
type="#variables.type#"
password="#variables.password#"
file="#arguments.target#"
virtual="#arguments.virtual#"
addCFMLFiles="#arguments.addCFMLFile#"
addNonCFMLFiles="#arguments.addNonCFMLFile#"
append="true"
remoteClients="#variables.remoteClients#";
// downloadFile(arguments.target);
}
/**
* @hint returns the list of custom tag mappings
*/
public query function getCustomTagMappings(){
admin
action="getCustomTagMappings"
type="#variables.type#"
password="#variables.password#"
returnVariable="local.providers";
return providers;
}
/**
* @hint returns the list of extensions for current context.
*/
public query function getExtensions(){
admin
action="getRHExtensions"
type="#variables.type#"
password="#variables.password#"
returnVariable="local.extensions";
return local.extensions;
}
/**
* @hint returns the extension Info
*/
public struct function getExtensionInfo(){
admin
action="getExtensionInfo"
type="#variables.type#"
password="#variables.password#"
returnVariable="local.info";
return info;
}
/**
* @hint updates(install/upgrade/downgrade) a specific extension.
* @id id of the extension
* @version version of the extension
*/
public void function updateExtension(required string id , string version ) {
if(isValid('uuid',id)) {
if(!isNull(arguments.version) && !isEmpty(arguments.version)) {
admin
action="updateRHExtension"
type=variables.type
password=variables.password
id=arguments.id
version=arguments.version;
}
else {
admin
action="updateRHExtension"
type=variables.type
password=variables.password
id=arguments.id;
}
}
else {
admin
action="updateRHExtension"
type=variables.type
password=variables.password
source=arguments.id;
}
}
/**
* @hint removes(uninstall) a specific extension.
* @id id of the extension to be removed
*/
public void function removeExtension( required string id ){
admin
action="removeRHExtension"
type="#variables.type#"
password="#variables.password#"
id="#arguments.id#";
}
/**
* @hint returns the list of server extension
*/
public query function getServerExtensions(){
admin
action="getRHServerExtensions"
type="#variables.type#"
password="#variables.password#"
returnVariable="local.rtn";
return rtn;
}
/**
* @hint returns the details about local extension
* @id specifies the id of local extension
*/
public struct function getLocalExtension( required string id ){
admin
action="getLocalExtension"
type="#variables.type#"
password="#variables.password#"
id="#arguments.id#"
returnVariable="local.rtn";
return rtn;
}
/**
* @hint returns the list of local extensions
*/
public query function getLocalExtensions(){
admin
action="getLocalExtensions"
type="#variables.type#"
password="#variables.password#"
returnVariable="local.rtn";
return rtn;
}
/**
* @hint returns the list of extension providers for current context.
*/
public query function getExtensionProviders(){
admin
action="getRHExtensionProviders"
type="#variables.type#"
password="#variables.password#"
returnVariable="local.providers";
return local.providers;
}
/**
* @hint verifies whether it is an extension provider or not
* @url URL to the Extension Provider (Example: http://www.myhost.com)
*/
public void function verifyExtensionProvider( required string url ){
admin
action="verifyExtensionProvider"
type="#variables.type#"
password="#variables.password#"
url="#arguments.url#";
}
/**
* @hint updates extension provider for current context.
* @url URL to the Extension Provider (Example: http://www.myhost.com)
*/
public void function updateExtensionProvider( required string url ){
admin
action="updateRHExtensionProvider"
type="#variables.type#"
password="#variables.password#"
url="#trim(arguments.url)#";
}
/**
* @hint removes the extension provider for current context.
* @url URL to the Extension Provider (Example: http://www.myhost.com)
*/
public void function removeExtensionProvider( required string url ){
admin
action="removeRHExtensionProvider"
type="#variables.type#"
password="#variables.password#"
url="#trim(arguments.url)#";
}
/**
* @hint returns the ORM settings
*/
public struct function getORMSetting(){
admin
action="getORMSetting"
type="#variables.type#"
password="#variables.password#"
returnVariable="local.rtn";
return rtn;
}
/**
* @hint updates ORM settings
* @autoGenMap Specifies whether Lucee should automatically generate mapping for the persistent CFCs.
* @eventHandling Specifies whether ORM Event callbacks should be given.
* @flushAtRequestEnd Specifies whether ormflush should be called automatically at request end.
* @logSQL Specifies whether the SQL queries that are executed by ORM will be logged.
* @saveMapping Specifies whether the generated Hibernate mapping file has to be saved to file system.
* @useDBForMapping Specifies whether the database has to be inspected to identify the missing information required to generate the Hibernate mapping.
* @catalog Specifies the default Catalog that should be used by ORM.
* @cfcLocation Specifies the directory that should be used to search for persistent CFCs to generate the mapping.
* @dbCreate Specifies whether Lucee should automatically generate mapping for the persistent CFCs, possible values are [none,update,dropcreate]
* @schema Specifies the default Schema that should be used by ORM.
*/
public void function updateORMSetting( boolean autoGenMap, boolean eventHandling, boolean flushAtRequestEnd, boolean logSQL, boolean, boolean useDBForMapping, string catalog, string cfcLocation, string dbCreate, string schema ){
var existing = getORMSetting();
admin
action="updateORMSetting"
type="#variables.type#"
password="#variables.password#"
autogenmap=isNull(arguments.autogenmap) || isEmpty(arguments.autogenmap) ? existing.autogenmap : arguments.autogenmap
eventHandling=isNull(arguments.eventHandling) || isEmpty(arguments.eventHandling) ? existing.eventHandling : arguments.eventHandling
flushatrequestend=isNull(arguments.flushatrequestend) || isEmpty(arguments.flushatrequestend) ? existing.flushatrequestend : arguments.flushatrequestend
logSQL=isNull(arguments.logSQL) || isEmpty(arguments.logSQL) ? existing.logSQL : arguments.logSQL
savemapping=isNull(arguments.savemapping) || isEmpty(arguments.savemapping) ? existing.savemapping : arguments.savemapping
useDBForMapping=isNull(arguments.useDBForMapping) || isEmpty(arguments.useDBForMapping) ? existing.useDBForMapping : arguments.useDBForMapping