Package com.eforce.baby.auth.action

Source Code of com.eforce.baby.auth.action.NotificationAdminAction

package com.eforce.baby.auth.action;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.action.DynaActionForm;
import org.apache.struts.actions.DispatchAction;

import com.eforce.baby.auth.delegates.NotificationAdminBD;
import com.eforce.baby.auth.vo.NotificationAdminVO;
import com.eforce.baby.auth.vo.SessionUserVO;
import com.eforce.baby.common.dao.DAOException;
import com.eforce.baby.common.delegates.BusinessException;
import com.eforce.baby.common.factory.BusinessDelegateFactory;
import com.eforce.baby.utils.IConstants;
import com.eforce.baby.utils.IErrorMessageKeys;


/**
* Implementation of <strong>Action</strong> that validates a multi-page
* registration form.
*/
public class NotificationAdminAction extends DispatchAction {

  private Logger log = (Logger) Logger.getInstance(this.getClass().getName());

  /**
   * Called when the Group Report is viewed
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return ActionForward
   * @throws IOException
   * @throws ServletException
   */
  public ActionForward viewNotification (
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException {
    ActionForward actionFrwd = null;
    DynaActionForm dynaForm = (DynaActionForm) form;

    NotificationAdminBD bd =
      (NotificationAdminBD) BusinessDelegateFactory.getInstance().getDelegate(
        "com.eteam.ems.auth.delegates.NotificationAdminBD");

    // get dsName and dbType from the session - begin
    HttpSession session = request.getSession();
    SessionUserVO sessUser =
      (SessionUserVO) session.getAttribute(
        IConstants.SESSION_ATTR_USER_SESSION_INFO);
    String dsName = sessUser.getDsName();
    String dbType = sessUser.getDbType();
    NotificationAdminVO notVO = new NotificationAdminVO();

    /* Forward to the View Page  */
    try {
      notVO = bd.findGroup(dsName, dbType, request.getParameter("id"));
      BeanUtils.copyProperties(form, notVO);
    } catch (IllegalAccessException ex) {
      log.error("Error GroupAction:viewGroup()");
    } catch (InvocationTargetException ex) {
      log.error("Error GroupAction:viewGroup()");
    } catch(DAOException e){
      ActionMessage message =  new ActionMessage(IErrorMessageKeys.KEY_DATABASE_ERROR);
      ActionMessages messages = new ActionMessages();
      messages.add(IConstants.PAGE_ERROR_MSG_ERROR_MESSAGE, message);
      this.saveErrors(request, messages);

      actionFrwd = new ActionForward(mapping.getInput());
    } catch(BusinessException e){
      ActionMessage message = new ActionMessage(e.getMessageKey());
      ActionMessages messages = new ActionMessages();
      messages.add(IConstants.PAGE_ERROR_MSG_ERROR_MESSAGE, message);
      this.saveErrors(request, messages);

      actionFrwd = new ActionForward(mapping.getInput());
    }

    actionFrwd = mapping.findForward(request.getParameter("target"));
    return actionFrwd;
  }

}
TOP

Related Classes of com.eforce.baby.auth.action.NotificationAdminAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.