In side my searcher I wish to use the following code to see if the user is in a specfic group:
JiraAuthenticationContext myAuth = ComponentManager.getInstance().getJiraAuthenticationContext();
String thisUser = myAuth.getLoggedInUser().getName();
boolean isUserBanned = (userUtil.getGroupNamesForUser(thisUser).contains("Banned"));
If he is in this group (if isUserBanned == true) I want my searcher to return no results when the search is performed, but how do I add this logic into my class which extends the SelectSearcher class?
Community moderators have prevented the ability to post new answers.
I have resolved this issue. The answer lied in writing a new Clause Validator i.e.:
public
class MySelectCustomFieldValidator implements ClauseValidator
{
...
}
and then using this class in the init(CustomField field) function of the MySelectSearcher class via:
this
.customFieldSearcherClauseHandler = new SimpleCustomFieldContextValueGeneratingClauseHandler(
componentFactory.createObject(MySelectCustomFieldValidator.class, field) , ......);
<font></font>
<font></font>
I've tried extending the parent class instead of the SelectSearch class
(
MySelectSearcher
extends AbstractInitializationCustomFieldSearcher
implements
CustomFieldSearcher, SortableCustomFieldSearcher, CustomFieldStattable {
........
)
However the problem is that although I defined all the functions necessary and the search template is in fact working the security check is only ever run once when the search template for the field of interest is changed. I've tried adding the security check to each of the six functions in the class (i.e. getSearchInformation() , getSearchRenderer() , etc) but again the cehck does not occur at the time the search is actually conducted. Any advice/help would be IMMENSELY appreciated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can I use the view.vm or search.vm files in the templates folder to make it such that if the isUserBanned function returns true the search view is altered?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.