*/
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, CommunicationException, NamingException
{
String dataSource = Settings.getInstance().getSiteInfo(CVUtility.getHostName(super.getServlet().getServletContext())).getDataSource();
HttpSession session = request.getSession(true);
GlobalMasterLists gml = GlobalMasterLists.getGlobalMasterLists(dataSource);
Vector vecMOC = (Vector)gml.get("MOC");
int listid = 0;
if (session.getAttribute("listid") != null)
{
listid = Integer.parseInt((String)session.getAttribute("listid"));
}
ListMemberForm dyn = (ListMemberForm)session.getAttribute("importListForm");
UserObject userobject = (UserObject)session.getAttribute("userobject");
int indvID = 0;
if (userobject != null)
{
indvID = userobject.getIndividualID();
}
ListGenerator lg = ListGenerator.getListGenerator(dataSource);
lg.makeListDirty("Entity");
lg.makeListDirty("Individual");
RandomAccessFile ral = new RandomAccessFile(new File(dyn.getFilePath()), "r");
String readline = "";
int i = 0;
//field seperator
String seperator = dyn.getFieldseprator();
Vector importList = new Vector();
Vector headerVector = new Vector();
String s = "";
String hasHeader = dyn.getHeaderrow();
String sFileFieldName = "";
int headerRow = 0;
String tabDelimiter = dyn.getFieldseprator();
String lineDelimiter = dyn.getLineseprator();
if (tabDelimiter.equals(""))
{
tabDelimiter = dyn.getTab();
}
if (lineDelimiter.equals(""))
{
lineDelimiter = dyn.getLine();
}
String headLine = "";
if (hasHeader.equals("Yes"))
{
headLine = ral.readLine();
headerRow++;
}
int iTemp = 0;
Vector listVector = dyn.getHeadervector();
int vectorColCounter = 0;
while ((readline = ral.readLine()) != null)
{
String[] lineSeprator = readline.split(lineDelimiter);
for (int j = 0; j < lineSeprator.length; j++)
{
HashMap hm = new HashMap();
int headerLen = listVector.size();
String[] sFileFieldList = lineSeprator[j].split(tabDelimiter, (listVector.size() + 1));
vectorColCounter = 0;
int fieldLen = sFileFieldList.length;
if (fieldLen == headerLen)
{
for (int k = 0; k < sFileFieldList.length; k++)
{
DDNameValue ddnamevalue = (DDNameValue)listVector.get(vectorColCounter);
String name = ddnamevalue.getName() + vectorColCounter;
String defValue = ddnamevalue.getName() + "DefaultValue" + vectorColCounter;
String sDBFieldName = (String)request.getParameter(name);
String defaultValue = (String)request.getParameter(defValue);
if (sDBFieldName != null && !(sDBFieldName.equals("--- Select ---")))
{
String defaultNameList = sFileFieldList[k];
if (defaultNameList == null && defaultValue != null)
{
defaultNameList = defaultValue;
} // end of if
if (defaultNameList != null && defaultNameList.equals("") && defaultValue != null)
{
defaultNameList = defaultValue;
} // end of if
defaultNameList = defaultNameList.replaceAll("\"", "");
hm.put(sDBFieldName, defaultNameList.trim());
} // end if block to not allow (sDBFieldName.equals("--- Select ---")) and null
vectorColCounter++;
} // end of for block used to parse every tabSeprator
} //end of if block (fieldLen==headerLen)
hm.put("Line", readline);
importList.add(hm);
} // end of for block used to parse every lineSeprator
} // end of while
Collection CustomEntList = dyn.getCustomEntityList();
Collection CustomIndList = dyn.getCustomIndividualList();
if (tabDelimiter != null && tabDelimiter.equals("\\t"))
{
tabDelimiter = "\t";
}
if (lineDelimiter != null && lineDelimiter.equals("\\n"))
{
lineDelimiter = "\n";
}
//We will check for the instance of the BackgroundImportMembers. and start the import process in background
BackgroundImportMembers backgroundImportMembers = (BackgroundImportMembers)session.getAttribute("backgroundImportMembers");
if (backgroundImportMembers == null || !backgroundImportMembers.isAlive())
{
backgroundImportMembers = new BackgroundImportMembers(importList, headerRow, listid,
indvID, CustomEntList, CustomIndList, tabDelimiter,
lineDelimiter, headLine, dataSource,
"backgroundImportMembers"+indvID);
backgroundImportMembers.start();
HashMap importMessage = backgroundImportMembers.getImportedMessages();
request.setAttribute("Message", importMessage);
session.setAttribute("backgroundImportMembers", backgroundImportMembers);
}
StringBuffer returnPath = new StringBuffer();
returnPath.append(mapping.findForward(".view.marketing.listmanager.importmember").getPath());