public boolean matches(User user) {
if (myRoleId == 0) {
return false;
}
ProjectRoleManager rm = ComponentAccessor.getComponentOfType(ProjectRoleManager.class);
com.atlassian.jira.security.roles.ProjectRole role = rm.getProjectRole(myRoleId);
if (role == null) {
return false;
}
List<Project> projects;
if (myProjectId == 0) {
StructureConfiguration configuration = ComponentAccessor.getOSGiComponentInstanceOfType(StructureConfiguration.class);
if (configuration == null) {
return false;
}
projects = configuration.getCurrentlyEnabledProjects();
} else {
ProjectManager pm = ComponentAccessor.getProjectManager();
Project project = pm.getProjectObj(myProjectId);
projects = project == null ? Collections.<Project>emptyList() : Collections.singletonList(project);
}
for (Project project : projects) {
if (rm.isUserInProjectRole(user, role, project)) {
return true;
}
}
return false;
}