Commit cc406542 by Harsh Shah

Finish Hotfix-20190724

parents 07b20465 5fdf74ab
......@@ -30,7 +30,7 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
private static final String ACC_USER_NAME = ConfigMgr.getKeyfileString("imap.email.acc.username");
private static final String ACC_PASSWORD = ConfigMgr.getKeyfileString("imap.email.acc.password");
private static final boolean SYNC_ALL_EXISTING_EMAILS = ConfigMgr.getKeyfileBoolean("sync.all.existing.emails", false);
private static final Integer SYNC_EMAILS_SINCE_MINUTES = ConfigMgr.getKeyfileInt("sync.emails.since.minutes", 30*60); //Applicable only when SYNC_ALL_EXISTING_EMAILS is false.
private static final Integer SYNC_EMAILS_SINCE_MINUTES = ConfigMgr.getKeyfileInt("sync.emails.since.minutes", 10*24*60); //Applicable only when SYNC_ALL_EXISTING_EMAILS is false.
public static final LoggingArea LOG = LoggingArea.createLoggingArea("PerformaEmailFetcher");
@Override
......@@ -291,6 +291,7 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
if(tmpJobId != null && !tmpJobId.isEmpty() && StringUtils.isNumber(tmpJobId))
{
LogMgr.log(LOG, LogLevel.PROCESSING1, "Identified Job ID: " , tmpJobId);
break;
}
}
......@@ -331,8 +332,12 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
{
if (jobIdentifier != null && !jobIdentifier.isEmpty() && StringUtils.isNumber(jobIdentifier))
{
LogMgr.log(LOG, LogLevel.PROCESSING1, "Starting to process message for job id: " , jobIdentifier);
Job job = Job.getJobByID(objTran, Long.parseLong(jobIdentifier));
LogMgr.log(LOG, LogLevel.PROCESSING1, "Retrived Job :" , job);
if (job != null)
{
createEmailMessage(objTran, job);
......@@ -358,6 +363,8 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
private void handleSeekEmail(ObjectTransaction objTran, Job job) throws StorageException, FieldException
{
LogMgr.log(LOG, LogLevel.PROCESSING1, "Starting to handle Seek email");
SecUser secUser = SecUser.searchNAME(objTran, replyTo);
boolean newUser = false;
......@@ -372,6 +379,8 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
secUser.addRole(Utils.getRole(Utils.ROLE_APPLICANT, objTran));
secUser.setFirstName(firstName);
secUser.setLastName(lastName);
LogMgr.log(LOG, LogLevel.PROCESSING1, "Created new sec user : " , secUser);
}
Candidate candidate = secUser.getExtensionOrCreate(Candidate.REFERENCE_Candidate);
......@@ -393,22 +402,26 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
if(cv.getContentType() != null && Utils.isValidContentType(cv.getContentType().toLowerCase()))
{
jobApplication.setCV(cv);
LogMgr.log(LOG, LogLevel.PROCESSING1, "Attaching cv of content type : " , cv.getContentType() , " for job application : ", jobApplication);
}
}
if(contents.size() > 1)
{
FileBinaryContent coverLetter = contents.get(0);
FileBinaryContent coverLetter = contents.get(1);
if(coverLetter.getContentType() != null && Utils.isValidContentType(coverLetter.getContentType().toLowerCase()))
{
jobApplication.setCoverLetter(contents.get(1));
LogMgr.log(LOG, LogLevel.PROCESSING1, "Attaching cover letter of content type : " , coverLetter.getContentType() , " for job application : ", jobApplication);
}
}
LogMgr.log(LOG, LogLevel.PROCESSING1, "Finished handling Seek email");
}
private void handleIndeedEmail(ObjectTransaction objTran, Job job) throws StorageException, FieldException
{
LogMgr.log(LOG, LogLevel.PROCESSING1, "Starting to handle indeed email");
// handle indeed email
Candidate candidate = Candidate.searchAlias(objTran, fromAddress);
SecUser secUser = SecUser.searchNAME(objTran, fromAddress);
......@@ -417,6 +430,7 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
if(candidate != null)
{
secUser = candidate.getUser();
LogMgr.log(LOG, LogLevel.PROCESSING1, "Candidate exists. Candidate :", candidate);
}
if(secUser == null)
......@@ -430,6 +444,8 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
secUser.addRole(Utils.getRole(Utils.ROLE_APPLICANT, objTran));
secUser.setFirstName(firstName);
secUser.setLastName(lastName);
LogMgr.log(LOG, LogLevel.PROCESSING1, "Created new sec user : " , secUser);
}
if(candidate == null)
......@@ -455,6 +471,7 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
if(cv.getContentType() != null && Utils.isValidContentType(cv.getContentType().toLowerCase()))
{
jobApplication.setCV(cv);
LogMgr.log(LOG, LogLevel.PROCESSING1, "Attaching cv of content type : " , cv.getContentType());
}
}
......@@ -472,7 +489,10 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
FileBinaryContent binaryContent = new FileBinaryContent("application/pdf", out.toByteArray(), "CoverLetter");
jobApplication.setCoverLetter(binaryContent);
LogMgr.log(LOG, LogLevel.PROCESSING1, "Created cover letter for job application : ", jobApplication);
}
LogMgr.log(LOG, LogLevel.PROCESSING1, "Finished handling indeed email");
}
private void createEmailMessage(ObjectTransaction objTran, Job job) throws StorageException, FieldException
......@@ -494,6 +514,8 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
attachment.setAttachmentFile(content);
emailMessage.addToAttachments(attachment);
}
LogMgr.log(LOG, LogLevel.PROCESSING1, "Created Email Message : " , emailMessage);
}
});
......
......@@ -90,7 +90,7 @@ public class StripeUtils
{
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, ex, "Error while creating a plan in stripe");
throw new BusinessException("Problem with creating plan : " + ex.getMessage());
throw new BusinessException("Problem with creating plan. " + ex.getMessage());
}
}
......@@ -117,7 +117,7 @@ public class StripeUtils
}
public static Card updateCardDetails(HiringTeam hiringTeam, String token) throws FieldException
public static Card updateCardDetails(HiringTeam hiringTeam, String token) throws FieldException, BusinessException
{
try
{
......@@ -139,14 +139,13 @@ public class StripeUtils
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, "Update card details in stripe, customer : ", customer, " card : ", card);
return card;
}
catch (StripeException ex)
{
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, ex, "Error while updating a customer in stripe");
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, ex, "Error while updating card details in stripe");
throw new BusinessException("Problem with updating card details. " + ex.getMessage());
}
return null;
}
......@@ -160,7 +159,7 @@ public class StripeUtils
}
catch (StripeException ex)
{
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, ex, "Error while updating a customer in stripe");
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, ex, "Error while retrieving card in stripe");
}
return null;
......
......@@ -720,6 +720,6 @@ public class Utils
public static boolean isValidContentType(String contentType)
{
return contentType.contains("msword") || contentType.contains("doc") || contentType.contains("docx") || contentType.contains("opendocument.text")
|| contentType.contains("pdf") || contentType.contains("vnd.openxmlformats-officedocument.wordprocessingml.document") || contentType.contains("text/plain");
|| contentType.contains("pdf") || contentType.contains("vnd.openxmlformats-officedocument.wordprocessingml.document") || contentType.contains("text/plain") || contentType.contains("txt");
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment