@@ -16,7 +16,7 @@ ClassMethod ExportProductionDefinitionShards(productionClass As %String, nameMet
16
16
Set internalNames (internalName ) = 1
17
17
18
18
// next, export each item to a separate file
19
- Set rs = ##class ( %SQL.Statement ). %ExecDirect (,
19
+ Set rs = .. ExecDirectNoPriv (
20
20
" select Name, ClassName from Ens_Config.Item where Production = ?"
21
21
, productionClass
22
22
)
@@ -51,10 +51,18 @@ ClassMethod DeleteProductionDefinitionShards(productionClass As %String, deleteM
51
51
// if the Production settings PTD exists, delete all PTDs for this Production
52
52
if ##class (%File ).Exists (settingsPTDFile ) {
53
53
set ptdDir = ##class (%File ).GetDirectory (settingsPTDFile )
54
- set rs = ##class (%ResultSet ).%New (" %File:FileSet" )
55
- $$$ThrowOnError(rs .Execute (ptdDir , " *.xml" ))
56
- $$$ThrowSQLIfError(rs .%SQLCODE , rs .%Message )
57
- while rs .Next () {
54
+ set statement = ##class (%SQL.Statement ).%New ()
55
+ try {
56
+ // execute without priv checking if possible on this IRIS version
57
+ set sc = statement .%PrepareClassQuery (" %File" ," FileSet" ,0 )
58
+ } catch err {
59
+ set sc = statement .%PrepareClassQuery (" %File" ," FileSet" )
60
+ }
61
+ quit :$$$ISERR(sc )
62
+ set rs = statement .%Execute (ptdDir , " *.xml" )
63
+ throw :rs .%SQLCODE <0 ##class (%Exception.SQL ).CreateFromSQLCODE (rs .%SQLCODE ,rs .%Message )
64
+ while rs .%Next (.sc ) {
65
+ quit :$$$ISERR(sc )
58
66
set ptdFilename = rs .Data (" Name" )
59
67
set sc = ##class (%Studio.SourceControl.Production ).ParseExternalName (ptdFilename , .ptdInternalName )
60
68
quit :$$$ISERR(sc )
@@ -216,10 +224,10 @@ ClassMethod GetModifiedItemsBeforeSave(internalName, Location, Output modifiedIt
216
224
merge ^IRIS .Temp (" sscProd" ,$job ," modifiedItems" ) = modifiedItems
217
225
// FUTURE: use a percent variable or PPG instead
218
226
kill ^IRIS .Temp (" sscProd" ,$job ," items" )
219
- set rs = ##class ( %SQL.Statement ). % ExecDirectNoPriv (
220
- , " select Name, ClassName from Ens_Config.Item where Production = ?"
227
+ set rs = .. ExecDirectNoPriv (
228
+ " select Name, ClassName from Ens_Config.Item where Production = ?"
221
229
, productionName )
222
- $$$ThrowSQLIfError( rs .%SQLCODE , rs .%Message )
230
+ throw : rs . %SQLCODE < 0 ##class ( %Exception.SQL ). CreateFromSQLCODE ( rs .%SQLCODE ,rs .%Message )
223
231
while rs .%Next () {
224
232
set ^IRIS .Temp (" sscProd" ,$job ," items" ,$listbuild (rs .Name , rs .ClassName )) = 1
225
233
}
@@ -231,10 +239,10 @@ ClassMethod GetModifiedItemsAfterSave(internalName, Output modifiedItems)
231
239
set productionName = $piece (internalName ," ." ,1 ,*-1 )
232
240
if ..IsEnsPortal () {
233
241
// If adding/deleting from SMP, get the modified items by comparing items in temp global with items now
234
- set rs = ##class ( %SQL.Statement ). % ExecDirectNoPriv (
235
- , " select Name, ClassName from Ens_Config.Item where Production = ?"
242
+ set rs = .. ExecDirectNoPriv (
243
+ " select Name, ClassName from Ens_Config.Item where Production = ?"
236
244
, productionName )
237
- $$$ThrowSQLIfError( rs .%SQLCODE , rs .%Message )
245
+ throw : rs . %SQLCODE < 0 ##class ( %Exception.SQL ). CreateFromSQLCODE ( rs .%SQLCODE ,rs .%Message )
238
246
while rs .%Next () {
239
247
if '$get (^IRIS .Temp (" sscProd" ,$job ," items" , $listbuild (rs .Name , rs .ClassName ))) {
240
248
set itemInternalName = ..CreateInternalName (productionName , rs .Name , rs .ClassName , 0 )
@@ -429,12 +437,23 @@ ClassMethod CreateProduction(productionName As %String, superClasses = "") As %S
429
437
ClassMethod GetUserProductionChanges (productionName As %String , ByRef items )
430
438
{
431
439
set sql = " SELECT InternalName, Action FROM %Studio_SourceControl.Change WHERE ChangedBy = ? AND Committed = 0 AND InternalName %STARTSWITH ?"
432
- set rs = ##class ( %SQL.Statement ). %ExecDirect (, sql ,$username ,productionName _" ||" )
433
- $$$ThrowSQLIfError( rs .%SQLCODE , rs .%Message )
440
+ set rs = .. ExecDirectNoPriv ( sql ,$username ,productionName _" ||" )
441
+ throw : rs . %SQLCODE < 0 ##class ( %Exception.SQL ). CreateFromSQLCODE ( rs .%SQLCODE ,rs .%Message )
434
442
while rs .%Next () {
435
443
set items (rs .InternalName ) = rs .Action
436
444
}
437
445
quit $$$OK
438
446
}
439
447
448
+ /// Executes a SQL query without privilege checking if possible on this IRIS version
449
+ ClassMethod ExecDirectNoPriv (sql , args ...) As %SQL .StatementResult
450
+ {
451
+ try {
452
+ set rs = ##class (%SQL.Statement ).%ExecDirectNoPriv (,sql ,args ...)
453
+ } catch err {
454
+ set rs = ##class (%SQL.Statement ).%ExecDirect (,sql ,args ...)
455
+ }
456
+ return rs
457
+ }
458
+
440
459
}
0 commit comments