v4 to v5 upgrade tasks for jexl scripted groups

XMLWordPrintable

    • Type: Documentation
    • Resolution: Completed
    • Priority: Minor
    • 5.12.2
    • Affects Version/s: 5.1.0
    • Component/s: None
    • None

      If you are upgrading to v5 and have jexl scripted groups that were created in v4, setting the cache attribute on all the components of all scripts is needed before the OTHER_JOB_grouperLoaderJexlScriptFullSync job runs (at least until around 5.12.0, but in some future version may not be needed). Also, if you have gsh templates from v4, you need to go into each template and set Template type to GSH. If not, the jexl loader daemon will work, but the UI will give an error:

      Error: Cant find property: grouperGshTemplate.templateName.templateType in properties file: grouper.properties, it is required, Problem calling method editGrouperLoader on edu.internet2.middleware.grouper.grouperUi.serviceLogic.UiV2GrouperLoader

       

      Step 1) Disable job OTHER_JOB_grouperLoaderJexlScriptFullSync

       

      Step 2) Set template type for gsh templates

      For each gsh template, edit and set Template type to GSH (not ABAC) and save

       

      Step 3) Set caching attribute on all scripted group components (if not on the >5.x version that caches all groups)

      Run this GSH script which will parse all the scripts to find the groups involved, and set the correct attributes:

      import edu.internet2.middleware.grouper.attr.AttributeDefName
      import edu.internet2.middleware.grouper.attr.assign.AttributeAssign
      import edu.internet2.middleware.grouper.attr.finder.AttributeDefNameFinder
       
      import java.util.regex.Matcher
      import java.util.regex.Pattern
       
      String ATTR_NAME_STR = "etc:attribute:abacJexlScript:grouperJexlScriptMarker"
      AttributeDefName ATTR_DEF_NAME = AttributeDefNameFinder.findByName(ATTR_NAME_STR, exceptionIfNotFound=true)
      String ATTR_NAME_STR2 = "etc:attribute:abacJexlScript:grouperJexlScriptJexlScript"
       
      AttributeDefName CACHE_GROUP_DEF_NAME = AttributeDefNameFinder.findByName("etc:sqlCacheable:sqlCacheableGroup", exceptionIfNotFound=true)
       
      Set<Group> groups = new edu.internet2.middleware.grouper.GroupFinder().assignNameOfAttributeDefName(ATTR_NAME_STR).findGroups()
       
      println "Found ${groups.size()} groups"
       
      Pattern pattern = ~/entity.memberOf\('([^']+)'\)/
       
      Set<String> cachedGroups = []
       
      groups.eachWithIndex {group, idx ->
          def attr = group.attributeDelegate.retrieveAssignment(null, ATTR_DEF_NAME, false, true)
          def value = attr.attributeValueDelegate.retrieveValueString(ATTR_NAME_STR2)
          println value
       
          // e.g., ${((entity.memberOf('a:b:c') || entity.memberOf('d:e:f')) && !(entity.memberOf('g:h:i') || ...
          Matcher matches = pattern.matcher(value)
          matches.iterator().each {
              String cacheGroupName = it[1]
              if (!cachedGroups.contains(cacheGroupName)) {
                  cachedGroups.add(cacheGroupName)
                  Group cacheGroup = new GroupFinder().addGroupName(cacheGroupName).findGroup()
                  if (cacheGroup == null) {
                      println "Can't find group ${cacheGroupName}"
                      //new GroupSave().assignName(cacheGroupName).assignCreateParentStemsIfNotExist(true).save()
                  } else {
                      println "${idx}\t${group.name}\t${cacheGroupName}"
                      AttributeAssign attributeAssign = cacheGroup.attributeDelegate.assignAttribute(CACHE_GROUP_DEF_NAME).attributeAssign
                      attributeAssign.attributeValueDelegate.with {
                          assignValue("etc:sqlCacheable:sqlCacheableListName", "members")
                      }
       
                  }
              }
          }
      }
      

      Step 5) Update caches: run job CHANGE_LOG_consumer_sqlCacheGroup

      Run the CHANGE_LOG_consumer_sqlCacheGroup job or wait for it to run. You should see a row with non-zero total and add counts. Look at the job message, and you should see: "addCacheCount: ###, insertedSqlCacheGroupSize: ###"

      Step 6) Run the jexl loader full sync: OTHER_JOB_grouperLoaderJexlScriptFullSync

      Enable and run job OTHER_JOB_grouperLoaderJexlScriptFullSync. You should not see large numbers of adds and deletes, depending on how long it was disabled for.

            Assignee:
            Chris Hyzer (upenn.edu)
            Reporter:
            Chad Redman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: