Document toolboxDocument toolbox

This article is for Data Center. Visit Cloud

Archive Structures Owned by Inactive Users

import com.atlassian.jira.component.ComponentAccessor def plugin = ComponentAccessor.pluginAccessor.getPlugin('com.almworks.jira.structure') def loader = plugin.classLoader def PermissionLevel = loader.loadClass('com.almworks.jira.structure.api.permissions.PermissionLevel') def StructureAuth = loader.loadClass('com.almworks.jira.structure.api.auth.StructureAuth') def structureComponents = plugin.getModuleDescriptor('structure-components').module def structureManager = structureComponents.structureManager StructureAuth.sudo {    def activeStructures = structureManager.getAllStructures(PermissionLevel.NONE, false)    def structuresToArchive = activeStructures.findAll { it.owner != null && !it.owner.isActive() }    structuresToArchive.forEach {         it.setArchived(true).saveChanges()        log.warn("Archived structure: ${it.id} - ${it.name}")    }    structuresToArchive }

Â