I'm encountering an error while working with a DXL script. The script is designed to iterate through all views of database modules, check if each view is listed as generic (belonging to the skiplist), and perform certain actions accordingly. Specifically, if a view is generic, the script should remove all access for all groups except the "12_Admin" group, then grant RMCDA rights to the "12_Admin" group, and finally save the changes made to the module.
DXL Script :
pragma runLim, 0
Skip includedViews = create()
/************************************
addIncludedView
Ajouter une vue à la skiplist des vues incluses.
************************************/
void addIncludedView(Skip includeList, string ViewName)
{
Skip sk = includeList
// sk insert ViewName
put(sk, ViewName, ViewName)
}
/************************************
processFormal
Do something with the given formal module.
************************************/
void processFormal(string mName)
{
Skip includeList = includedViews
string IncludedView
string sView
View v
noError
Module m = read(mName, false)
lastError
// Parcourir toutes les vues du module "itm"
for sView in views(m) do
{
// Initialiser isIncluded à false pour chaque vue
v = view sView
bool isIncluded = false
print fullName(m) "; "
// Vérifier si la vue actuelle est incluse dans la liste des vues incluses
for IncludedView in includeList do
{
if (IncludedView == name(v))
{
isIncluded = true
break
}
}
// Si la vue est incluse
if (isIncluded)
{
Group group
noError
m = edit(mName, false)
lastError
for g in groupList do {
string gName = group.name
if (gName != "12_Admin"){
unsetAll(v)
}
}
set (v, read|modify|create|delete|control, "12_Admin")
save(m)
print name(v) "; Vue générique\n"
}
else
{
print name(v) "; Vue non générique\n"
}
}
}
void scanFolder(Folder f)
{
Item itm;
if (f == null)
{
print("NULL Folder parameter passed\n");
return;
}
for itm in all f do
{
if (itm == null) continue;
if (type(itm) == "Project" || type(itm) == "Folder")
{
scanFolder(folder(itm));
}
else if (type(itm) == "Formal")
{
processFormal(fullName(itm))
}
}
}
/************************************
MAIN
************************************/
// Ajoutez les vues que vous souhaitez inclure de la modification à la skiplist
addIncludedView(includedViews, "Allocation Matrix")
scanFolder(current Folder);
Despite my efforts, I'm consistently facing the following DXL error:
-E- DXL: <Line:59> Arguments incorrects pour (do)
I've double-checked the syntax and context of the script, but I'm unable to pinpoint the cause of this error. Any insights or assistance on resolving this issue would be greatly appreciated. Thank you for your help!
The syntax error is rather simple. Line 59 reads
for g in groupList do {
But a variable g is nowhere defined. I think you wanted to write
for group in groupList do {
BUT: groupList
gives you a list of each group defined in the database (i.e. it is the list you get when you call Tools->Manage Users->Group.). So, with the current code, the unsetAll(v)
in line 62 will always be called when at least one group exists that is not called 12_Admin.
I think you wanted to check the access rights of the view v
. Check chapter 22 "Access Controls", about how to iterate over each AccessRec
of a view (for _ar_ in _type_ do {if username ar != "12_Admin" then ...
) (DOORS does not distinguish between access records for single users and for groups, both are stored in username
). But please note that unsetAll
will clear the complete access rights of the view, not only of the current AccessRec, you might want to use unset
instead.
Also, you might want to check whether the access rights of a view are inherited and if not, change them to specific.
Also, read the Note in the definition of “unset, unsetDef, unsetVal, unsetAll”, I think you will first have to set the access rights for the Admin group before removing the rights for all others. Check this script thoroughly before running it in a productive DB. By the way: is it sure that the end users (Everyone Else, i.e. username = "") shall not even have read access to the specific views?
Apart from this, I noticed the following.
Line 3:
Skip includedViews = create()
If the key of a Skip List is of type string
, you need to use
Skip includeViews = createString()
Lines 11ff:
Skip sk = includeList
// sk insert ViewName
put(sk, ViewName, ViewName)
There's no need to create a temporary variable. Just use put (includeList, ViewName, ViewName)
.