Traverse through all folders and projects under a project

Hi all, I need to traverse through all the projects, folders and modules present under a specific project. I tried to use a recursive approach but my execution is getting timed out :

void recurseFolders( Item parentItem ) {
   string itemType = type( parentItem )
   if ( ( itemType == "Folder" ) || ( itemType == "Project" ) ) {
      Item childItem
      for childItem in folder( parentItem ) do {
         recurseFolders( childItem )
      }
   }

// Some operations

}

recurseFolders(item("/filePath"))

 

When I'm running the same script at a lower level i.e with less number of folders and projects, it is working fine.

 

Any help will be appreciated. Thank you.


cron7 - Fri Feb 02 05:42:28 EST 2018

Re: Traverse through all folders and projects under a project
PekkaMakinen - Fri Feb 02 07:57:25 EST 2018

Timed out? DOORS has script execution timing check, you can set values for that or disable that by setting pragma runLim (google that)

More http://www-01.ibm.com/support/docview.wss?uid=swg21407421

 

Otherwise see the folder recursion template at http://www.smartdxl.com/content/?p=442

Re: Traverse through all folders and projects under a project
cron7 - Mon Feb 05 02:13:40 EST 2018

PekkaMakinen - Fri Feb 02 07:57:25 EST 2018

Timed out? DOORS has script execution timing check, you can set values for that or disable that by setting pragma runLim (google that)

More http://www-01.ibm.com/support/docview.wss?uid=swg21407421

 

Otherwise see the folder recursion template at http://www.smartdxl.com/content/?p=442

Hi. Thanks a lot for your input. The folder recursion template works fine.

But at the same time while recursing the various items, I need to fetch the access rights of different users associated with that item. I am having trouble doing that. Could you help?

 

Thanks, again.

 

Re: Traverse through all folders and projects under a project
PekkaMakinen - Mon Feb 05 02:33:28 EST 2018

cron7 - Mon Feb 05 02:13:40 EST 2018

Hi. Thanks a lot for your input. The folder recursion template works fine.

But at the same time while recursing the various items, I need to fetch the access rights of different users associated with that item. I am having trouble doing that. Could you help?

 

Thanks, again.

 

See (again) in SmartDXL this script http://www.smartdxl.com/content/?p=385

Re: Traverse through all folders and projects under a project
cron7 - Mon Feb 05 03:41:31 EST 2018

PekkaMakinen - Mon Feb 05 02:33:28 EST 2018

See (again) in SmartDXL this script http://www.smartdxl.com/content/?p=385

Yes. My original question is regarding this script only. Execution is getting timed out.

Re: Traverse through all folders and projects under a project
PekkaMakinen - Mon Feb 05 05:48:14 EST 2018

cron7 - Mon Feb 05 03:41:31 EST 2018

Yes. My original question is regarding this script only. Execution is getting timed out.

What do you mean by timed out? Did you check the pragma runLim setting?

Re: Traverse through all folders and projects under a project
cron7 - Mon Feb 05 05:54:07 EST 2018

PekkaMakinen - Mon Feb 05 05:48:14 EST 2018

What do you mean by timed out? Did you check the pragma runLim setting?

Yes. I have set it 0.

 

By timed out, I mean... when I'm recursing through smaller number of folders and projects, it is working fine but when the number of folders, projects and modules increase, the execution is halted because of time out.

This is in regard to this template : http://www.smartdxl.com/content/?p=385

Re: Traverse through all folders and projects under a project
EHcnck - Mon Feb 05 12:34:51 EST 2018

cron7 - Mon Feb 05 05:54:07 EST 2018

Yes. I have set it 0.

 

By timed out, I mean... when I'm recursing through smaller number of folders and projects, it is working fine but when the number of folders, projects and modules increase, the execution is halted because of time out.

This is in regard to this template : http://www.smartdxl.com/content/?p=385

