Skip to main content
Skip table of contents

Archive Structures Owned by Inactive Users

GROOVY
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

}

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.