Untitled

 avatar
unknown
plain_text
2 months ago
4.7 kB
3
Indexable
package com.chrysler.service.vip.action;

import java.io.IOException;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Locale;
import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.actions.DispatchAction;
import org.apache.struts.util.LabelValueBean;
// Added by T7111FJ for Vip Logging changes SeRV01577337 - START 
import com.chrysler.service.vip.action.helper.UDEHelper;
import com.chrysler.service.vip.common.UDELogger;
import com.chrysler.service.vip.db2.ApplicationConstants;
import com.chrysler.service.vip.forms.ReportForm;
// Added by T7111FJ for Vip Logging changes SeRV01577337 - START 
/**
 * @version 	1.0
 * @author Akshat Singh 
 * Added for SeRV00434763 - New Vehicle Prep Checklist Enhancements
 */
public class UDEAction extends DispatchAction
{
	UDEHelper helper = new UDEHelper();
	// Added by T7111FJ for Vip Logging changes SeRV01577337 - START 
	public static final UDELogger LOGGER = UDELogger.getLogger(ApplicationConstants.UDE_LOG_NAME);
	// Added by T7111FJ for Vip Logging changes SeRV01577337 - END 
	
	/** Constructor */
	public UDEAction() 
	{
		System.out.println("UDE Constructed");
	}

	
	public ActionForward dataExtract(ActionMapping mapping, ActionForm form,
		    HttpServletRequest request, HttpServletResponse response)
		    throws Exception {

		ActionForward forward = new ActionForward(); // return value
		ActionMessages errors = new ActionMessages();
		ArrayList dealerList = new ArrayList();
		// Added by T7111FJ for Vip Logging changes SeRV01577337 - START 
		ArrayList<LabelValueBean> sourceList;
		//	 Added by T7111FJ for Vip Logging changes SeRV01577337 - END 
		ReportForm reportForm = null;
		
		try 
		{
			System.out.println("-----In getDataExtract--Action--");
			
			reportForm = (ReportForm)form;
	/*		
       Enumeration<String> headerNames = request.getHeaderNames();
        while (headerNames.hasMoreElements()) {
            String headerName = headerNames.nextElement();
            LOGGER.debug("Header: " + headerName + " Value: " + request.getHeader(headerName));
        }
	*/

				  // Check for sm_user header
	          String lsRemoteUser = getServletRequest().getHeader("SM_USER");
		log.debug("Inside the>>>>>>>--------------->>>>"+lsRemoteUser);
	
		if(lsRemoteUser !=null){
			lsRemoteUser=lsRemoteUser.toUpperCase();
		}
		if(lsRemoteUser.startsWith("S")){
		forward=mapping.findForward("redirect");
		}
		else{

			
			System.out.println("selected appl: " + reportForm.getSelectedAppl());
			// Added by T7111FJ for Vip Logging changes SeRV01577337 - START 
			if (reportForm.getSelectedAppl().equalsIgnoreCase("N")) {
				
				//	 Added by T7111FJ for Vip Logging changes SeRV01577337 - END 
				dealerList = helper.getAllDealersInfo();
    			reportForm.setDealerList(dealerList);
    			// Added by T7111FJ for Vip Logging changes SeRV01577337 - START 
			}
			else
			if (reportForm.getSelectedAppl().equalsIgnoreCase("V"))
			{
				sourceList = new ArrayList<LabelValueBean>();
				sourceList =helper.getAllSourceInfo("menu");
				reportForm.setSourceList(sourceList);
				DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy",Locale.ENGLISH);
		        String yesterday=dateFormat.format(new Date(System.currentTimeMillis()-24*60*60*1000));
		        reportForm.setFromDate(yesterday);
		        reportForm.setToDate(yesterday);
			}
			// Added by T7111FJ for Vip Logging changes SeRV01577337 - END 
		
			
			forward = mapping.findForward("success");
		}

		} catch (Exception e) {

		    // Report the error using the appropriate name and ID.
		    errors.add("name", new ActionMessage("id"));

		}

		// If a message is required, save the specified key(s)
		// into the request for use by the <struts:errors> tag.

		if (!errors.isEmpty()) {
		    saveErrors(request, errors);

		    // Forward control to the appropriate 'failure' URI (change name as desired)
		    //	forward = mapping.findForward("failure");

		} else {

		    // Forward control to the appropriate 'success' URI (change name as desired)
		    // forward = mapping.findForward("success");

		}
		// Finish with
		return (forward);

	    }
	
Editor is loading...
Leave a Comment