View difference between Paste ID: pFcuze66 and wYKuaCmg
SHOW: | | - or go back to the newest paste.
1
/*
2
 * To change this template, choose Tools | Templates
3
 * and open the template in the editor.
4
 */
5
package web.service.common;
6
7
import java.util.List;
8
import java.util.Locale;
9
import org.springframework.context.MessageSource;
10
import org.springframework.context.MessageSourceResolvable;
11
import org.springframework.context.NoSuchMessageException;
12
13
/**
14
 *
15
 * @author syncsys
16
 */
17
public class Result {
18
    private boolean isSuccessful;
19
    private Object object;
20-
} 
20+
21
    private MessageSource messages;
22
    
23
    
24
    public Result(boolean isSuccessful, Object object, List errorList){
25
        this.isSuccessful = isSuccessful;
26
        this.object = object;
27
        for (Object error : errorList){
28
            
29
            String errorMessage = messages.getMessage((String)error,  new Object [] {"error-"}, "error-", null);
30
            this.messageList.add(errorMessage);
31
        }
32
        
33
   
34
    }
35
    
36
}
37
38
39
40
public Result save(Users user){
41
        if( userDAO.doesloginIdExists(user.getEmail()) ){
42
            return new Result(false,null,Arrays.asList("error.emailAlreadyExists"/*,"string"*/) );
43
        }else{
44
            Users userToBeReturned = userDAO.save(user);
45
         return new Result(true,userToBeReturned,null);
46
        }
47
       
48
    }