Source Code‎ > ‎src‎ > ‎in.co.sunrays.proj1‎ > ‎action‎ > ‎

ChangePasswordAction.java

package in.co.sunrays.proj1.action;
 
import in.co.sunrays.proj1.exception.ApplicationException;
import in.co.sunrays.proj1.exception.RecordNotFoundException;
import in.co.sunrays.proj1.service.UserServiceInt;
 
import org.apache.log4j.Logger;
 
/**
 * Change Password functionality Action. Performs operation for Change Password
 * 
 * @author SUNRAYS Technologies
 * @version 1.0
 * @Copyright (c) SUNRAYS Technologies
 */
public class ChangePasswordAction extends BaseAction {
 
    private static Logger log = Logger.getLogger(ChangePasswordAction.class);
    private String oldPassword;
    private String newPassword;
    private String confirmPassword;
    private UserServiceInt service;
 
    public void setService(UserServiceInt service) {
        this.service = service;
    }
 
    public String getOldPassword() {
        return oldPassword;
    }
 
    public void setOldPassword(String oldPassword) {
        this.oldPassword = oldPassword;
    }
 
    public String getNewPassword() {
        return newPassword;
    }
 
    public void setNewPassword(String newPassword) {
        this.newPassword = newPassword;
    }
 
    public String getConfirmPassword() {
        return confirmPassword;
    }
 
    public void setConfirmPassword(String confirmPassword) {
        this.confirmPassword = confirmPassword;
    }
 
    /**
     * Performs display operations for ChagePasswordAction
     * 
     * @return type String
     * @return INPUT
     */
    @Override
    public String input() {
        log.debug("ChagePasswordAction.input() Start");
        log.debug("ChagePasswordAction.input() End");
        return INPUT;
    }
 
    /**
     * Performs submit operations for ChagePasswordAction
     * 
     * @return type String
     * @return SUCCESS
     */
    @Override
    public String execute() {
        log.debug("ChagePasswordAction.execute() Start");
        try {
            if (OP_SAVE.equalsIgnoreCase(operation)) {
                service.changePassword(id, oldPassword, newPassword);
                addActionMessage("Your password has been changed.");
            }
        } catch (RecordNotFoundException e) {
            log.error("Old Password not match.", e);
            addActionError("Old Password not match.");
            return INPUT;
        } catch (ApplicationException e) {
            log.error("Critical Issue ", e);
            return OP_ERROR;
        }
        log.debug("ChagePasswordAction.execute() End " + operation);
        return operation;
    }
 
}
Comments