Example usage for com.liferay.portal.kernel.events ActionException ActionException

List of usage examples for com.liferay.portal.kernel.events ActionException ActionException

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.events ActionException ActionException.

Prototype

public ActionException(String msg, Throwable cause) 

Source Link

Usage

From source file:pt.knowledgeworks.liferay.ext.event.ContainerLoginAction.java

License:Open Source License

@Override
public void run(HttpServletRequest req, HttpServletResponse res) throws ActionException {
    HttpSession session = req.getSession();

    User user = (User) session.getAttribute(WebKeys.USER);
    String password = (String) session.getAttribute(WebKeys.USER_PASSWORD);
    boolean isSessionPassword = true;

    if (user != null) {
        try {//from w w w  .  j  av  a 2s.  c o m
            String username = user.getLogin();
            if (password == null) {
                isSessionPassword = false;
                password = user.getPassword();
            }
            try {
                req.login(username, password);
                LOG.info("CAUTH0001: User '" + username + "' logged on container");
                if (GetterUtil.get(PropsUtil.get("ext.remove.session.store.password"), false)) {
                    session.removeAttribute(WebKeys.USER_PASSWORD);
                }
            } catch (ServletException ex) {
                String message = "CAUTH0010: Unable to perform container login for user=" + username
                        + "; isSessionPassword=" + isSessionPassword;
                LOG.warn(message + " :: " + ex);
                if (LOG.isTraceEnabled()) {
                    LOG.trace(message, ex);
                }
            }
        } catch (PortalException | SystemException ex) {
            String message = "CAUTH0011: Unxpected error while retring information on user " + user;
            LOG.warn(message + " :: " + ex);
            throw new ActionException(message, ex);
        }
    } else {
        String message = "CAUTH0012: User not found in session";
        LOG.warn(message);
        throw new ActionException(message);
    }
}