//Validation
        UploadPortletRequest uploadReq = PortalUtil.getUploadPortletRequest(req);
        byte[] bytes = FileUtil.getBytes(uploadReq.getFile("file"));
        ImportContentletsForm importContentletsForm = (ImportContentletsForm) form;
        if(importContentletsForm.getStructure().isEmpty()){
          SessionMessages.add(req, "error", "structure-type-is-required");
          setForward(req, "portlet.ext.contentlet.import_contentlets");
        }else if (bytes == null || bytes.length == 0) {
          SessionMessages.add(req, "error", "message.contentlet.file.required");
          setForward(req, "portlet.ext.contentlet.import_contentlets");
        } else {
          try {
            Reader reader = null;
            CsvReader csvreader = null;
            String[] csvHeaders = null;
            int languageCodeHeaderColumn = -1;
            int countryCodeHeaderColumn = -1;
                        
            if (importContentletsForm.getLanguage() == -1)
              reader = new InputStreamReader(new ByteArrayInputStream(bytes), Charset.forName("UTF-8"));
            else
              reader = new InputStreamReader(new ByteArrayInputStream(bytes));
            
            csvreader = new CsvReader(reader);
            csvreader.setSafetySwitch(false);
            
            switch ((int) importContentletsForm.getLanguage()) {
            case -1:
              if (0 < importContentletsForm.getFields().length) {
                if (csvreader.readHeaders()) {
                  csvHeaders = csvreader.getHeaders();
                  for (int column = 0; column < csvHeaders.length; ++column) {
                    if (csvHeaders[column].equals(languageCodeHeader))
                      languageCodeHeaderColumn = column;
                    if (csvHeaders[column].equals(countryCodeHeader))
                      countryCodeHeaderColumn = column;
                    
                    if ((-1 < languageCodeHeaderColumn) && (-1 < countryCodeHeaderColumn))
                      break;
                  }
                  
                  if ((-1 == languageCodeHeaderColumn) || (-1 == countryCodeHeaderColumn)) {
                    SessionMessages.add(req, "error", "message.import.contentlet.csv_headers.required");
                    setForward(req, "portlet.ext.contentlet.import_contentlets");
                  } else {
                    _generatePreview(0,req, res, config, form, user, bytes, csvHeaders, csvreader, languageCodeHeaderColumn, countryCodeHeaderColumn, reader);
                    setForward(req, "portlet.ext.contentlet.import_contentlets_preview");
                  }
                } else {
                  SessionMessages.add(req, "error", "message.import.contentlet.csv_headers.error");
                  setForward(req, "portlet.ext.contentlet.import_contentlets");
                }
              } else {
                SessionMessages.add(req, "error", "message.import.contentlet.key_field.required");
                setForward(req, "portlet.ext.contentlet.import_contentlets");
              }
              break;
            case 0:
              SessionMessages.add(req, "error", "message.import.contentlet.language.required");
              setForward(req, "portlet.ext.contentlet.import_contentlets");
              break;
            default:
              _generatePreview(0, req, res, config, form, user, bytes, csvHeaders, csvreader, languageCodeHeaderColumn, countryCodeHeaderColumn, reader);
              setForward(req, "portlet.ext.contentlet.import_contentlets_preview");
              break;
            }
            
            csvreader.close();
          } catch (Exception e) {
            _handleException(e, req);
            return;
          }
        }
      } catch (Exception ae) {
        _handleException(ae, req);
        return;
      }
    } else if ((cmd != null) && cmd.equals(com.dotmarketing.util.Constants.PUBLISH)) {
      AdminLogger.log(ImportContentletsAction.class, "processAction", "Importing Contentlets", user);
      Long importIdComplete=(Long)session.getAttribute("importId");
      String subcmd = req.getParameter("subcmd");
       if(subcmd != null && subcmd.equals("importContentletsResults")){
        HashMap<String, List<String>>results=ImportAuditUtil.loadImportResults(importIdComplete);
        req.setAttribute("importResults", results);
        setForward(req, "portlet.ext.contentlet.import_contentlets_results");
      } else {
        final ActionRequestImpl reqImpl = (ActionRequestImpl) req;
        final HttpServletRequest httpReq = reqImpl.getHttpServletRequest();
        final long importId = ImportAuditUtil.createAuditRecord(user.getUserId(), (String)httpReq.getSession().getAttribute("fileName"));
        Thread t=new Thread() {
          public void run() {
            try {
              Logger.debug(this, "Calling Process File Method");
              
              Reader reader = null;
              CsvReader csvreader = null;
              String[] csvHeaders = null;
              int languageCodeHeaderColumn = -1;
              int countryCodeHeaderColumn = -1;
              
              byte[] bytes = (byte[]) httpReq.getSession().getAttribute("file_to_import");
              File file= (File)httpReq.getSession().getAttribute("csvFile");
              ImportContentletsForm importContentletsForm = (ImportContentletsForm) form;
              if (importContentletsForm.getLanguage() == -1)
                reader = new InputStreamReader(new ByteArrayInputStream(bytes), Charset.forName("UTF-8"));
              else
                reader = new InputStreamReader(new ByteArrayInputStream(bytes));
              csvreader = new CsvReader(reader);
              csvreader.setSafetySwitch(false);
                
              if (importContentletsForm.getLanguage() == -1) {
                if (csvreader.readHeaders()) {
                  csvHeaders = csvreader.getHeaders();
                  for (int column = 0; column < csvHeaders.length; ++column) {
                    if (csvHeaders[column].equals(languageCodeHeader))
                      languageCodeHeaderColumn = column;