@Override
 public List<Profile> getProfiles(String projectIdentifier, String query, int limit)
     throws NoSuchEntityException {
   com.tasktop.c2c.server.profile.domain.internal.Project project;
   try {
     project = profileService.getProjectByIdentifier(projectIdentifier);
   } catch (EntityNotFoundException e) {
     handle(e);
     throw new IllegalStateException();
   }
   List<Profile> profiles = new ArrayList<Profile>();
   for (ProjectProfile profile : project.getProjectProfiles()) {
     Profile copy = webServiceDomain.copy(profile.getProfile());
     if (matches(query, copy)) {
       profiles.add(copy);
     }
   }
   Collections.sort(profiles);
   if (limit > 0) {
     while (profiles.size() > limit) {
       profiles.remove(profiles.size() - 1);
     }
   }
   // don't leak email addresses
   for (Profile profile : profiles) {
     profile.setEmail(null);
   }
   return profiles;
 }