what version of DOORS are you running this is a defect(just don't recall the version) for iterating over folders/depths

 

pragma encoding, "UTF-8"
pragma runLim, 0

#include <C:\DXL\FX\includes\64Bit.inc>
#include <C:\DXL\FX\includes\stringFunctions.inc>
#include <C:\DXL\FX\includes\StreamEx.inc>

StreamEx Buf = createStreamEx(write("P:\\Desktop\\Perms.txt", CP_UTF8))               

string getAccessRecord(AccessRec ar) {
        string r = ((read ar)?"R":"")
        string m = ((modify ar)?"M":"")
        string c = ((create ar)?"C":"")
        string d = ((delete ar)?"D":"")
        string a = ((control ar)?"A":"")

        string accessStr = toString(r + m + c + d + a)

        if (null(accessStr)) {
                accessStr = "None"
        }

        return(accessStr)
}

void recurseFolders(Item parentItem) {
   if ((type(parentItem) == "Folder") || (type(parentItem) == "Project")) {
      Item childItem
      for childItem in folder( parentItem ) do {
         recurseFolders( childItem )
      }
   }

   Buf += toString(type(parentItem) + ":\t" + rootName_(parentItem) + "\t" + uniqueID(parentItem) +"\n")

   AccessRec ar
   for ar in all parentItem do {
          if(null(ar)) continue

      if (isDefault(ar)) {
         Buf += "\tDefault"
      } else {
         Buf += toString("\t" + username(ar))
      }

      Buf += toString(" (" + getAccessRecord(ar) + ")\n")
   }
}

recurseFolders(item(rootName_(current Folder)))
closeStreamEx(Buf)
ack "Done!"

 

Re: Traverse through all folders and projects under a project
cron7 - Tue Feb 06 00:37:42 EST 2018

EHcnck - Mon Feb 05 12:34:51 EST 2018

what version of DOORS are you running this is a defect(just don't recall the version) for iterating over folders/depths

 

pragma encoding, "UTF-8"
pragma runLim, 0

#include <C:\DXL\FX\includes\64Bit.inc>
#include <C:\DXL\FX\includes\stringFunctions.inc>
#include <C:\DXL\FX\includes\StreamEx.inc>

StreamEx Buf = createStreamEx(write("P:\\Desktop\\Perms.txt", CP_UTF8))               

string getAccessRecord(AccessRec ar) {
        string r = ((read ar)?"R":"")
        string m = ((modify ar)?"M":"")
        string c = ((create ar)?"C":"")
        string d = ((delete ar)?"D":"")
        string a = ((control ar)?"A":"")

        string accessStr = toString(r + m + c + d + a)

        if (null(accessStr)) {
                accessStr = "None"
        }

        return(accessStr)
}

void recurseFolders(Item parentItem) {
   if ((type(parentItem) == "Folder") || (type(parentItem) == "Project")) {
      Item childItem
      for childItem in folder( parentItem ) do {
         recurseFolders( childItem )
      }
   }

   Buf += toString(type(parentItem) + ":\t" + rootName_(parentItem) + "\t" + uniqueID(parentItem) +"\n")

   AccessRec ar
   for ar in all parentItem do {
          if(null(ar)) continue

      if (isDefault(ar)) {
         Buf += "\tDefault"
      } else {
         Buf += toString("\t" + username(ar))
      }

      Buf += toString(" (" + getAccessRecord(ar) + ")\n")
   }
}

recurseFolders(item(rootName_(current Folder)))
closeStreamEx(Buf)
ack "Done!"

 

Thank you so much for your concern. I'm using version 9.6.

 

While running the above code I get errors for the header files that you have included :

--------

-E- DXL: <Line:4> could not open include file (C:\DXL\FX\includes\64Bit.inc) (No such file or directory)
-E- DXL: <Line:4> syntax error
-I- DXL: All done. Errors reported: 2. Warnings reported: 0.

---------

 

Thanks a lot again.

Re: Traverse through all folders and projects under a project
cron7 - Tue Feb 06 00:40:27 EST 2018

EHcnck - Mon Feb 05 12:34:51 EST 2018

what version of DOORS are you running this is a defect(just don't recall the version) for iterating over folders/depths

 

pragma encoding, "UTF-8"
pragma runLim, 0

#include <C:\DXL\FX\includes\64Bit.inc>
#include <C:\DXL\FX\includes\stringFunctions.inc>
#include <C:\DXL\FX\includes\StreamEx.inc>

StreamEx Buf = createStreamEx(write("P:\\Desktop\\Perms.txt", CP_UTF8))               

string getAccessRecord(AccessRec ar) {
        string r = ((read ar)?"R":"")
        string m = ((modify ar)?"M":"")
        string c = ((create ar)?"C":"")
        string d = ((delete ar)?"D":"")
        string a = ((control ar)?"A":"")

        string accessStr = toString(r + m + c + d + a)

        if (null(accessStr)) {
                accessStr = "None"
        }

        return(accessStr)
}

void recurseFolders(Item parentItem) {
   if ((type(parentItem) == "Folder") || (type(parentItem) == "Project")) {
      Item childItem
      for childItem in folder( parentItem ) do {
         recurseFolders( childItem )
      }
   }

   Buf += toString(type(parentItem) + ":\t" + rootName_(parentItem) + "\t" + uniqueID(parentItem) +"\n")

   AccessRec ar
   for ar in all parentItem do {
          if(null(ar)) continue

      if (isDefault(ar)) {
         Buf += "\tDefault"
      } else {
         Buf += toString("\t" + username(ar))
      }

      Buf += toString(" (" + getAccessRecord(ar) + ")\n")
   }
}

recurseFolders(item(rootName_(current Folder)))
closeStreamEx(Buf)
ack "Done!"

 

Also, the template here  - http://www.smartdxl.com/content/?p=442  for recursing the folders and projects works fine. I am able to traverse through every folder/project/module. But in this I am facing problems accessing the access rights for different users for the every folder/project/module scanned.

 

Could you please help me with this?

Re: Traverse through all folders and projects under a project
Mike.Scharnow - Tue Feb 06 08:05:05 EST 2018

cron7 - Tue Feb 06 00:40:27 EST 2018

Also, the template here  - http://www.smartdxl.com/content/?p=442  for recursing the folders and projects works fine. I am able to traverse through every folder/project/module. But in this I am facing problems accessing the access rights for different users for the every folder/project/module scanned.

 

Could you please help me with this?

I am facing problems accessing the access rights

Which problems?

Re: Traverse through all folders and projects under a project
cron7 - Tue Feb 06 23:51:26 EST 2018

Mike.Scharnow - Tue Feb 06 08:05:05 EST 2018

I am facing problems accessing the access rights

Which problems?

Hi Mike. The problem is fixed now. Thanks for your concern.