@RequestParam("q") String query,
HttpServletRequest req, HttpServletResponse response)
throws Exception {
IPermissionActivity activity = permissionOwnerDao.getPermissionActivity(activityId);
IPermissionTargetProvider provider = targetProviderRegistry.getTargetProvider(activity.getTargetProviderKey());
SortedSet<IPermissionTarget> matchingTargets = new TreeSet<IPermissionTarget>();
// add matching results for this identifier provider to the set
Collection<IPermissionTarget> targets = provider.searchTargets(query);
for (IPermissionTarget target : targets) {
if ((StringUtils.isNotBlank(target.getName()) && target
.getName().toLowerCase().contains(query))
|| target.getKey().toLowerCase().contains(query)) {
matchingTargets.addAll(targets);