File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\main\java\hudson\search\UserSearchProperty.java.html

1 package hudson.search;
2
3 import hudson.Extension;
4 import hudson.model.User;
5 import hudson.model.UserProperty;
6 import hudson.model.UserPropertyDescriptor;
7 import net.sf.json.JSONObject;
8
9 import org.kohsuke.stapler.StaplerRequest;
10 import org.kohsuke.stapler.export.Exported;
11
12 public class UserSearchProperty extends hudson.model.UserProperty {
13
14 private final boolean insensitiveSearch;
15
16 public UserSearchProperty(boolean insensitiveSearch) {
17 this.insensitiveSearch = insensitiveSearch;
18 }
19
20 @Exported
21 public boolean getInsensitiveSearch() {
22 return insensitiveSearch;
23 }
24
25 public static boolean isCaseInsensitive(){
26 User user = User.current();
27 boolean caseInsensitive = false;
28 if(user!=null && user.getProperty(UserSearchProperty.class).getInsensitiveSearch()){//Searching for anonymous user is case-sensitive
29 caseInsensitive=true;
30 }
31 return caseInsensitive;
32 }
33
34
35 @Extension
36 public static final class DescriptorImpl extends UserPropertyDescriptor {
37 public String getDisplayName() {
38 return Messages.UserSearchProperty_DisplayName();
39 }
40
41 public UserProperty newInstance(User user) {
42 return new UserSearchProperty(false); //default setting is case-sensitive searching
43 }
44
45 @Override
46 public UserProperty newInstance(StaplerRequest req, JSONObject formData) throws FormException {
47 return new UserSearchProperty(formData.optBoolean("insensitiveSearch"));
48 }
49
50 }
51
52 }