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();
CustomFieldHome cfh = (CustomFieldHome) CVUtility.getHomeObject("com.centraview.customfield.CustomFieldHome", "CustomField");
try {
HttpSession session = request.getSession(true);
// We must have to remove the attribute from the session.
session.removeAttribute("backgroundImportMembers");
ListMemberForm dyn = (ListMemberForm) session.getAttribute("importListForm");
UserObject userobject = (UserObject) session.getAttribute("userobject");
int indvID = userobject.getIndividualID();
FormFile ff = dyn.getTheFile();
String strf = ff.getFileName();
InputStream im = ff.getInputStream();
CvFileFacade cvfile = new CvFileFacade();
CvFileVO flvo = new CvFileVO();
flvo.setTitle("EmailAttachment");
flvo.setName(strf);
flvo.setCreatedBy(indvID);
flvo.setOwner(indvID);
int emailAttachmentResult = cvfile.addEmailAttachment(indvID, flvo, im, dataSource);
flvo = cvfile.getEmailAttachment(indvID, emailAttachmentResult, dataSource);
String path = flvo.getPhysicalFolderVO().getFullPath(null, true) + flvo.getName();
session.setAttribute("path", path);
// fill vector with column name
Vector v = new Vector();
String hasHeader = dyn.getHeaderrow();
// int vectorColCounter = 0;
RandomAccessFile ral = new RandomAccessFile(new File(path), "r");
String readline = "";
String tabDelimiter = dyn.getFieldseprator();
String lineDelimiter = dyn.getLineseprator();
if (tabDelimiter.equals("")) {
tabDelimiter = dyn.getTab();
}
if (lineDelimiter.equals("")) {
lineDelimiter = dyn.getLine();
}
if (hasHeader.equals("Yes") || (hasHeader.equals("No"))) {
readline = ral.readLine();
String[] sFileFieldName = readline.split(tabDelimiter);
for (int k = 0; k < sFileFieldName.length; k++) {
v.add(new DDNameValue(sFileFieldName[k], sFileFieldName[k]));
}
}
dyn.setHeadervector(v);
dyn.setFilePath(path);
Collection importEntityList = new ArrayList();
Collection importIndividualList = new ArrayList();
Collection mapImport = new ArrayList();
mapImport.add(new DDNameValue("1", "--- Select ---"));
mapImport.add(new DDNameValue("2", "First Name"));
mapImport.add(new DDNameValue("3", "Middle Name"));
mapImport.add(new DDNameValue("4", "Last Name"));
mapImport.add(new DDNameValue("5", "Entity Name"));
mapImport.add(new DDNameValue("6", "ExternalID (Entity)"));
mapImport.add(new DDNameValue("6", "ExternalID (Individual)"));
mapImport.add(new DDNameValue("7", "Street1"));
mapImport.add(new DDNameValue("8", "Street2"));
mapImport.add(new DDNameValue("9", "City"));
mapImport.add(new DDNameValue("10", "State"));
mapImport.add(new DDNameValue("11", "Zipcode"));
mapImport.add(new DDNameValue("12", "Country"));
mapImport.add(new DDNameValue("13", "Title"));
mapImport.add(new DDNameValue("14", "Source (Individual)"));
mapImport.add(new DDNameValue("14", "Source (Entity)"));
mapImport.add(new DDNameValue("15", "Home Phone"));
mapImport.add(new DDNameValue("16", "Fax Phone"));
mapImport.add(new DDNameValue("17", "Main Phone"));
mapImport.add(new DDNameValue("18", "Mobile Phone"));
mapImport.add(new DDNameValue("19", "Other Phone"));
mapImport.add(new DDNameValue("20", "Pager Phone"));
mapImport.add(new DDNameValue("21", "Work Phone"));
mapImport.add(new DDNameValue("22", "Email"));
mapImport.add(new DDNameValue("23", "Website"));
mapImport.add(new DDNameValue("24", "Account Manager"));
mapImport.add(new DDNameValue("25", "Account Team"));
CustomField remote = cfh.create();
remote.setDataSource(dataSource);
Collection entityCustomFieldList = remote.getCustomFieldImportData("entity");
Collection individualCustomFieldList = remote.getCustomFieldImportData("individual");