1
2
3
4
5 package gboat2.web.validators;
6
7 import gboat2.web.Constants;
8 import gboat2.web.exception.ValidateException;
9 import gboat2.web.validate.AbstractValidator;
10
11 import java.util.Map;
12
13 import org.apache.commons.lang3.StringUtils;
14 import org.osgi.framework.BundleContext;
15 import org.springframework.util.Assert;
16
17
18
19
20
21
22
23
24
25 public class NotNullValidator extends AbstractValidator {
26
27 public NotNullValidator(BundleContext bundleContext) {
28 super(bundleContext);
29
30 }
31
32 @Override
33 public void validate(Map<String,?> paraMap) throws ValidateException {
34 Assert.notEmpty(paraMap);
35
36 String username = (String)paraMap.get("username");
37 String password = (String)paraMap.get("password");
38 if (StringUtils.isEmpty(username)) {
39 throw new ValidateException(Constants.ERROR_MESSAGE_USERNAME_NULL);
40 }
41
42
43 if (StringUtils.isEmpty(password)) {
44 throw new ValidateException(Constants.ERROR_MESSAGE_PASSWORD_NULL);
45 }
46 }
47
48 }