Commit 8d516bbc by Nilu

Email ingest feature

parent 06b98d82
......@@ -16,6 +16,9 @@
<column name="verification_key" type="String" nullable="true" length="10"/>
<column name="is_account_verified" type="Boolean" nullable="true"/>
<column name="google_address_text" type="String" nullable="true" length="300"/>
<column name="is_email_ingest" type="Boolean" nullable="true"/>
<column name="is_masked_email" type="Boolean" nullable="true"/>
<column name="known_as_alias" type="String" nullable="true" length="100"/>
<column name="test_input_id" type="Long" length="11" nullable="true"/>
<column name="user_id" type="Long" length="11" nullable="true"/>
</NODE>
......
......@@ -15,6 +15,9 @@ CREATE TABLE oneit_sec_user_extension (
verification_key varchar(10) NULL,
is_account_verified char(1) NULL,
google_address_text varchar(300) NULL,
is_email_ingest char(1) NULL,
is_masked_email char(1) NULL,
known_as_alias varchar(100) NULL,
test_input_id numeric(12) NULL,
user_id numeric(12) NULL
);
......
......@@ -16,6 +16,9 @@ CREATE TABLE oneit_sec_user_extension (
verification_key varchar2(10) NULL,
is_account_verified char(1) NULL,
google_address_text varchar2(300) NULL,
is_email_ingest char(1) NULL,
is_masked_email char(1) NULL,
known_as_alias varchar2(100) NULL,
test_input_id number(12) NULL,
user_id number(12) NULL
);
......
......@@ -16,6 +16,9 @@ CREATE TABLE oneit_sec_user_extension (
verification_key varchar(10) NULL,
is_account_verified char(1) NULL,
google_address_text varchar(300) NULL,
is_email_ingest char(1) NULL,
is_masked_email char(1) NULL,
known_as_alias varchar(100) NULL,
test_input_id numeric(12) NULL,
user_id numeric(12) NULL
);
......
package performa.form;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import oneit.business.content.Article;
import oneit.components.ParticipantInitialisationContext;
import oneit.email.ConfigurableArticleTemplateEmailer;
import oneit.email.ConfigurableEmailerException;
import oneit.logging.*;
import oneit.net.LoopbackHTTP;
import oneit.objstore.ObjectTransaction;
import oneit.objstore.StorageException;
import oneit.objstore.parser.BusinessObjectParser;
......@@ -19,13 +15,13 @@ import oneit.utils.*;
import performa.orm.*;
import performa.orm.types.RoleType;
import performa.utils.Utils;
import performa.utils.WebUtils;
public class SendVerificationMailFP extends SaveFP
{
private static final LoggingArea LOG = LoggingArea.createLoggingArea("SendVerificationLink");
protected ConfigurableArticleTemplateEmailer emailer;
protected ConfigurableArticleTemplateEmailer emailChangedMailer;
@Override
......@@ -55,7 +51,7 @@ public class SendVerificationMailFP extends SaveFP
BusinessObjectParser.assertFieldCondition(secUser.getEmail() != null , job, Job.FIELD_Email, "mandatory", exceptions, true, request);
BusinessObjectParser.assertFieldCondition(StringUtils.isEmailAddress(secUser.getEmail()), job, Job.FIELD_Email, "invalid", exceptions, true, request);
BusinessObjectParser.assertFieldCondition(secUser.getFirstName() != null, secUser, SecUser.FIELD_FirstName, "mandatory", exceptions, true, request);
BusinessObjectParser.assertFieldCondition(secUser.getLastName() != null, secUser, SecUser.FIELD_LastName, "mandatory", exceptions, true, request);
......@@ -133,9 +129,34 @@ public class SendVerificationMailFP extends SaveFP
}
else
{
sendVerificationMail(candidate, job, request);
if(candidate.isTrue(candidate.getIsEmailIngest()))
{
if(candidate.isTrue(candidate.getIsMaskedEmail()))
{
SecUser old = (SecUser) candidate.getUser().getEarliestBackup();
if(CollectionUtils.equals(old.getEmail(), candidate.getUser().getEmail()))
{
throw new BusinessException("Please enter a valid email address");
}
// send email changed mail
Utils.sendMaskedEmailChangedMail(candidate, job, emailChangedMailer);
candidate.getUser().setUserName(candidate.getUser().getEmail());
candidate.setIsMaskedEmail(false);
candidate.setKnownAsAlias(old.getEmail());
}
else
{
candidate.setIsAccountVerified(true);
}
}
else
{
Utils.sendVerificationMail(candidate, job, emailer, SendVerificationMailFP.class.getName());
}
request.setAttribute("nextPage", request.getAttribute("nextPage") + "&JobID=" + job.getID());
}
return super.processForm(process, submission, params);
......@@ -148,47 +169,6 @@ public class SendVerificationMailFP extends SaveFP
super.init(context);
emailer = (ConfigurableArticleTemplateEmailer) (context.getSingleChild("AccountVerificationEmailer"));
}
private void sendVerificationMail(Candidate candidate, Job job, HttpServletRequest request) throws BusinessException
{
if(!candidate.isTrue(candidate.getIsAccountVerified()))
{
try
{
LogMgr.log(LOG, LogLevel.PROCESSING1, "Sending verification mail from SendVerificationMailFP to :: ", candidate);
Article verificationArticle = WebUtils.getArticleByShortCut(candidate.getTransaction(), WebUtils.APPLICANT_ACCOUNT_VERIFICATION);
RandomStringGen random = new RandomStringGen();
//set verification key and send mail time
candidate.setVerificationKey(random.generateAlphaNum(6));
candidate.setVerificationMailSendDate(new Date());
String link = LoopbackHTTP.getRemoteAccessURL(request)
+ verificationArticle.getLink(request, CollectionUtils.EMPTY_MAP, "/")
+ "?id=" + job.getID()
+ "&key=" + job.getRandomKey()
+ "&aid=" + candidate.getID()
+ "&pin=" + candidate.getVerificationKey();
Map defaultParams = CollectionUtils.mapEntry("link", link).toMap();
ObjectTransform transform = Utils.createCompoundTransform(defaultParams, candidate.getUser(), job);
Utils.sendMail(emailer, transform, new String[]{candidate.getUser().getUserName()}, null, candidate);
LogMgr.log(LOG, LogLevel.PROCESSING1, "Sent verification mail successfully from " + SendVerificationMailFP.class + " to :: ", candidate);
}
catch (ConfigurableEmailerException ex)
{
LogMgr.log(LOG, LogLevel.SYSTEMERROR1, ex, "Error occured while sending mail for Candidate :: " + candidate);
throw new BusinessException("We are unable to send mail. Please try again or contact Matchd for more details.");
}
}
else
{
LogMgr.log(LOG, LogLevel.PROCESSING1, "Call from " + SendVerificationMailFP.class + ". Account is already verified for candidate :: ", candidate);
}
emailChangedMailer = (ConfigurableArticleTemplateEmailer) (context.getSingleChild("EmailChangedEmailer"));
}
}
\ No newline at end of file
......@@ -47,6 +47,9 @@ public abstract class BaseCandidate extends SecUserExtension
public static final String FIELD_VerificationKey = "VerificationKey";
public static final String FIELD_IsAccountVerified = "IsAccountVerified";
public static final String FIELD_GoogleAddressText = "GoogleAddressText";
public static final String FIELD_IsEmailIngest = "IsEmailIngest";
public static final String FIELD_IsMaskedEmail = "IsMaskedEmail";
public static final String FIELD_KnownAsAlias = "KnownAsAlias";
public static final String FIELD_PrivacyPolicyAgreed = "PrivacyPolicyAgreed";
public static final String FIELD_ConditionsAgreed = "ConditionsAgreed";
public static final String SINGLEREFERENCE_TestInput = "TestInput";
......@@ -62,6 +65,7 @@ public abstract class BaseCandidate extends SecUserExtension
// Static constants corresponding to searches
public static final String SEARCH_All = "All";
public static final String SEARCH_Alias = "Alias";
public static final String SEARCH_IdPin = "IdPin";
......@@ -73,6 +77,9 @@ public abstract class BaseCandidate extends SecUserExtension
private static final DefaultAttributeHelper<Candidate> HELPER_VerificationKey = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<Candidate> HELPER_IsAccountVerified = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<Candidate> HELPER_GoogleAddressText = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<Candidate> HELPER_IsEmailIngest = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<Candidate> HELPER_IsMaskedEmail = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<Candidate> HELPER_KnownAsAlias = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<Candidate> HELPER_PrivacyPolicyAgreed = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<Candidate> HELPER_ConditionsAgreed = DefaultAttributeHelper.INSTANCE;
......@@ -85,6 +92,9 @@ public abstract class BaseCandidate extends SecUserExtension
private String _VerificationKey;
private Boolean _IsAccountVerified;
private String _GoogleAddressText;
private Boolean _IsEmailIngest;
private Boolean _IsMaskedEmail;
private String _KnownAsAlias;
private Boolean _PrivacyPolicyAgreed;
private Boolean _ConditionsAgreed;
......@@ -113,6 +123,9 @@ public abstract class BaseCandidate extends SecUserExtension
private static final AttributeValidator[] FIELD_VerificationKey_Validators;
private static final AttributeValidator[] FIELD_IsAccountVerified_Validators;
private static final AttributeValidator[] FIELD_GoogleAddressText_Validators;
private static final AttributeValidator[] FIELD_IsEmailIngest_Validators;
private static final AttributeValidator[] FIELD_IsMaskedEmail_Validators;
private static final AttributeValidator[] FIELD_KnownAsAlias_Validators;
// Arrays of behaviour decorators
......@@ -145,6 +158,9 @@ public abstract class BaseCandidate extends SecUserExtension
FIELD_VerificationKey_Validators = (AttributeValidator[])setupAttribMetaData_VerificationKey(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_IsAccountVerified_Validators = (AttributeValidator[])setupAttribMetaData_IsAccountVerified(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_GoogleAddressText_Validators = (AttributeValidator[])setupAttribMetaData_GoogleAddressText(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_IsEmailIngest_Validators = (AttributeValidator[])setupAttribMetaData_IsEmailIngest(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_IsMaskedEmail_Validators = (AttributeValidator[])setupAttribMetaData_IsMaskedEmail(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_KnownAsAlias_Validators = (AttributeValidator[])setupAttribMetaData_KnownAsAlias(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_Candidate.initialiseReference ();
......@@ -397,6 +413,63 @@ public abstract class BaseCandidate extends SecUserExtension
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_IsEmailIngest(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "is_email_ingest");
metaInfo.put ("defaultValue", "Boolean.FALSE");
metaInfo.put ("name", "IsEmailIngest");
metaInfo.put ("type", "Boolean");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Candidate.IsEmailIngest:", metaInfo);
ATTRIBUTES_METADATA_Candidate.put (FIELD_IsEmailIngest, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Candidate.class, "IsEmailIngest", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Candidate.IsEmailIngest:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_IsMaskedEmail(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "is_masked_email");
metaInfo.put ("defaultValue", "Boolean.FALSE");
metaInfo.put ("name", "IsMaskedEmail");
metaInfo.put ("type", "Boolean");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Candidate.IsMaskedEmail:", metaInfo);
ATTRIBUTES_METADATA_Candidate.put (FIELD_IsMaskedEmail, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Candidate.class, "IsMaskedEmail", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Candidate.IsMaskedEmail:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_KnownAsAlias(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "known_as_alias");
metaInfo.put ("length", "100");
metaInfo.put ("name", "KnownAsAlias");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Candidate.KnownAsAlias:", metaInfo);
ATTRIBUTES_METADATA_Candidate.put (FIELD_KnownAsAlias, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(Candidate.class, "KnownAsAlias", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Candidate.KnownAsAlias:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION
......@@ -431,6 +504,9 @@ public abstract class BaseCandidate extends SecUserExtension
_VerificationKey = (String)(HELPER_VerificationKey.initialise (_VerificationKey));
_IsAccountVerified = (Boolean)(Boolean.FALSE);
_GoogleAddressText = (String)(HELPER_GoogleAddressText.initialise (_GoogleAddressText));
_IsEmailIngest = (Boolean)(Boolean.FALSE);
_IsMaskedEmail = (Boolean)(Boolean.FALSE);
_KnownAsAlias = (String)(HELPER_KnownAsAlias.initialise (_KnownAsAlias));
_PrivacyPolicyAgreed = (Boolean)(Boolean.FALSE);
_ConditionsAgreed = (Boolean)(Boolean.FALSE);
}
......@@ -1154,6 +1230,300 @@ public abstract class BaseCandidate extends SecUserExtension
}
/**
* Get the attribute IsEmailIngest
*/
public Boolean getIsEmailIngest ()
{
assertValid();
Boolean valToReturn = _IsEmailIngest;
for (CandidateBehaviourDecorator bhd : Candidate_BehaviourDecorators)
{
valToReturn = bhd.getIsEmailIngest ((Candidate)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preIsEmailIngestChange (Boolean newIsEmailIngest) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postIsEmailIngestChange () throws FieldException
{
}
public FieldWriteability getWriteability_IsEmailIngest ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute IsEmailIngest. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setIsEmailIngest (Boolean newIsEmailIngest) throws FieldException
{
boolean oldAndNewIdentical = HELPER_IsEmailIngest.compare (_IsEmailIngest, newIsEmailIngest);
try
{
for (CandidateBehaviourDecorator bhd : Candidate_BehaviourDecorators)
{
newIsEmailIngest = bhd.setIsEmailIngest ((Candidate)this, newIsEmailIngest);
oldAndNewIdentical = HELPER_IsEmailIngest.compare (_IsEmailIngest, newIsEmailIngest);
}
if (FIELD_IsEmailIngest_Validators.length > 0)
{
Object newIsEmailIngestObj = HELPER_IsEmailIngest.toObject (newIsEmailIngest);
if (newIsEmailIngestObj != null)
{
int loopMax = FIELD_IsEmailIngest_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Candidate.get (FIELD_IsEmailIngest);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_IsEmailIngest_Validators[v].checkAttribute (this, FIELD_IsEmailIngest, metadata, newIsEmailIngestObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_IsEmailIngest () != FieldWriteability.FALSE, "Field IsEmailIngest is not writeable");
preIsEmailIngestChange (newIsEmailIngest);
markFieldChange (FIELD_IsEmailIngest);
_IsEmailIngest = newIsEmailIngest;
postFieldChange (FIELD_IsEmailIngest);
postIsEmailIngestChange ();
}
}
/**
* Get the attribute IsMaskedEmail
*/
public Boolean getIsMaskedEmail ()
{
assertValid();
Boolean valToReturn = _IsMaskedEmail;
for (CandidateBehaviourDecorator bhd : Candidate_BehaviourDecorators)
{
valToReturn = bhd.getIsMaskedEmail ((Candidate)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preIsMaskedEmailChange (Boolean newIsMaskedEmail) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postIsMaskedEmailChange () throws FieldException
{
}
public FieldWriteability getWriteability_IsMaskedEmail ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute IsMaskedEmail. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setIsMaskedEmail (Boolean newIsMaskedEmail) throws FieldException
{
boolean oldAndNewIdentical = HELPER_IsMaskedEmail.compare (_IsMaskedEmail, newIsMaskedEmail);
try
{
for (CandidateBehaviourDecorator bhd : Candidate_BehaviourDecorators)
{
newIsMaskedEmail = bhd.setIsMaskedEmail ((Candidate)this, newIsMaskedEmail);
oldAndNewIdentical = HELPER_IsMaskedEmail.compare (_IsMaskedEmail, newIsMaskedEmail);
}
if (FIELD_IsMaskedEmail_Validators.length > 0)
{
Object newIsMaskedEmailObj = HELPER_IsMaskedEmail.toObject (newIsMaskedEmail);
if (newIsMaskedEmailObj != null)
{
int loopMax = FIELD_IsMaskedEmail_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Candidate.get (FIELD_IsMaskedEmail);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_IsMaskedEmail_Validators[v].checkAttribute (this, FIELD_IsMaskedEmail, metadata, newIsMaskedEmailObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_IsMaskedEmail () != FieldWriteability.FALSE, "Field IsMaskedEmail is not writeable");
preIsMaskedEmailChange (newIsMaskedEmail);
markFieldChange (FIELD_IsMaskedEmail);
_IsMaskedEmail = newIsMaskedEmail;
postFieldChange (FIELD_IsMaskedEmail);
postIsMaskedEmailChange ();
}
}
/**
* Get the attribute KnownAsAlias
*/
public String getKnownAsAlias ()
{
assertValid();
String valToReturn = _KnownAsAlias;
for (CandidateBehaviourDecorator bhd : Candidate_BehaviourDecorators)
{
valToReturn = bhd.getKnownAsAlias ((Candidate)this, valToReturn);
}
return valToReturn;
}
/**
* Called prior to the attribute changing. Subclasses need not call super. If a field exception
* is thrown, the attribute change will fail. The new value is different to the old value.
*/
protected void preKnownAsAliasChange (String newKnownAsAlias) throws FieldException
{
}
/**
* Called after the attribute changes.
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postKnownAsAliasChange () throws FieldException
{
}
public FieldWriteability getWriteability_KnownAsAlias ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute KnownAsAlias. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setKnownAsAlias (String newKnownAsAlias) throws FieldException
{
boolean oldAndNewIdentical = HELPER_KnownAsAlias.compare (_KnownAsAlias, newKnownAsAlias);
try
{
for (CandidateBehaviourDecorator bhd : Candidate_BehaviourDecorators)
{
newKnownAsAlias = bhd.setKnownAsAlias ((Candidate)this, newKnownAsAlias);
oldAndNewIdentical = HELPER_KnownAsAlias.compare (_KnownAsAlias, newKnownAsAlias);
}
if (FIELD_KnownAsAlias_Validators.length > 0)
{
Object newKnownAsAliasObj = HELPER_KnownAsAlias.toObject (newKnownAsAlias);
if (newKnownAsAliasObj != null)
{
int loopMax = FIELD_KnownAsAlias_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_Candidate.get (FIELD_KnownAsAlias);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_KnownAsAlias_Validators[v].checkAttribute (this, FIELD_KnownAsAlias, metadata, newKnownAsAliasObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_KnownAsAlias () != FieldWriteability.FALSE, "Field KnownAsAlias is not writeable");
preKnownAsAliasChange (newKnownAsAlias);
markFieldChange (FIELD_KnownAsAlias);
_KnownAsAlias = newKnownAsAlias;
postFieldChange (FIELD_KnownAsAlias);
postKnownAsAliasChange ();
}
}
/**
* Get the attribute PrivacyPolicyAgreed
*/
public Boolean getPrivacyPolicyAgreed ()
......@@ -2243,6 +2613,9 @@ public abstract class BaseCandidate extends SecUserExtension
oneit_sec_user_extensionPSet.setAttrib (FIELD_VerificationKey, HELPER_VerificationKey.toObject (_VerificationKey)); //
oneit_sec_user_extensionPSet.setAttrib (FIELD_IsAccountVerified, HELPER_IsAccountVerified.toObject (_IsAccountVerified)); //
oneit_sec_user_extensionPSet.setAttrib (FIELD_GoogleAddressText, HELPER_GoogleAddressText.toObject (_GoogleAddressText)); //
oneit_sec_user_extensionPSet.setAttrib (FIELD_IsEmailIngest, HELPER_IsEmailIngest.toObject (_IsEmailIngest)); //
oneit_sec_user_extensionPSet.setAttrib (FIELD_IsMaskedEmail, HELPER_IsMaskedEmail.toObject (_IsMaskedEmail)); //
oneit_sec_user_extensionPSet.setAttrib (FIELD_KnownAsAlias, HELPER_KnownAsAlias.toObject (_KnownAsAlias)); //
_TestInput.getPersistentSets (allSets);
}
......@@ -2265,6 +2638,9 @@ public abstract class BaseCandidate extends SecUserExtension
_VerificationKey = (String)(HELPER_VerificationKey.fromObject (_VerificationKey, oneit_sec_user_extensionPSet.getAttrib (FIELD_VerificationKey))); //
_IsAccountVerified = (Boolean)(HELPER_IsAccountVerified.fromObject (_IsAccountVerified, oneit_sec_user_extensionPSet.getAttrib (FIELD_IsAccountVerified))); //
_GoogleAddressText = (String)(HELPER_GoogleAddressText.fromObject (_GoogleAddressText, oneit_sec_user_extensionPSet.getAttrib (FIELD_GoogleAddressText))); //
_IsEmailIngest = (Boolean)(HELPER_IsEmailIngest.fromObject (_IsEmailIngest, oneit_sec_user_extensionPSet.getAttrib (FIELD_IsEmailIngest))); //
_IsMaskedEmail = (Boolean)(HELPER_IsMaskedEmail.fromObject (_IsMaskedEmail, oneit_sec_user_extensionPSet.getAttrib (FIELD_IsMaskedEmail))); //
_KnownAsAlias = (String)(HELPER_KnownAsAlias.fromObject (_KnownAsAlias, oneit_sec_user_extensionPSet.getAttrib (FIELD_KnownAsAlias))); //
_TestInput.setFromPersistentSets (objectID, allSets);
}
......@@ -2344,6 +2720,33 @@ public abstract class BaseCandidate extends SecUserExtension
e.addException (ex);
}
try
{
setIsEmailIngest (otherCandidate.getIsEmailIngest ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setIsMaskedEmail (otherCandidate.getIsMaskedEmail ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setKnownAsAlias (otherCandidate.getKnownAsAlias ());
}
catch (FieldException ex)
{
e.addException (ex);
}
}
}
......@@ -2366,6 +2769,9 @@ public abstract class BaseCandidate extends SecUserExtension
_VerificationKey = sourceCandidate._VerificationKey;
_IsAccountVerified = sourceCandidate._IsAccountVerified;
_GoogleAddressText = sourceCandidate._GoogleAddressText;
_IsEmailIngest = sourceCandidate._IsEmailIngest;
_IsMaskedEmail = sourceCandidate._IsMaskedEmail;
_KnownAsAlias = sourceCandidate._KnownAsAlias;
_PrivacyPolicyAgreed = sourceCandidate._PrivacyPolicyAgreed;
_ConditionsAgreed = sourceCandidate._ConditionsAgreed;
......@@ -2432,6 +2838,9 @@ public abstract class BaseCandidate extends SecUserExtension
_VerificationKey = (String)(HELPER_VerificationKey.readExternal (_VerificationKey, vals.get(FIELD_VerificationKey))); //
_IsAccountVerified = (Boolean)(HELPER_IsAccountVerified.readExternal (_IsAccountVerified, vals.get(FIELD_IsAccountVerified))); //
_GoogleAddressText = (String)(HELPER_GoogleAddressText.readExternal (_GoogleAddressText, vals.get(FIELD_GoogleAddressText))); //
_IsEmailIngest = (Boolean)(HELPER_IsEmailIngest.readExternal (_IsEmailIngest, vals.get(FIELD_IsEmailIngest))); //
_IsMaskedEmail = (Boolean)(HELPER_IsMaskedEmail.readExternal (_IsMaskedEmail, vals.get(FIELD_IsMaskedEmail))); //
_KnownAsAlias = (String)(HELPER_KnownAsAlias.readExternal (_KnownAsAlias, vals.get(FIELD_KnownAsAlias))); //
_PrivacyPolicyAgreed = (Boolean)(HELPER_PrivacyPolicyAgreed.readExternal (_PrivacyPolicyAgreed, vals.get(FIELD_PrivacyPolicyAgreed))); //
_ConditionsAgreed = (Boolean)(HELPER_ConditionsAgreed.readExternal (_ConditionsAgreed, vals.get(FIELD_ConditionsAgreed))); //
_TestInput.readExternalData(vals.get(SINGLEREFERENCE_TestInput));
......@@ -2457,6 +2866,9 @@ public abstract class BaseCandidate extends SecUserExtension
vals.put (FIELD_VerificationKey, HELPER_VerificationKey.writeExternal (_VerificationKey));
vals.put (FIELD_IsAccountVerified, HELPER_IsAccountVerified.writeExternal (_IsAccountVerified));
vals.put (FIELD_GoogleAddressText, HELPER_GoogleAddressText.writeExternal (_GoogleAddressText));
vals.put (FIELD_IsEmailIngest, HELPER_IsEmailIngest.writeExternal (_IsEmailIngest));
vals.put (FIELD_IsMaskedEmail, HELPER_IsMaskedEmail.writeExternal (_IsMaskedEmail));
vals.put (FIELD_KnownAsAlias, HELPER_KnownAsAlias.writeExternal (_KnownAsAlias));
vals.put (FIELD_PrivacyPolicyAgreed, HELPER_PrivacyPolicyAgreed.writeExternal (_PrivacyPolicyAgreed));
vals.put (FIELD_ConditionsAgreed, HELPER_ConditionsAgreed.writeExternal (_ConditionsAgreed));
vals.put (SINGLEREFERENCE_TestInput, _TestInput.writeExternalData());
......@@ -2505,6 +2917,18 @@ public abstract class BaseCandidate extends SecUserExtension
{
listener.notifyFieldChange(this, other, FIELD_GoogleAddressText, HELPER_GoogleAddressText.toObject(this._GoogleAddressText), HELPER_GoogleAddressText.toObject(otherCandidate._GoogleAddressText));
}
if (!HELPER_IsEmailIngest.compare(this._IsEmailIngest, otherCandidate._IsEmailIngest))
{
listener.notifyFieldChange(this, other, FIELD_IsEmailIngest, HELPER_IsEmailIngest.toObject(this._IsEmailIngest), HELPER_IsEmailIngest.toObject(otherCandidate._IsEmailIngest));
}
if (!HELPER_IsMaskedEmail.compare(this._IsMaskedEmail, otherCandidate._IsMaskedEmail))
{
listener.notifyFieldChange(this, other, FIELD_IsMaskedEmail, HELPER_IsMaskedEmail.toObject(this._IsMaskedEmail), HELPER_IsMaskedEmail.toObject(otherCandidate._IsMaskedEmail));
}
if (!HELPER_KnownAsAlias.compare(this._KnownAsAlias, otherCandidate._KnownAsAlias))
{
listener.notifyFieldChange(this, other, FIELD_KnownAsAlias, HELPER_KnownAsAlias.toObject(this._KnownAsAlias), HELPER_KnownAsAlias.toObject(otherCandidate._KnownAsAlias));
}
// Compare single assocs
_TestInput.compare (otherCandidate._TestInput, listener);
......@@ -2541,6 +2965,9 @@ public abstract class BaseCandidate extends SecUserExtension
visitor.visitField(this, FIELD_VerificationKey, HELPER_VerificationKey.toObject(getVerificationKey()));
visitor.visitField(this, FIELD_IsAccountVerified, HELPER_IsAccountVerified.toObject(getIsAccountVerified()));
visitor.visitField(this, FIELD_GoogleAddressText, HELPER_GoogleAddressText.toObject(getGoogleAddressText()));
visitor.visitField(this, FIELD_IsEmailIngest, HELPER_IsEmailIngest.toObject(getIsEmailIngest()));
visitor.visitField(this, FIELD_IsMaskedEmail, HELPER_IsMaskedEmail.toObject(getIsMaskedEmail()));
visitor.visitField(this, FIELD_KnownAsAlias, HELPER_KnownAsAlias.toObject(getKnownAsAlias()));
visitor.visitAssociation (_TestInput);
visitor.visitAssociation (_TestAnalysises);
visitor.visitAssociation (_JobApplications);
......@@ -2627,6 +3054,18 @@ public abstract class BaseCandidate extends SecUserExtension
{
return filter.matches (getGoogleAddressText ());
}
else if (attribName.equals (FIELD_IsEmailIngest))
{
return filter.matches (getIsEmailIngest ());
}
else if (attribName.equals (FIELD_IsMaskedEmail))
{
return filter.matches (getIsMaskedEmail ());
}
else if (attribName.equals (FIELD_KnownAsAlias))
{
return filter.matches (getKnownAsAlias ());
}
else if (attribName.equals (SINGLEREFERENCE_TestInput))
{
return filter.matches (getTestInput ());
......@@ -2704,6 +3143,24 @@ public abstract class BaseCandidate extends SecUserExtension
return this;
}
public SearchAll andIsEmailIngest (QueryFilter<Boolean> filter)
{
filter.addFilter (context, "oneit_sec_user_extension.is_email_ingest", "IsEmailIngest");
return this;
}
public SearchAll andIsMaskedEmail (QueryFilter<Boolean> filter)
{
filter.addFilter (context, "oneit_sec_user_extension.is_masked_email", "IsMaskedEmail");
return this;
}
public SearchAll andKnownAsAlias (QueryFilter<String> filter)
{
filter.addFilter (context, "oneit_sec_user_extension.known_as_alias", "KnownAsAlias");
return this;
}
public SearchAll andTestInput (QueryFilter<TestInput> filter)
{
filter.addFilter (context, "oneit_sec_user_extension.test_input_id", "TestInput");
......@@ -2743,6 +3200,43 @@ public abstract class BaseCandidate extends SecUserExtension
.search (transaction);
}
public static SearchAlias SearchByAlias () { return new SearchAlias (); }
public static class SearchAlias extends SearchObject<Candidate>
{
public SearchAlias byKnownAs (String KnownAs)
{
by ("KnownAs", KnownAs);
return this;
}
public Candidate search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_Candidate, SEARCH_Alias, criteria);
Set<Candidate> typedResults = new LinkedHashSet <Candidate> ();
for (BaseBusinessClass bbcResult : results)
{
Candidate aResult = (Candidate)bbcResult;
typedResults.add (aResult);
}
return (Candidate)singletonResult(ObjstoreUtils.removeDeleted(transaction, typedResults).toArray(new BaseBusinessClass[0]), "Candidate", "");
}
}
public static Candidate searchAlias (ObjectTransaction transaction, String KnownAs) throws StorageException
{
return SearchByAlias ()
.byKnownAs (KnownAs)
.search (transaction);
}
public static SearchIdPin SearchByIdPin () { return new SearchIdPin (); }
public static class SearchIdPin extends SearchObject<Candidate>
......@@ -2821,6 +3315,24 @@ public abstract class BaseCandidate extends SecUserExtension
return this;
}
public SearchIdPin andIsEmailIngest (QueryFilter<Boolean> filter)
{
filter.addFilter (context, "oneit_sec_user_extension.is_email_ingest", "IsEmailIngest");
return this;
}
public SearchIdPin andIsMaskedEmail (QueryFilter<Boolean> filter)
{
filter.addFilter (context, "oneit_sec_user_extension.is_masked_email", "IsMaskedEmail");
return this;
}
public SearchIdPin andKnownAsAlias (QueryFilter<String> filter)
{
filter.addFilter (context, "oneit_sec_user_extension.known_as_alias", "KnownAsAlias");
return this;
}
public SearchIdPin andTestInput (QueryFilter<TestInput> filter)
{
filter.addFilter (context, "oneit_sec_user_extension.test_input_id", "TestInput");
......@@ -2896,6 +3408,18 @@ public abstract class BaseCandidate extends SecUserExtension
{
return HELPER_GoogleAddressText.toObject (getGoogleAddressText ());
}
else if (attribName.equals (FIELD_IsEmailIngest))
{
return HELPER_IsEmailIngest.toObject (getIsEmailIngest ());
}
else if (attribName.equals (FIELD_IsMaskedEmail))
{
return HELPER_IsMaskedEmail.toObject (getIsMaskedEmail ());
}
else if (attribName.equals (FIELD_KnownAsAlias))
{
return HELPER_KnownAsAlias.toObject (getKnownAsAlias ());
}
else if (attribName.equals (FIELD_PrivacyPolicyAgreed))
{
return HELPER_PrivacyPolicyAgreed.toObject (getPrivacyPolicyAgreed ());
......@@ -2945,6 +3469,18 @@ public abstract class BaseCandidate extends SecUserExtension
{
return HELPER_GoogleAddressText;
}
else if (attribName.equals (FIELD_IsEmailIngest))
{
return HELPER_IsEmailIngest;
}
else if (attribName.equals (FIELD_IsMaskedEmail))
{
return HELPER_IsMaskedEmail;
}
else if (attribName.equals (FIELD_KnownAsAlias))
{
return HELPER_KnownAsAlias;
}
else if (attribName.equals (FIELD_PrivacyPolicyAgreed))
{
return HELPER_PrivacyPolicyAgreed;
......@@ -2994,6 +3530,18 @@ public abstract class BaseCandidate extends SecUserExtension
{
setGoogleAddressText ((String)(HELPER_GoogleAddressText.fromObject (_GoogleAddressText, attribValue)));
}
else if (attribName.equals (FIELD_IsEmailIngest))
{
setIsEmailIngest ((Boolean)(HELPER_IsEmailIngest.fromObject (_IsEmailIngest, attribValue)));
}
else if (attribName.equals (FIELD_IsMaskedEmail))
{
setIsMaskedEmail ((Boolean)(HELPER_IsMaskedEmail.fromObject (_IsMaskedEmail, attribValue)));
}
else if (attribName.equals (FIELD_KnownAsAlias))
{
setKnownAsAlias ((String)(HELPER_KnownAsAlias.fromObject (_KnownAsAlias, attribValue)));
}
else if (attribName.equals (FIELD_PrivacyPolicyAgreed))
{
setPrivacyPolicyAgreed ((Boolean)(HELPER_PrivacyPolicyAgreed.fromObject (_PrivacyPolicyAgreed, attribValue)));
......@@ -3050,6 +3598,18 @@ public abstract class BaseCandidate extends SecUserExtension
{
return getWriteability_GoogleAddressText ();
}
else if (fieldName.equals (FIELD_IsEmailIngest))
{
return getWriteability_IsEmailIngest ();
}
else if (fieldName.equals (FIELD_IsMaskedEmail))
{
return getWriteability_IsMaskedEmail ();
}
else if (fieldName.equals (FIELD_KnownAsAlias))
{
return getWriteability_KnownAsAlias ();
}
else if (fieldName.equals (MULTIPLEREFERENCE_TestAnalysises))
{
return getWriteability_TestAnalysises ();
......@@ -3123,6 +3683,21 @@ public abstract class BaseCandidate extends SecUserExtension
fields.add (FIELD_GoogleAddressText);
}
if (getWriteability_IsEmailIngest () != FieldWriteability.TRUE)
{
fields.add (FIELD_IsEmailIngest);
}
if (getWriteability_IsMaskedEmail () != FieldWriteability.TRUE)
{
fields.add (FIELD_IsMaskedEmail);
}
if (getWriteability_KnownAsAlias () != FieldWriteability.TRUE)
{
fields.add (FIELD_KnownAsAlias);
}
if (getWriteability_PrivacyPolicyAgreed () != FieldWriteability.TRUE)
{
fields.add (FIELD_PrivacyPolicyAgreed);
......@@ -3149,6 +3724,9 @@ public abstract class BaseCandidate extends SecUserExtension
result.add(HELPER_VerificationKey.getAttribObject (getClass (), _VerificationKey, false, FIELD_VerificationKey));
result.add(HELPER_IsAccountVerified.getAttribObject (getClass (), _IsAccountVerified, false, FIELD_IsAccountVerified));
result.add(HELPER_GoogleAddressText.getAttribObject (getClass (), _GoogleAddressText, false, FIELD_GoogleAddressText));
result.add(HELPER_IsEmailIngest.getAttribObject (getClass (), _IsEmailIngest, false, FIELD_IsEmailIngest));
result.add(HELPER_IsMaskedEmail.getAttribObject (getClass (), _IsMaskedEmail, false, FIELD_IsMaskedEmail));
result.add(HELPER_KnownAsAlias.getAttribObject (getClass (), _KnownAsAlias, false, FIELD_KnownAsAlias));
result.add(HELPER_PrivacyPolicyAgreed.getAttribObject (getClass (), _PrivacyPolicyAgreed, false, FIELD_PrivacyPolicyAgreed));
result.add(HELPER_ConditionsAgreed.getAttribObject (getClass (), _ConditionsAgreed, false, FIELD_ConditionsAgreed));
......@@ -3328,6 +3906,60 @@ public abstract class BaseCandidate extends SecUserExtension
}
/**
* Get the attribute IsEmailIngest
*/
public Boolean getIsEmailIngest (Candidate obj, Boolean original)
{
return original;
}
/**
* Change the value set for attribute IsEmailIngest.
* May modify the field beforehand
* Occurs before validation.
*/
public Boolean setIsEmailIngest (Candidate obj, Boolean newIsEmailIngest) throws FieldException
{
return newIsEmailIngest;
}
/**
* Get the attribute IsMaskedEmail
*/
public Boolean getIsMaskedEmail (Candidate obj, Boolean original)
{
return original;
}
/**
* Change the value set for attribute IsMaskedEmail.
* May modify the field beforehand
* Occurs before validation.
*/
public Boolean setIsMaskedEmail (Candidate obj, Boolean newIsMaskedEmail) throws FieldException
{
return newIsMaskedEmail;
}
/**
* Get the attribute KnownAsAlias
*/
public String getKnownAsAlias (Candidate obj, String original)
{
return original;
}
/**
* Change the value set for attribute KnownAsAlias.
* May modify the field beforehand
* Occurs before validation.
*/
public String setKnownAsAlias (Candidate obj, String newKnownAsAlias) throws FieldException
{
return newKnownAsAlias;
}
/**
* Get the attribute PrivacyPolicyAgreed
*/
public Boolean getPrivacyPolicyAgreed (Candidate obj, Boolean original)
......@@ -3467,6 +4099,18 @@ public abstract class BaseCandidate extends SecUserExtension
{
return toGoogleAddressText ();
}
if (name.equals ("IsEmailIngest"))
{
return toIsEmailIngest ();
}
if (name.equals ("IsMaskedEmail"))
{
return toIsMaskedEmail ();
}
if (name.equals ("KnownAsAlias"))
{
return toKnownAsAlias ();
}
if (name.equals ("TestInput"))
{
return toTestInput ();
......@@ -3494,6 +4138,12 @@ public abstract class BaseCandidate extends SecUserExtension
public PipeLine<From, Boolean> toIsAccountVerified () { return pipe(new ORMAttributePipe<Me, Boolean>(FIELD_IsAccountVerified)); }
public PipeLine<From, String> toGoogleAddressText () { return pipe(new ORMAttributePipe<Me, String>(FIELD_GoogleAddressText)); }
public PipeLine<From, Boolean> toIsEmailIngest () { return pipe(new ORMAttributePipe<Me, Boolean>(FIELD_IsEmailIngest)); }
public PipeLine<From, Boolean> toIsMaskedEmail () { return pipe(new ORMAttributePipe<Me, Boolean>(FIELD_IsMaskedEmail)); }
public PipeLine<From, String> toKnownAsAlias () { return pipe(new ORMAttributePipe<Me, String>(FIELD_KnownAsAlias)); }
public TestInput.TestInputPipeLineFactory<From, TestInput> toTestInput () { return toTestInput (Filter.ALL); }
public TestInput.TestInputPipeLineFactory<From, TestInput> toTestInput (Filter<TestInput> filter)
......
......@@ -7,6 +7,7 @@ import java.util.Comparator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import oneit.logging.LoggingArea;
import oneit.objstore.MessageSource;
import oneit.objstore.ObjectTransaction;
import oneit.objstore.rdbms.filters.EqualsFilter;
......@@ -25,6 +26,7 @@ import performa.utils.ExpressAnswerFilter;
public class Candidate extends BaseCandidate
{
public static LoggingArea LOG = LoggingArea.createLoggingArea("Candidate");
private static final long serialVersionUID = 0L;
// This constructor should not be called
......@@ -181,4 +183,9 @@ public class Candidate extends BaseCandidate
Distance calculateDistance = DistanceUtils.calculateDistance(FIELD_Phone, FIELD_Phone);
return false;
}
public boolean isUnverifiedEmailIngestUser()
{
return !isTrue(getIsAccountVerified()) && isTrue(getIsEmailIngest());
}
}
\ No newline at end of file
......@@ -23,6 +23,9 @@
<ATTRIB name="VerificationKey" type="String" dbcol="verification_key" length="10"/>
<ATTRIB name="IsAccountVerified" type="Boolean" dbcol="is_account_verified" defaultValue="Boolean.FALSE"/>
<ATTRIB name="GoogleAddressText" type="String" dbcol="google_address_text" length="300"/>
<ATTRIB name="IsEmailIngest" type="Boolean" dbcol="is_email_ingest" defaultValue="Boolean.FALSE"/>
<ATTRIB name="IsMaskedEmail" type="Boolean" dbcol="is_masked_email" defaultValue="Boolean.FALSE"/>
<ATTRIB name="KnownAsAlias" type="String" dbcol="known_as_alias" length="100"/>
<SINGLEREFERENCE name="TestInput" type="TestInput" dbcol="test_input_id" backreferenceName="Candidates" />
<SINGLEREFERENCE name="User" type="SecUser" dbcol="user_id" backreferenceName="Extensions" inSuper='TRUE'/>
......@@ -31,6 +34,10 @@
<SEARCH type="All" paramFilter="oneit_sec_user_extension.object_id is not null" >
</SEARCH>
<SEARCH type="Alias" filter="known_as_alias = ?" polymorphic="TRUE" singleton="TRUE">
<PARAM name="KnownAs" type="String"/>
</SEARCH>
<SEARCH type="IdPin" paramFilter="oneit_sec_user_extension.object_id is not null" singleton="TRUE">
<PARAM name="ID" type="Long" paramFilter="object_id = ${ID} " />
<PARAM name="Pin" type="String" paramFilter="verification_key = ${Pin}" />
......
......@@ -34,6 +34,9 @@ public class CandidatePersistenceMgr extends SecUserExtensionPersistenceMgr
private String dummyVerificationKey;
private Boolean dummyIsAccountVerified;
private String dummyGoogleAddressText;
private Boolean dummyIsEmailIngest;
private Boolean dummyIsMaskedEmail;
private String dummyKnownAsAlias;
// Static constants corresponding to attribute helpers
......@@ -44,6 +47,9 @@ public class CandidatePersistenceMgr extends SecUserExtensionPersistenceMgr
private static final DefaultAttributeHelper HELPER_VerificationKey = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_IsAccountVerified = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_GoogleAddressText = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_IsEmailIngest = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_IsMaskedEmail = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_KnownAsAlias = DefaultAttributeHelper.INSTANCE;
......@@ -57,10 +63,13 @@ public class CandidatePersistenceMgr extends SecUserExtensionPersistenceMgr
dummyVerificationKey = (String)(HELPER_VerificationKey.initialise (dummyVerificationKey));
dummyIsAccountVerified = (Boolean)(HELPER_IsAccountVerified.initialise (dummyIsAccountVerified));
dummyGoogleAddressText = (String)(HELPER_GoogleAddressText.initialise (dummyGoogleAddressText));
dummyIsEmailIngest = (Boolean)(HELPER_IsEmailIngest.initialise (dummyIsEmailIngest));
dummyIsMaskedEmail = (Boolean)(HELPER_IsMaskedEmail.initialise (dummyIsMaskedEmail));
dummyKnownAsAlias = (String)(HELPER_KnownAsAlias.initialise (dummyKnownAsAlias));
}
private String SELECT_COLUMNS = "{PREFIX}oneit_sec_user_extension.object_id as id, {PREFIX}oneit_sec_user_extension.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}oneit_sec_user_extension.object_CREATED_DATE as CREATED_DATE, {PREFIX}oneit_sec_user_extension.object_TYPE as OBJECT_TYPE, {PREFIX}oneit_sec_user_extension.phone, {PREFIX}oneit_sec_user_extension.forgot_password_mail_send_date, {PREFIX}oneit_sec_user_extension.forgot_password_key, {PREFIX}oneit_sec_user_extension.verification_mail_send_date, {PREFIX}oneit_sec_user_extension.verification_key, {PREFIX}oneit_sec_user_extension.is_account_verified, {PREFIX}oneit_sec_user_extension.google_address_text, {PREFIX}oneit_sec_user_extension.test_input_id, {PREFIX}oneit_sec_user_extension.user_id, 1 AS commasafe ";
private String SELECT_COLUMNS = "{PREFIX}oneit_sec_user_extension.object_id as id, {PREFIX}oneit_sec_user_extension.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}oneit_sec_user_extension.object_CREATED_DATE as CREATED_DATE, {PREFIX}oneit_sec_user_extension.object_TYPE as OBJECT_TYPE, {PREFIX}oneit_sec_user_extension.phone, {PREFIX}oneit_sec_user_extension.forgot_password_mail_send_date, {PREFIX}oneit_sec_user_extension.forgot_password_key, {PREFIX}oneit_sec_user_extension.verification_mail_send_date, {PREFIX}oneit_sec_user_extension.verification_key, {PREFIX}oneit_sec_user_extension.is_account_verified, {PREFIX}oneit_sec_user_extension.google_address_text, {PREFIX}oneit_sec_user_extension.is_email_ingest, {PREFIX}oneit_sec_user_extension.is_masked_email, {PREFIX}oneit_sec_user_extension.known_as_alias, {PREFIX}oneit_sec_user_extension.test_input_id, {PREFIX}oneit_sec_user_extension.user_id, 1 AS commasafe ";
private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
......@@ -119,6 +128,9 @@ public class CandidatePersistenceMgr extends SecUserExtensionPersistenceMgr
!oneit_sec_user_extensionPSet.containsAttrib(Candidate.FIELD_VerificationKey)||
!oneit_sec_user_extensionPSet.containsAttrib(Candidate.FIELD_IsAccountVerified)||
!oneit_sec_user_extensionPSet.containsAttrib(Candidate.FIELD_GoogleAddressText)||
!oneit_sec_user_extensionPSet.containsAttrib(Candidate.FIELD_IsEmailIngest)||
!oneit_sec_user_extensionPSet.containsAttrib(Candidate.FIELD_IsMaskedEmail)||
!oneit_sec_user_extensionPSet.containsAttrib(Candidate.FIELD_KnownAsAlias)||
!oneit_sec_user_extensionPSet.containsAttrib(Candidate.SINGLEREFERENCE_TestInput)||
!oneit_sec_user_extensionPSet.containsAttrib(Candidate.SINGLEREFERENCE_User))
{
......@@ -219,10 +231,10 @@ public class CandidatePersistenceMgr extends SecUserExtensionPersistenceMgr
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}oneit_sec_user_extension " +
"SET phone = ?, forgot_password_mail_send_date = ?, forgot_password_key = ?, verification_mail_send_date = ?, verification_key = ?, is_account_verified = ?, google_address_text = ?, test_input_id = ? , user_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"SET phone = ?, forgot_password_mail_send_date = ?, forgot_password_key = ?, verification_mail_send_date = ?, verification_key = ?, is_account_verified = ?, google_address_text = ?, is_email_ingest = ?, is_masked_email = ?, known_as_alias = ?, test_input_id = ? , user_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE oneit_sec_user_extension.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_Phone.getForSQL(dummyPhone, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_Phone))).listEntry (HELPER_ForgotPasswordMailSendDate.getForSQL(dummyForgotPasswordMailSendDate, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_ForgotPasswordMailSendDate))).listEntry (HELPER_ForgotPasswordKey.getForSQL(dummyForgotPasswordKey, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_ForgotPasswordKey))).listEntry (HELPER_VerificationMailSendDate.getForSQL(dummyVerificationMailSendDate, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_VerificationMailSendDate))).listEntry (HELPER_VerificationKey.getForSQL(dummyVerificationKey, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_VerificationKey))).listEntry (HELPER_IsAccountVerified.getForSQL(dummyIsAccountVerified, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_IsAccountVerified))).listEntry (HELPER_GoogleAddressText.getForSQL(dummyGoogleAddressText, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_GoogleAddressText))).listEntry (SQLManager.CheckNull((Long)(oneit_sec_user_extensionPSet.getAttrib (Candidate.SINGLEREFERENCE_TestInput)))).listEntry (SQLManager.CheckNull((Long)(oneit_sec_user_extensionPSet.getAttrib (Candidate.SINGLEREFERENCE_User)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
CollectionUtils.listEntry (HELPER_Phone.getForSQL(dummyPhone, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_Phone))).listEntry (HELPER_ForgotPasswordMailSendDate.getForSQL(dummyForgotPasswordMailSendDate, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_ForgotPasswordMailSendDate))).listEntry (HELPER_ForgotPasswordKey.getForSQL(dummyForgotPasswordKey, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_ForgotPasswordKey))).listEntry (HELPER_VerificationMailSendDate.getForSQL(dummyVerificationMailSendDate, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_VerificationMailSendDate))).listEntry (HELPER_VerificationKey.getForSQL(dummyVerificationKey, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_VerificationKey))).listEntry (HELPER_IsAccountVerified.getForSQL(dummyIsAccountVerified, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_IsAccountVerified))).listEntry (HELPER_GoogleAddressText.getForSQL(dummyGoogleAddressText, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_GoogleAddressText))).listEntry (HELPER_IsEmailIngest.getForSQL(dummyIsEmailIngest, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_IsEmailIngest))).listEntry (HELPER_IsMaskedEmail.getForSQL(dummyIsMaskedEmail, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_IsMaskedEmail))).listEntry (HELPER_KnownAsAlias.getForSQL(dummyKnownAsAlias, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_KnownAsAlias))).listEntry (SQLManager.CheckNull((Long)(oneit_sec_user_extensionPSet.getAttrib (Candidate.SINGLEREFERENCE_TestInput)))).listEntry (SQLManager.CheckNull((Long)(oneit_sec_user_extensionPSet.getAttrib (Candidate.SINGLEREFERENCE_User)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1)
{
......@@ -310,6 +322,10 @@ public class CandidatePersistenceMgr extends SecUserExtensionPersistenceMgr
{
throw new RuntimeException ("NOT implemented: executeSearchQueryAll");
}
public ResultSet executeSearchQueryAlias (SQLManager sqlMgr, String KnownAs) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryAlias");
}
public ResultSet executeSearchQueryIdPin (SQLManager sqlMgr, Long ID, String Pin) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryIdPin");
......@@ -494,6 +510,37 @@ public class CandidatePersistenceMgr extends SecUserExtensionPersistenceMgr
return results;
}
else if (searchType.equals (Candidate.SEARCH_Alias))
{
// Local scope for transformed variables
{
}
String orderBy = " ";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter:
filter = "known_as_alias = ?"
+ " ";
searchParams = new Object[] { criteria.get ("KnownAs") };
Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}oneit_sec_user_extension " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else if (searchType.equals (Candidate.SEARCH_IdPin))
{
// Local scope for transformed variables
......@@ -592,6 +639,9 @@ public class CandidatePersistenceMgr extends SecUserExtensionPersistenceMgr
oneit_sec_user_extensionPSet.setAttrib(Candidate.FIELD_VerificationKey, HELPER_VerificationKey.getFromRS(dummyVerificationKey, r, "verification_key"));
oneit_sec_user_extensionPSet.setAttrib(Candidate.FIELD_IsAccountVerified, HELPER_IsAccountVerified.getFromRS(dummyIsAccountVerified, r, "is_account_verified"));
oneit_sec_user_extensionPSet.setAttrib(Candidate.FIELD_GoogleAddressText, HELPER_GoogleAddressText.getFromRS(dummyGoogleAddressText, r, "google_address_text"));
oneit_sec_user_extensionPSet.setAttrib(Candidate.FIELD_IsEmailIngest, HELPER_IsEmailIngest.getFromRS(dummyIsEmailIngest, r, "is_email_ingest"));
oneit_sec_user_extensionPSet.setAttrib(Candidate.FIELD_IsMaskedEmail, HELPER_IsMaskedEmail.getFromRS(dummyIsMaskedEmail, r, "is_masked_email"));
oneit_sec_user_extensionPSet.setAttrib(Candidate.FIELD_KnownAsAlias, HELPER_KnownAsAlias.getFromRS(dummyKnownAsAlias, r, "known_as_alias"));
oneit_sec_user_extensionPSet.setAttrib(Candidate.SINGLEREFERENCE_TestInput, r.getObject ("test_input_id"));
oneit_sec_user_extensionPSet.setAttrib(Candidate.SINGLEREFERENCE_User, r.getObject ("user_id"));
......@@ -611,10 +661,10 @@ public class CandidatePersistenceMgr extends SecUserExtensionPersistenceMgr
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}oneit_sec_user_extension " +
" (phone, forgot_password_mail_send_date, forgot_password_key, verification_mail_send_date, verification_key, is_account_verified, google_address_text, test_input_id, user_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE, object_TYPE) " +
" (phone, forgot_password_mail_send_date, forgot_password_key, verification_mail_send_date, verification_key, is_account_verified, google_address_text, is_email_ingest, is_masked_email, known_as_alias, test_input_id, user_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE, object_TYPE) " +
"VALUES " +
" (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", ?)",
CollectionUtils.listEntry (HELPER_Phone.getForSQL(dummyPhone, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_Phone))).listEntry (HELPER_ForgotPasswordMailSendDate.getForSQL(dummyForgotPasswordMailSendDate, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_ForgotPasswordMailSendDate))).listEntry (HELPER_ForgotPasswordKey.getForSQL(dummyForgotPasswordKey, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_ForgotPasswordKey))).listEntry (HELPER_VerificationMailSendDate.getForSQL(dummyVerificationMailSendDate, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_VerificationMailSendDate))).listEntry (HELPER_VerificationKey.getForSQL(dummyVerificationKey, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_VerificationKey))).listEntry (HELPER_IsAccountVerified.getForSQL(dummyIsAccountVerified, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_IsAccountVerified))).listEntry (HELPER_GoogleAddressText.getForSQL(dummyGoogleAddressText, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_GoogleAddressText))) .listEntry (SQLManager.CheckNull((Long)(oneit_sec_user_extensionPSet.getAttrib (Candidate.SINGLEREFERENCE_TestInput)))).listEntry (SQLManager.CheckNull((Long)(oneit_sec_user_extensionPSet.getAttrib (Candidate.SINGLEREFERENCE_User)))) .listEntry (objectID.longID ()).listEntry (context.getTag (obj)).toList().toArray());
" (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", ?)",
CollectionUtils.listEntry (HELPER_Phone.getForSQL(dummyPhone, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_Phone))).listEntry (HELPER_ForgotPasswordMailSendDate.getForSQL(dummyForgotPasswordMailSendDate, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_ForgotPasswordMailSendDate))).listEntry (HELPER_ForgotPasswordKey.getForSQL(dummyForgotPasswordKey, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_ForgotPasswordKey))).listEntry (HELPER_VerificationMailSendDate.getForSQL(dummyVerificationMailSendDate, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_VerificationMailSendDate))).listEntry (HELPER_VerificationKey.getForSQL(dummyVerificationKey, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_VerificationKey))).listEntry (HELPER_IsAccountVerified.getForSQL(dummyIsAccountVerified, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_IsAccountVerified))).listEntry (HELPER_GoogleAddressText.getForSQL(dummyGoogleAddressText, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_GoogleAddressText))).listEntry (HELPER_IsEmailIngest.getForSQL(dummyIsEmailIngest, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_IsEmailIngest))).listEntry (HELPER_IsMaskedEmail.getForSQL(dummyIsMaskedEmail, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_IsMaskedEmail))).listEntry (HELPER_KnownAsAlias.getForSQL(dummyKnownAsAlias, oneit_sec_user_extensionPSet.getAttrib (Candidate.FIELD_KnownAsAlias))) .listEntry (SQLManager.CheckNull((Long)(oneit_sec_user_extensionPSet.getAttrib (Candidate.SINGLEREFERENCE_TestInput)))).listEntry (SQLManager.CheckNull((Long)(oneit_sec_user_extensionPSet.getAttrib (Candidate.SINGLEREFERENCE_User)))) .listEntry (objectID.longID ()).listEntry (context.getTag (obj)).toList().toArray());
oneit_sec_user_extensionPSet.setStatus (PersistentSetStatus.PROCESSED);
}
......
......@@ -105,14 +105,14 @@ public class JobApplication extends BaseJobApplication
if(getCV() != null)
{
String contentType = getCV().getContentType();
context.check(contentType.contains("msword") || contentType.contains("opendocument.text")
context.check(contentType.contains("msword") || contentType.contains("doc") || contentType.contains("docx") || contentType.contains("opendocument.text")
|| contentType.contains("pdf") || contentType.contains("vnd.openxmlformats-officedocument.wordprocessingml.document") , this, FIELD_CV, "invalid");
}
if(getCoverLetter() != null)
{
String contentType = getCoverLetter().getContentType();
context.check(contentType.contains("msword") || contentType.contains("opendocument.text")
context.check(contentType.contains("msword") || contentType.contains("doc") || contentType.contains("docx") || contentType.contains("opendocument.text")
|| contentType.contains("pdf") || contentType.contains("vnd.openxmlformats-officedocument.wordprocessingml.document") , this, FIELD_CoverLetter, "invalid");
}
}
......
......@@ -7,10 +7,12 @@ import javax.mail.internet.*;
import javax.mail.search.*;
import oneit.appservices.config.ConfigMgr;
import oneit.components.*;
import oneit.email.ConfigurableArticleTemplateEmailer;
import oneit.email.EmailFetcher;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.services.*;
import oneit.security.SecUser;
import oneit.utils.*;
import oneit.utils.parsers.FieldException;
import performa.orm.*;
......@@ -20,13 +22,15 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
{
private static final String SERVER_NAME = ConfigMgr.getKeyfileString("imap.server.name");
private static final String SERVER_PORT = ConfigMgr.getKeyfileString("imap.server.port");
private static final String SERVER_PROTOCOL = ConfigMgr.getKeyfileString("imap.server.protocol", "imap");
private static final String SERVER_PROTOCOL = ConfigMgr.getKeyfileString("imap.server.protocol", "imaps");
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", 90); //Applicable only when SYNC_ALL_EXISTING_EMAILS is false.
private static final boolean SYNC_ALL_EXISTING_EMAILS = ConfigMgr.getKeyfileBoolean("sync.all.existing.emails", true);
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.
public static final LoggingArea LOG = LoggingArea.createLoggingArea("PerformaEmailFetcher");
private static ConfigurableArticleTemplateEmailer emailer;
@Override
public void run()
{
......@@ -223,6 +227,9 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
LogMgr.log(LOG, LogLevel.PROCESSING2 , "processMessage called");
String tmpFromAdress = null;
String tmpReplyTo = null;
String tmpFirstName = null;
String tmpLastName = null;
String tmpEmailText;
String tmpSubject;
Date tmpSentDate;
......@@ -233,6 +240,9 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
List<FileBinaryContent> tmpContents;
final String fromAddress;
final String firstName;
final String lastName;
final String replyTo;
final String recipient;
final String subject;
final Date sentDate;
......@@ -251,7 +261,16 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
tmpSubject = message.getSubject();
tmpSentDate = message.getReceivedDate();
tmpMessageID = ((MimeMessage)message).getMessageID();
if(message.getReplyTo() != null && message.getReplyTo().length > 0)
{
tmpReplyTo = ((InternetAddress) message.getReplyTo()[0]).getAddress();
String name = ((InternetAddress) message.getReplyTo()[0]).getPersonal();
tmpFirstName = getFirstName(name);
tmpLastName = getLastName(name);
}
LogMgr.log(LOG, LogLevel.PROCESSING2 , "Mail Subject:" + tmpSubject, " Address:", tmpFromAdress, " MessageId:", tmpMessageID);
LogMgr.log(LOG, LogLevel.PROCESSING2 , "Mail Details: Received ", message.getReceivedDate(), " Sent:", message.getSentDate());
......@@ -276,6 +295,9 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
}
fromAddress = tmpFromAdress;
firstName = tmpFirstName;
lastName = tmpLastName;
replyTo = tmpReplyTo;
subject = tmpSubject;
sentDate = tmpSentDate;
jobIdentifier = tmpJobId;
......@@ -299,26 +321,148 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
if (job != null)
{
EmailMessage emailMessage = EmailMessage.createEmailMessage(objTran);
emailMessage.setMessageId(messageID);
emailMessage.setEmailFrom(fromAddress);
emailMessage.setEmailTo(recipient);
emailMessage.setSubject(subject);
emailMessage.setDescription(emailText);
emailMessage.setReceivedDate(sentDate);
emailMessage.setJob(job);
for (FileBinaryContent content : contents)
createEmailMessage(objTran, job);
if(fromAddress.contains("indeedemail.com"))
{
Attachment attachment = Attachment.createAttachment(objTran);
attachment.setAttachmentFile(content);
emailMessage.addToAttachments(attachment);
handleIndeedEmail(objTran, job);
}
else if(fromAddress.contains("seek.com.au"))
{
// handle seek email
if(replyTo == null || replyTo.isEmpty())
{
// might have to check email body if reply to is not set
return;
}
handleSeekEmail(objTran, job);
}
}
}
}
private void handleSeekEmail(ObjectTransaction objTran, Job job) throws StorageException, FieldException
{
SecUser secUser = SecUser.searchNAME(objTran, replyTo);
boolean newUser = false;
if(secUser == null)
{
newUser = true;
secUser = SecUser.createSecUser(objTran);
secUser.setUserName(replyTo);
secUser.setEmail(replyTo);
secUser.setAttribute("md5:" + SecUser.FIELD_Password, CompanyUser.DEFAULT_PASSWORD);
secUser.addRole(Utils.getRole(Utils.ROLE_APPLICANT, objTran));
secUser.setFirstName(firstName);
secUser.setLastName(lastName);
}
Candidate candidate = secUser.getExtensionOrCreate(Candidate.REFERENCE_Candidate);
if(newUser)
{
candidate.setIsEmailIngest(true);
}
JobApplication jobApplication = JobApplication.createNewApplication(candidate, job);
if(contents.size() > 0)
{
jobApplication.setCV(contents.get(0));
}
if(contents.size() > 1)
{
jobApplication.setCoverLetter(contents.get(1));
}
sendVerificationEmail(newUser, candidate, job);
}
private void sendVerificationEmail(boolean newUser, Candidate candidate, Job job)
{
try
{
if(newUser)
{
Utils.sendVerificationMail(candidate, job, emailer, PerformaEmailFetcher.class.getName());
}
}
catch (BusinessException e)
{
LogMgr.log(LOG, LogLevel.PROCESSING2 , e, "Batch Email Fetcher : Error while sending verification email ");
}
}
private void handleIndeedEmail(ObjectTransaction objTran, Job job) throws StorageException, FieldException
{
// handle indeed email
Candidate candidate = Candidate.searchAlias(objTran, fromAddress);
SecUser secUser = SecUser.searchNAME(objTran, fromAddress);
boolean newUser = false;
if(candidate != null)
{
secUser = candidate.getUser();
}
if(secUser == null)
{
secUser = SecUser.createSecUser(objTran);
newUser = true;
secUser.setUserName(fromAddress);
secUser.setEmail(fromAddress);
secUser.setAttribute("md5:" + SecUser.FIELD_Password, CompanyUser.DEFAULT_PASSWORD);
secUser.addRole(Utils.getRole(Utils.ROLE_APPLICANT, objTran));
secUser.setFirstName(firstName);
secUser.setLastName(lastName);
}
if(candidate == null)
{
candidate = secUser.getExtensionOrCreate(Candidate.REFERENCE_Candidate);
}
if(newUser)
{
candidate.setIsEmailIngest(true);
candidate.setIsMaskedEmail(true);
}
JobApplication jobApplication = JobApplication.createNewApplication(candidate, job);
if(contents.size() > 0)
{
jobApplication.setCV(contents.get(0));
}
sendVerificationEmail(newUser, candidate, job);
}
private void createEmailMessage(ObjectTransaction objTran, Job job) throws StorageException, FieldException
{
EmailMessage emailMessage = EmailMessage.createEmailMessage(objTran);
emailMessage.setMessageId(messageID);
emailMessage.setEmailFrom(fromAddress);
emailMessage.setEmailTo(recipient);
emailMessage.setSubject(subject);
emailMessage.setDescription(emailText);
emailMessage.setReceivedDate(sentDate);
emailMessage.setJob(job);
for (FileBinaryContent content : contents)
{
Attachment attachment = Attachment.createAttachment(objTran);
attachment.setAttachmentFile(content);
emailMessage.addToAttachments(attachment);
}
}
});
LogMgr.log(LOG, LogLevel.PROCESSING2 , "processMessage completed successfully");
......@@ -334,12 +478,22 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
LogMgr.log(LOG, LogLevel.PROCESSING2 , e, "Batch Email Fetcher : Error in creating the email message ");
}
}
private static String getFirstName(String name)
{
return (name.split("\\w+").length > 1) ? name.substring(0, name.lastIndexOf(' ')) : name;
}
private static String getLastName(String name)
{
return (name.split("\\w+").length > 1) ? name.substring(name.lastIndexOf(" ")+1) : "";
}
public static String getJobIdentifierFromEmail(String strReceipient)
{
int index = strReceipient.indexOf('@');
return strReceipient.substring(0, index);
return strReceipient.substring(0, index).replace("job", "");
}
private static List<FileBinaryContent> getAttachments(Message message) throws IOException, MessagingException
......@@ -372,11 +526,12 @@ public class PerformaEmailFetcher implements Runnable, InitialisationParticipant
return DateDiff.before(new Date(), SYNC_EMAILS_SINCE_MINUTES, Calendar.MINUTE);
}
@Override
public void init(ParticipantInitialisationContext pic) throws InitialisationException
{
}
public void init (ParticipantInitialisationContext context) throws InitialisationException
{
emailer = (ConfigurableArticleTemplateEmailer)(context.getSingleChild("AccountVerificationEmailer"));
}
public static final void main (String[] args) throws Exception
{
......
......@@ -43,8 +43,8 @@ public class Utils
public static final String PRIV_ACCESS_APPLICANT_PORTAL = "TL_AccessApplicantPortal";
public static final String PRIV_ACCESS_COMPANY_ADMIN = "TL_AccessCompanyAdmin";
public static final String PRIV_ACCESS_COMPANY = "TL_AccessCompany";
public static final String ADVT_CONFIG_EMAIL_EXTENSION = ConfigMgr.getKeyfileString ("advt.config.email.extension", "matchdmail.com");
public static final String APPLICANT_VERIFY_LINK = "/ApplicantPortal-Applicant_Account_Verification.htm";
public static Role getRole(String role, ObjectTransaction transaction)
{
......@@ -428,6 +428,48 @@ public class Utils
}
public static void sendVerificationMail(Candidate candidate, Job job, ConfigurableArticleTemplateEmailer emailer, String callingClass) throws BusinessException
{
if(!candidate.isTrue(candidate.getIsAccountVerified()))
{
try
{
LogMgr.log(Candidate.LOG, LogLevel.PROCESSING1, "Sending verification mail from SendVerificationMailFP to :: ", candidate);
RandomStringGen random = new RandomStringGen();
//set verification key and send mail time
candidate.setVerificationKey(random.generateAlphaNum(6));
candidate.setVerificationMailSendDate(new Date());
String link = LoopbackHTTP.getRemoteAccessURL()
+ APPLICANT_VERIFY_LINK
+ "?id=" + job.getID()
+ "&key=" + job.getRandomKey()
+ "&aid=" + candidate.getID()
+ "&pin=" + candidate.getVerificationKey();
Map defaultParams = CollectionUtils.mapEntry("link", link).toMap();
ObjectTransform transform = Utils.createCompoundTransform(defaultParams, candidate.getUser(), job);
Utils.sendMail(emailer, transform, new String[]{candidate.getUser().getUserName()}, null, candidate);
LogMgr.log(Candidate.LOG, LogLevel.PROCESSING1, "Sent verification mail successfully from " + callingClass + " to :: ", candidate);
}
catch (ConfigurableEmailerException ex)
{
LogMgr.log(Candidate.LOG, LogLevel.SYSTEMERROR1, ex, "Error occured while sending mail for Candidate :: " + candidate);
throw new BusinessException("We are unable to send mail. Please try again or contact Matchd for more details.");
}
}
else
{
LogMgr.log(Candidate.LOG, LogLevel.PROCESSING1, "Call from " + callingClass + ". Account is already verified for candidate :: ", candidate);
}
}
public static void sendVerificationMail(Job job, CompanyUser companyUser, HttpServletRequest request, ConfigurableArticleTemplateEmailer emailer, String callingClass) throws BusinessException
{
if(!CollectionUtils.equals(companyUser.getIsAccountVerified(), Boolean.TRUE))
......@@ -468,6 +510,40 @@ public class Utils
}
public static void sendMaskedEmailChangedMail(Candidate candidate, Job job, ConfigurableArticleTemplateEmailer emailer) throws BusinessException
{
try
{
LogMgr.log(Candidate.LOG, LogLevel.PROCESSING1, "Sending masked email changed mail to :: ", candidate);
RandomStringGen random = new RandomStringGen();
//set verification key and send mail time
candidate.setVerificationKey(random.generateAlphaNum(6));
candidate.setVerificationMailSendDate(new Date());
String link = LoopbackHTTP.getRemoteAccessURL()
+ APPLICANT_VERIFY_LINK
+ "?id=" + job.getID()
+ "&key=" + job.getRandomKey()
+ "&aid=" + candidate.getID()
+ "&pin=" + candidate.getVerificationKey();
Map defaultParams = CollectionUtils.mapEntry("link", link).toMap();
ObjectTransform transform = Utils.createCompoundTransform(defaultParams, candidate.getUser(), job);
Utils.sendMail(emailer, transform, new String[]{candidate.getUser().getEmail()}, null, candidate);
LogMgr.log(CompanyUser.LOG, LogLevel.PROCESSING1, "Sent masked email changed mail successfully to :: ", candidate);
}
catch (ConfigurableEmailerException ex)
{
LogMgr.log(CompanyUser.LOG, LogLevel.SYSTEMERROR1, ex, "Error occured while sending mail for user :: " + candidate);
throw new BusinessException("We are unable to send mail. Please try again or contact Matchd for more details.");
}
}
public static void sendEmailChangedMail(CompanyUser companyUser, HttpServletRequest request, ConfigurableArticleTemplateEmailer emailer, String callingClass) throws BusinessException
{
if(companyUser.getIsEmailChanged()==Boolean.TRUE)
......
......@@ -13,6 +13,7 @@
<FORM name="*.saveAndExitWorkStyle" factory="Participant" class="performa.form.SaveAndExitWorkStypeFP"/>
<FORM name="*.sendVerificationMail" factory="Participant" class="performa.form.SendVerificationMailFP">
<AccountVerificationEmailer factory="Participant" class="oneit.email.ConfigurableArticleTemplateEmailer" templateShortcut="AccountVerificationMail"/>
<EmailChangedEmailer factory="Participant" class="oneit.email.ConfigurableArticleTemplateEmailer" templateShortcut="EmailChangedMail"/>
</FORM>
<FORM name="*.facebookOAuthLogin" factory="Participant" class="oneit.security.oauth.form.FacebookOAuthLoginFP"/>
<FORM name="*.googleOAuthLogin" factory="Participant" class="oneit.security.oauth.form.GoogleOAuthLoginFP"/>
......
......@@ -53,9 +53,20 @@
Debug.assertion(job != null && !toRedirect, "Invalid job in applicant portal");
Debug.assertion(candidate != null, "Invalid candidate in applicant portal");
JobApplication jobApplication = JobApplication.searchCandidateJob(transaction, candidate, job);
Article applyJobArticle = WebUtils.getArticleByShortCut(objTran, WebUtils.JOB_APPLICATION);
String nextPage = applyJobArticle.getLink(request, CollectionUtils.mapEntry("cms.rm", job.getIncludeAssessmentCriteria() ? "SelectionCriteria" : "WorkplaceCulture").toMap());
Article applyJobArticle = WebUtils.getArticleByShortCut(objTran, WebUtils.APPLY_JOB);
String confirmDetailsPage = LoopbackHTTP.getRemoteAccessURL(request)
+ applyJobArticle.getLink(request, CollectionUtils.mapEntry("cms.rm", "VerifyIdentity").toMap(), "/");
if(candidate.isUnverifiedEmailIngestUser() && candidate.getKnownAsAlias() == null)
{
request.getSession().setAttribute (SecUser.SEC_USER_ID, secUser);
request.getSession().setAttribute (SessionSecUserDecorator.REFRESH_SECURITY, Boolean.TRUE);
response.sendRedirect(confirmDetailsPage + "&JobID=" + job.getID().toString());
}
JobApplication jobApplication = JobApplication.searchCandidateJob(transaction, candidate, job);
Article jobApplicationArticle = WebUtils.getArticleByShortCut(objTran, WebUtils.JOB_APPLICATION);
String nextPage = jobApplicationArticle.getLink(request, CollectionUtils.mapEntry("cms.rm", job.getIncludeAssessmentCriteria() ? "SelectionCriteria" : "WorkplaceCulture").toMap());
process.setAttribute("JobApplication", jobApplication);
%>
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au">
<NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.RedefineTableOperation">
<tableName factory="String">oneit_sec_user_extension</tableName>
<column name="is_email_ingest" type="Boolean" nullable="true"/>
<column name="is_masked_email" type="Boolean" nullable="true"/>
<column name="known_as_alias" type="String" nullable="true" length="100"/>
</NODE>
</NODE>
</OBJECTS>
\ No newline at end of file
......@@ -5,23 +5,30 @@
<oneit:dynIncluded>
<%
ObjectTransaction objTran = process.getTransaction ();
boolean toRedirect = GenericObjDF.getOrCreateObject (request, "Job", Job.REFERENCE_Job);
Job job = (Job) process.getAttribute("Job");
Debug.assertion(job != null && !toRedirect, "Invalid job in applicant portal");
Candidate candidate = (Candidate) process.getAttribute("NewCandidate");
Job job = (Job) process.getAttribute("Job");
String successPage = WebUtils.getSamePageInRenderMode(request, "VerificationSent");
SecUser secUser = null;
boolean toRedirect = false;
if(candidate != null)
SecUser secUser = SecUser.getTXUser(transaction);
if(candidate == null && secUser != null)
{
candidate = secUser.getExtension(Candidate.REFERENCE_Candidate);
}
if(secUser == null && candidate != null)
{
secUser = candidate.getUser();
process.setAttribute("NewCandidate", candidate);
}
Debug.assertion(job != null && !toRedirect, "Invalid job in applicant portal");
Debug.assertion(candidate != null, "Invalid candidate in applicant portal");
String successPage = WebUtils.getSamePageInRenderMode(request, "VerificationSent") + "&JobID=" + job.getID();
String applyJobPage = WebUtils.getArticleByShortCut(transaction, WebUtils.JOB_APPLICATION).getLink(request) + "?JobID=" + job.getID();
JobApplication jobApplication = JobApplication.searchCandidateJob(transaction, candidate, job);
String nextPage = WebUtils.getSamePageInRenderMode(request, "Page");
if(jobApplication == null)
{
......@@ -129,7 +136,20 @@
<div class="main-box-layout main-verify-step-2">
<div class="form-group text-left">
<label>Email Address</label>
<oneit:ormInput obj="<%= secUser %>" type="text" attributeName="Email" cssClass="form-control second-style" disabled="true" readonly="true"/>
<%
if(candidate.isUnverifiedEmailIngestUser() && candidate.isTrue(candidate.getIsMaskedEmail()))
{
%>
<oneit:ormInput obj="<%= secUser %>" type="text" attributeName="Email" cssClass="form-control" style="text-transform: lowercase" required="true"/>
<%
}
else
{
%>
<oneit:ormInput obj="<%= secUser %>" type="text" attributeName="Email" cssClass="form-control second-style" disabled="true" readonly="true"/>
<%
}
%>
</div>
<div class="form-group text-left email">
......@@ -245,14 +265,31 @@
</div>
</div>
<div class="text-center">
<oneit:button value="Submit" name="sendVerificationMail" cssClass="box-btn send-link-btn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", successPage)
.mapEntry("Job",job)
.mapEntry("Candidate",candidate)
.mapEntry("JobApplication",jobApplication)
.mapEntry(NotificationUtils.NOTIFICATION_MSG_PARAM, "emailSent")
.toMap() %>"/>
<%
if(candidate.isUnverifiedEmailIngestUser() && !candidate.isTrue(candidate.getIsMaskedEmail()))
{
%>
<oneit:button value="Verify and proceed" name="sendVerificationMail" cssClass="box-btn send-link-btn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", applyJobPage)
.mapEntry("Job",job)
.mapEntry("Candidate",candidate)
.mapEntry("JobApplication",jobApplication)
.toMap() %>"/>
<%
}
else
{
%>
<oneit:button value="Submit" name="sendVerificationMail" cssClass="box-btn send-link-btn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", successPage)
.mapEntry("Job",job)
.mapEntry("Candidate",candidate)
.mapEntry("JobApplication",jobApplication)
.mapEntry(NotificationUtils.NOTIFICATION_MSG_PARAM, "emailSent")
.toMap() %>"/>
<%
}
%>
</div>
</div>
</div>
......
......@@ -32,15 +32,17 @@
<MAP value="HOME_TL" description="HomePage" JSP="/extensions/performa/editor/additionalHomePage.jsp" />
</NODE>
<!-- <NODE name="WEB_BATCH::Email">
<NODE name="WEB_BATCH::Email">
<TASK factory="Participant" class="oneit.appservices.batch.DefaultTask">
<RUN class="performa.utils.PerformaEmailFetcher" factory="Participant" />
<RUN class="performa.utils.PerformaEmailFetcher" factory="Participant">
<AccountVerificationEmailer factory="Participant" class="oneit.email.ConfigurableArticleTemplateEmailer" templateShortcut="AccountVerificationMail"/>
</RUN>
<WHEN factory="MetaComponent" component="BatchSchedule" selector="performa.runbatch">
<NODE name="schedule" class="oneit.appservices.batch.QuickSchedule">
<NODE name="period" factory="Integer" value="5"/>
</NODE>
</WHEN>
</TASK>
</NODE>-->
</NODE>
</OBJECTS>
\ No newline at end of file
<%@ page import="performa.orm.*, performa.orm.types.*, performa.form.*, performa.utils.*, performa.search.*"%>
<%@ page import="com.stripe.model.*"%>
<%@ page import="oneit.objstore.rdbms.filters.*, oneit.security.jsp.SecUserToNameTransform, oneit.servlets.utils.*, oneit.utils.image.*, oneit.objstore.utils.ObjstoreUtils "%>
<%@ page import="oneit.utils.text.FormatUtils, oneit.utils.math.*"%>
<%@ page import="oneit.objstore.rdbms.filters.*, oneit.servlets.security.SessionSecUserDecorator, oneit.security.jsp.SecUserToNameTransform, oneit.servlets.utils.*, oneit.utils.image.*, oneit.objstore.utils.ObjstoreUtils "%>
<%@ page import="oneit.utils.text.FormatUtils, oneit.utils.math.*, oneit.net.LoopbackHTTP"%>
<%@ page import="oneit.servlets.objstore.binary.*,oneit.servlets.jsp.ormtable.*"%>
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