Tagging through a lot of pages

Hello,

I have a whole structure representing customer documentation for some 120 customers.
I want to add tags according to customer name to each page and some subpages get subpage-specific tags. (this “list of clients”, “faq”, “list of servers”)
This is to aid the support department in quickly finding documentation.

I have read this thread and started rummaging through various documentation to velocity:

I’d like to have some script that will check the page structure and only add tags if they are missing; it should also not remove any hand-added tags.
I’ve got something that will do something, but it’s getting more complex, as I will need to check a list of “must have” tags against the list of “currently there” tags.

To a point, $str.split() return an array of java.lang.string that I don’t know how to work with and don’t know if I can convert this to a java.util.ArrayList.

Finding documentation for this … is difficult for me as I basically jumped into cold water a few days ago.
I am now questioning my life choices along with the question if I might better look into groovy.

Has anyone some really helpful hints on how to better grasp the basics and maybe on how to fix my above issue?