private Permissions.Permission getPermissionFromId() throws NumberFormatException { final Integer permissionId; try { permissionId = Integer.valueOf(id()); } catch (NumberFormatException e) { return null; } for (Permissions.Permission permission : Permissions.Permission.values()) { if (permissionId.equals(permission.getId())) { return permission; } } return null; }
private UserPermissionJsonBean createBean(Permissions.Permission permission, Issue issue, Project project, ApplicationUser loggedInUser) { boolean hasPermission; if (issue != null) { hasPermission = permissionManager.hasPermission(new ProjectPermissionKey(permission.getId()), issue, loggedInUser); } else if (project != null) { hasPermission = permissionManager.hasPermission(new ProjectPermissionKey(permission.getId()), project, loggedInUser); } else { hasPermission = permissionManager.hasProjects(new ProjectPermissionKey(permission.getId()), loggedInUser); } return new UserPermissionJsonBean(permission, hasPermission, jiraAuthenticationContext); }
private Permissions.Permission getPermissionFromKey() { if (key == null) { return null; } try { return Permissions.Permission.valueOf(key); } catch (IllegalArgumentException i) { return null; } }
public NotificationBuilder addRestrictPermission(Permissions.Permission permission) { this.restrictPermissions.add(permission.getId()); return this; }
public UserPermissionJsonBean(Permissions.Permission permission, boolean havePermission, JiraAuthenticationContext authenticationContext) { id(String.valueOf(permission.getId())); key(permission.name()); this.type = PermissionType.PROJECT; this.name = authenticationContext.getI18nHelper().getText(permission.getNameKey()); this.description = authenticationContext.getI18nHelper().getText(permission.getDescriptionKey()); this.havePermission = havePermission; this.deprecatedKey = true; }
@Internal public GlobalPermissionType(Permissions.Permission permission, final boolean anonymousAllowed) { this.key = permission.name(); this.globalPermissionKey = GlobalPermissionKey.of(key); this.nameI18nKey = permission.getNameKey(); this.descriptionI18nKey = permission.getDescriptionKey(); this.anonymousAllowed = anonymousAllowed; }