Last active
August 29, 2015 14:20
-
-
Save jfut/a03617409fbfad05ab1f to your computer and use it in GitHub Desktop.
JIRA: Show group permissions script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.ofbiz.core.entity.EntityUtil | |
import com.atlassian.jira.component.ComponentAccessor | |
import com.atlassian.jira.permission.ProjectPermissionCategory | |
def projectManager = ComponentAccessor.getProjectManager() | |
def permissionManager = ComponentAccessor.getPermissionManager() | |
def permissionSchemeManager = ComponentAccessor.getPermissionSchemeManager() | |
def permissionCategories = [ | |
// ProjectPermissionCategory.PROJECTS, | |
ProjectPermissionCategory.ISSUES, | |
// ProjectPermissionCategory.VOTERS_AND_WATCHERS, | |
ProjectPermissionCategory.COMMENTS, | |
ProjectPermissionCategory.ATTACHMENTS, | |
ProjectPermissionCategory.TIME_TRACKING, | |
ProjectPermissionCategory.OTHER | |
] | |
def result = ""; | |
for (project in projectManager.projectObjects) { | |
result += "Project $project.name id is $project.id<br />\n"; | |
def scheme = EntityUtil.getOnly( | |
permissionSchemeManager.getSchemes( | |
project.getGenericValue())); | |
for (permissionCategory in permissionCategories) { | |
def permissions = permissionManager.getProjectPermissions( | |
permissionCategory); | |
// パーミッションが空ではないカテゴリのみ編集対象にします。 | |
if (permissions.isEmpty() == false) { | |
for (permission in permissions) { | |
def entities = permissionSchemeManager.getEntities( | |
scheme, permission.getKey()); | |
// 値が空ではないエントリのみを編賞対象にします。 | |
// 値が空のエントリは、自身の削除権限など特殊な権限のため、そのままにします。 | |
if (entities.isEmpty() == false) { | |
result += "- " + permission.getNameI18nKey() + "<br />\n"; | |
for (entity in entities) { | |
def parameter = entity.getString("parameter"); | |
result += "-- " + entity.getLong("id") + " [" + entity.getString("type") + ":"; | |
if (parameter == null) { | |
result += "Anyone" + "]<br />\n"; | |
} else { | |
result += entity.getString("parameter") + "]<br />\n"; | |
} | |
// 必要に応じて何らかの編集操作を実装します。 | |
// 例1: 削除 | |
// permissionSchemeManager.deleteEntity( | |
// entity.getLong("id").longValue()); | |
// 例2: 更新 | |
// entity.set("parameter", project.name.toLowerCase()); | |
} | |
} | |
} | |
} | |
} | |
} | |
return result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment