Commit 315545f2 by Nilu

added logs

parent 82fb2cf1
...@@ -21,7 +21,7 @@ public class CloseJobBatch extends ORMBatch ...@@ -21,7 +21,7 @@ public class CloseJobBatch extends ORMBatch
@Override @Override
public void run(ObjectTransaction ot) throws StorageException, FieldException public void run(ObjectTransaction ot) throws StorageException, FieldException
{ {
LogMgr.log (CLOSE_JOB_BATCH, LogLevel.DEBUG2, "RUNNING Close Job Batch"); LogMgr.log (CLOSE_JOB_BATCH, LogLevel.PROCESSING1, "RUNNING Close Job Batch");
Job[] expiringJobs = Job.SearchByAll() Job[] expiringJobs = Job.SearchByAll()
.andApplyBy(new LessThanFilter<>(DateDiff.getToday())) .andApplyBy(new LessThanFilter<>(DateDiff.getToday()))
...@@ -32,7 +32,7 @@ public class CloseJobBatch extends ORMBatch ...@@ -32,7 +32,7 @@ public class CloseJobBatch extends ORMBatch
job.setJobStatus(JobStatus.COMPLETE); job.setJobStatus(JobStatus.COMPLETE);
job.setIsManuallyClosed(Boolean.FALSE); job.setIsManuallyClosed(Boolean.FALSE);
LogMgr.log(CLOSE_JOB_BATCH, LogLevel.DEBUG2, "Setting Job Status to Closed in job : ", job); LogMgr.log(CLOSE_JOB_BATCH, LogLevel.PROCESSING1, "Setting Job Status to Closed in job : ", job);
} }
// Update closed job details to intercom // Update closed job details to intercom
......
package performa.batch; package performa.batch;
import com.stripe.Stripe; import com.stripe.Stripe;
import com.stripe.exception.APIConnectionException;
import com.stripe.exception.APIException;
import com.stripe.exception.AuthenticationException;
import com.stripe.exception.CardException;
import com.stripe.exception.InvalidRequestException;
import com.stripe.model.Plan; import com.stripe.model.Plan;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -28,7 +33,7 @@ public class PullStripeDataBatch extends ORMBatch ...@@ -28,7 +33,7 @@ public class PullStripeDataBatch extends ORMBatch
{ {
try try
{ {
LogMgr.log (PULL_STRIPE_DATA_BATCH, LogLevel.DEBUG2, "RUNNING Pull Stripe Data Batch"); LogMgr.log (PULL_STRIPE_DATA_BATCH, LogLevel.PROCESSING1, "RUNNING Pull Stripe Data Batch");
Stripe.apiKey = StripeUtils.STRIPE_KEY; Stripe.apiKey = StripeUtils.STRIPE_KEY;
...@@ -43,12 +48,12 @@ public class PullStripeDataBatch extends ORMBatch ...@@ -43,12 +48,12 @@ public class PullStripeDataBatch extends ORMBatch
if(paymentPlans != null && paymentPlans.length > 0) if(paymentPlans != null && paymentPlans.length > 0)
{ {
paymentPlan = paymentPlans[0]; paymentPlan = paymentPlans[0];
LogMgr.log (PULL_STRIPE_DATA_BATCH, LogLevel.DEBUG2, "Updating exiting payment plan: " , paymentPlan, " to match stripe plan: ", plan); LogMgr.log (PULL_STRIPE_DATA_BATCH, LogLevel.PROCESSING1, "Updating exiting payment plan: " , paymentPlan, " to match stripe plan: ", plan);
} }
else else
{ {
paymentPlan = PaymentPlan.createPaymentPlan(ot); paymentPlan = PaymentPlan.createPaymentPlan(ot);
LogMgr.log (PULL_STRIPE_DATA_BATCH, LogLevel.DEBUG2, "Creating a new payment plan for stripe plan: ", plan); LogMgr.log (PULL_STRIPE_DATA_BATCH, LogLevel.PROCESSING1, "Creating a new payment plan for stripe plan: ", plan);
} }
Map<String, String> metadata = plan.getMetadata(); Map<String, String> metadata = plan.getMetadata();
...@@ -68,10 +73,10 @@ public class PullStripeDataBatch extends ORMBatch ...@@ -68,10 +73,10 @@ public class PullStripeDataBatch extends ORMBatch
paymentPlan.setActiveJobCount(Integer.valueOf(activeJobs)); paymentPlan.setActiveJobCount(Integer.valueOf(activeJobs));
} }
LogMgr.log (PULL_STRIPE_DATA_BATCH, LogLevel.DEBUG2, "Saving payment plan: " , paymentPlan, " mapped from stripe plan: ", plan); LogMgr.log (PULL_STRIPE_DATA_BATCH, LogLevel.PROCESSING1, "Saving payment plan: " , paymentPlan, " mapped from stripe plan: ", plan);
} }
} }
catch (Exception ex) catch (AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException | StorageException | FieldException | NumberFormatException ex)
{ {
LogMgr.log(PULL_STRIPE_DATA_BATCH, LogLevel.PROCESSING1, ex, "Error while pulling plan details from stripe"); LogMgr.log(PULL_STRIPE_DATA_BATCH, LogLevel.PROCESSING1, ex, "Error while pulling plan details from stripe");
......
...@@ -18,7 +18,7 @@ public class URLShortnerBatch extends ORMBatch ...@@ -18,7 +18,7 @@ public class URLShortnerBatch extends ORMBatch
@Override @Override
public void run(ObjectTransaction ot) throws StorageException, FieldException public void run(ObjectTransaction ot) throws StorageException, FieldException
{ {
LogMgr.log (URL_SHORTNER_BATCH, LogLevel.DEBUG2, "RUNNING URL Shortner Batch"); LogMgr.log (URL_SHORTNER_BATCH, LogLevel.PROCESSING1, "RUNNING URL Shortner Batch");
Job[] jobs = Job.SearchByAll() Job[] jobs = Job.SearchByAll()
.andShortenedURL(new IsNullFilter<>()) .andShortenedURL(new IsNullFilter<>())
...@@ -30,7 +30,7 @@ public class URLShortnerBatch extends ORMBatch ...@@ -30,7 +30,7 @@ public class URLShortnerBatch extends ORMBatch
{ {
job.createShortenedURL(); job.createShortenedURL();
LogMgr.log(URL_SHORTNER_BATCH, LogLevel.DEBUG2, "Setting Shortened URL to job : ", job); LogMgr.log(URL_SHORTNER_BATCH, LogLevel.PROCESSING1, "Setting Shortened URL to job : ", job);
} }
catch(StorageException | FieldException e) catch(StorageException | FieldException e)
{ {
......
...@@ -27,6 +27,8 @@ public class CompleteApplicationFP extends SaveFP ...@@ -27,6 +27,8 @@ public class CompleteApplicationFP extends SaveFP
jobApplication = (JobApplication) jobApplication.getInTransaction (objTran); jobApplication = (JobApplication) jobApplication.getInTransaction (objTran);
LogMgr.log(JobApplication.LOG, LogLevel.PROCESSING2, "CompleteApplicationFP Job Application :", jobApplication);
jobApplication.setApplicationStatus(ApplicationStatus.SUBMITTED); jobApplication.setApplicationStatus(ApplicationStatus.SUBMITTED);
jobApplication.setSubmittedDate(new Date()); jobApplication.setSubmittedDate(new Date());
......
...@@ -35,7 +35,7 @@ public class LoadCultureFromTemplateFP extends ORMProcessFormProcessor ...@@ -35,7 +35,7 @@ public class LoadCultureFromTemplateFP extends ORMProcessFormProcessor
Job job = (Job) request.getAttribute("Job"); Job job = (Job) request.getAttribute("Job");
CultureCriteriaTemplate template = job.getCultureTemplate(); CultureCriteriaTemplate template = job.getCultureTemplate();
LogMgr.log(Job.LOG, LogLevel.PROCESSING1, "Inside LoadCultureFromTemplateFP for ", job.getObjectID(), " load from template:", template); LogMgr.log(Job.LOG, LogLevel.PROCESSING1, "Inside LoadCultureFromTemplateFP for ", job , " load from template:", template);
if(template != null) if(template != null)
{ {
...@@ -55,7 +55,8 @@ public class LoadCultureFromTemplateFP extends ORMProcessFormProcessor ...@@ -55,7 +55,8 @@ public class LoadCultureFromTemplateFP extends ORMProcessFormProcessor
job.addToCultureCriterias(criteriaCopy); job.addToCultureCriterias(criteriaCopy);
} }
} }
LogMgr.log(Job.LOG, LogLevel.PROCESSING1, "LoadCultureFromTemplateFP completed for ", job.getObjectID());
LogMgr.log(Job.LOG, LogLevel.PROCESSING1, "LoadCultureFromTemplateFP completed for ", job);
return RedisplayResult.getInstance(); return RedisplayResult.getInstance();
} }
......
...@@ -19,9 +19,6 @@ import oneit.servlets.process.ORMProcessState; ...@@ -19,9 +19,6 @@ import oneit.servlets.process.ORMProcessState;
import oneit.servlets.process.SaveFP; import oneit.servlets.process.SaveFP;
import oneit.utils.BusinessException; import oneit.utils.BusinessException;
import performa.orm.Job; import performa.orm.Job;
import performa.orm.PaymentPlan;
import performa.orm.types.CurrencyType;
import performa.orm.types.Interval;
public class ManagePlansFP extends SaveFP public class ManagePlansFP extends SaveFP
......
...@@ -32,7 +32,6 @@ public class UpdateCardFP extends SaveFP ...@@ -32,7 +32,6 @@ public class UpdateCardFP extends SaveFP
@Override @Override
public SuccessfulResult processForm(ORMProcessState process, SubmissionDetails submission, Map p) throws BusinessException, StorageException public SuccessfulResult processForm(ORMProcessState process, SubmissionDetails submission, Map p) throws BusinessException, StorageException
{ {
LogMgr.log(LOG, LogLevel.PROCESSING1,"In UpdateCardFP : " );
Stripe.apiKey = StripeUtils.STRIPE_KEY; Stripe.apiKey = StripeUtils.STRIPE_KEY;
...@@ -45,6 +44,8 @@ public class UpdateCardFP extends SaveFP ...@@ -45,6 +44,8 @@ public class UpdateCardFP extends SaveFP
Company company = companyUser.getCompany(); Company company = companyUser.getCompany();
Card card = StripeUtils.retrieveCard(company); Card card = StripeUtils.retrieveCard(company);
LogMgr.log(LOG, LogLevel.PROCESSING1,"In UpdateCardFP updating card details of user : ", company, " card : " , card );
Map<String, Object> updateParams = new HashMap<>(); Map<String, Object> updateParams = new HashMap<>();
String expiryDate = request.getParameter("expiry-date"); String expiryDate = request.getParameter("expiry-date");
String name = request.getParameter("holder-name"); String name = request.getParameter("holder-name");
...@@ -59,15 +60,16 @@ public class UpdateCardFP extends SaveFP ...@@ -59,15 +60,16 @@ public class UpdateCardFP extends SaveFP
updateParams.put("name", name); updateParams.put("name", name);
updateParams.put("address_zip", addressZip); updateParams.put("address_zip", addressZip);
card.update(updateParams); Card updatedCard = card.update(updateParams);
company.setNameOnCard(name); company.setNameOnCard(name);
company.setCardPostCode(addressZip); company.setCardPostCode(addressZip);
LogMgr.log(LOG, LogLevel.PROCESSING1,"Updated card details of user : ", company, " updated card : " , updatedCard );
} }
catch (AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException e) catch (AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException e)
{ {
LogMgr.log(LOG, LogLevel.PROCESSING1, e, "Error while making payment"); LogMgr.log(LOG, LogLevel.PROCESSING1, e, "Error while updating card details of user");
} }
return super.processForm(process, submission, p); return super.processForm(process, submission, p);
......
package performa.form; package performa.form;
import java.util.Map; import java.util.Map;
import oneit.logging.LogLevel;
import oneit.logging.LogMgr;
import oneit.objstore.ObjectTransaction; import oneit.objstore.ObjectTransaction;
import oneit.security.LoginProcessor; import oneit.security.LoginProcessor;
import oneit.security.SecUser; import oneit.security.SecUser;
...@@ -23,6 +25,8 @@ public class UserLoginFP extends LoginProcessor ...@@ -23,6 +25,8 @@ public class UserLoginFP extends LoginProcessor
CompanyUser companyUser = userToCheck.getExtension(CompanyUser.REFERENCE_CompanyUser); CompanyUser companyUser = userToCheck.getExtension(CompanyUser.REFERENCE_CompanyUser);
LogMgr.log(LOGIN, LogLevel.PROCESSING1,"In UserLoginFP checking user can log : ", companyUser );
if(!Utils.checkAdminPortalAccess(userToCheck) || companyUser == null || !companyUser.isTrue(companyUser.getIsAccountVerified())) if(!Utils.checkAdminPortalAccess(userToCheck) || companyUser == null || !companyUser.isTrue(companyUser.getIsAccountVerified()))
{ {
throw new FieldException("You're not an authorised user to access this portal.", SecUser.FIELD_UserName); throw new FieldException("You're not an authorised user to access this portal.", SecUser.FIELD_UserName);
......
...@@ -9,7 +9,6 @@ import java.util.Map; ...@@ -9,7 +9,6 @@ import java.util.Map;
import oneit.logging.LogLevel; import oneit.logging.LogLevel;
import oneit.logging.LogMgr; import oneit.logging.LogMgr;
import oneit.logging.LoggingArea; import oneit.logging.LoggingArea;
import oneit.objstore.ObjectTransaction;
import oneit.objstore.StorageException; import oneit.objstore.StorageException;
import oneit.objstore.rdbms.filters.EqualsFilter; import oneit.objstore.rdbms.filters.EqualsFilter;
import oneit.objstore.rdbms.filters.InFilter; import oneit.objstore.rdbms.filters.InFilter;
...@@ -19,9 +18,14 @@ import oneit.utils.CollectionUtils; ...@@ -19,9 +18,14 @@ import oneit.utils.CollectionUtils;
import oneit.utils.ObjectTransform; import oneit.utils.ObjectTransform;
import oneit.utils.filter.CollectionFilter; import oneit.utils.filter.CollectionFilter;
import oneit.utils.filter.Filter; import oneit.utils.filter.Filter;
import performa.intercom.resources.AuthorizationException;
import performa.intercom.resources.ClientException;
import performa.intercom.resources.Company; import performa.intercom.resources.Company;
import performa.intercom.resources.CustomAttribute; import performa.intercom.resources.CustomAttribute;
import performa.intercom.resources.Intercom; import performa.intercom.resources.Intercom;
import performa.intercom.resources.InvalidException;
import performa.intercom.resources.RateLimitException;
import performa.intercom.resources.ServerException;
import performa.intercom.resources.User; import performa.intercom.resources.User;
import performa.orm.Job; import performa.orm.Job;
import performa.orm.JobApplication; import performa.orm.JobApplication;
...@@ -56,9 +60,13 @@ public class IntercomUtils ...@@ -56,9 +60,13 @@ public class IntercomUtils
user.addCompany(company); user.addCompany(company);
} }
return User.create(user); User.create(user);
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, "Created Intercom User: ", user);
return user;
} }
catch (Exception e) catch (AuthorizationException | ClientException | ServerException | InvalidException | RateLimitException e)
{ {
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, e, "Error while creating a user in intercom"); LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, e, "Error while creating a user in intercom");
...@@ -77,7 +85,7 @@ public class IntercomUtils ...@@ -77,7 +85,7 @@ public class IntercomUtils
return User.find(map); return User.find(map);
} }
catch (Exception e) catch (AuthorizationException | ClientException | ServerException | InvalidException | RateLimitException e)
{ {
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, e, "Error while fetching a user by id from intercom"); LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, e, "Error while fetching a user by id from intercom");
...@@ -100,9 +108,11 @@ public class IntercomUtils ...@@ -100,9 +108,11 @@ public class IntercomUtils
User.update(user); User.update(user);
} }
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, "Updated Intercom User: ", user);
return user; return user;
} }
catch (Exception e) catch (InvalidException | AuthorizationException e)
{ {
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, e, "Error while updating a user in intercom"); LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, e, "Error while updating a user in intercom");
return null; return null;
...@@ -120,9 +130,11 @@ public class IntercomUtils ...@@ -120,9 +130,11 @@ public class IntercomUtils
Company.create(intercomCompany); Company.create(intercomCompany);
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, "Created Intercom Company: ", intercomCompany);
return intercomCompany; return intercomCompany;
} }
catch (Exception e) catch (StorageException | InvalidException | AuthorizationException e)
{ {
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, e, "Error while creating a company in intercom"); LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, e, "Error while creating a company in intercom");
...@@ -190,7 +202,7 @@ public class IntercomUtils ...@@ -190,7 +202,7 @@ public class IntercomUtils
return Company.find(map); return Company.find(map);
} }
catch (Exception e) catch (InvalidException | AuthorizationException e)
{ {
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, e, "Error while fetching a company by id from intercom"); LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, e, "Error while fetching a company by id from intercom");
...@@ -214,6 +226,8 @@ public class IntercomUtils ...@@ -214,6 +226,8 @@ public class IntercomUtils
setCompanyDetails(intercomCompany, company); setCompanyDetails(intercomCompany, company);
Company.update(intercomCompany); Company.update(intercomCompany);
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, "Updated Intercom Company: ", intercomCompany);
} }
} }
catch (Exception e) catch (Exception e)
......
...@@ -8,14 +8,11 @@ import com.stripe.exception.CardException; ...@@ -8,14 +8,11 @@ import com.stripe.exception.CardException;
import com.stripe.exception.InvalidRequestException; import com.stripe.exception.InvalidRequestException;
import com.stripe.model.Card; import com.stripe.model.Card;
import com.stripe.model.Customer; import com.stripe.model.Customer;
import com.stripe.model.ExternalAccount;
import com.stripe.model.ExternalAccountCollection;
import com.stripe.model.Plan; import com.stripe.model.Plan;
import com.stripe.model.Subscription; import com.stripe.model.Subscription;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import oneit.appservices.config.ConfigMgr; import oneit.appservices.config.ConfigMgr;
import oneit.logging.LogLevel; import oneit.logging.LogLevel;
...@@ -57,6 +54,7 @@ public class StripeUtils ...@@ -57,6 +54,7 @@ public class StripeUtils
company.setStripeReference(customer.getId()); company.setStripeReference(customer.getId());
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, "Create customer in stripe : ", customer);
} }
catch (StorageException | AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException ex) catch (StorageException | AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException ex)
{ {
...@@ -82,7 +80,11 @@ public class StripeUtils ...@@ -82,7 +80,11 @@ public class StripeUtils
customer = customer.update(updateParams); customer = customer.update(updateParams);
return (Card) customer.getSources().retrieve(customer.getDefaultSource()); Card card = (Card) customer.getSources().retrieve(customer.getDefaultSource());
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, "Update card details in stripe, customer : ", customer, " card : ", card);
return card;
} }
catch (StorageException | AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException ex) catch (StorageException | AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException ex)
...@@ -133,6 +135,8 @@ public class StripeUtils ...@@ -133,6 +135,8 @@ public class StripeUtils
Subscription subscription = Subscription.create(params); Subscription subscription = Subscription.create(params);
LogMgr.log(LoggingArea.ALL, LogLevel.PROCESSING1, "Subscribing customer in stripe : ", subscription);
company.setStripeSubscription(subscription.getId()); company.setStripeSubscription(subscription.getId());
} }
catch (StorageException | AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException ex) catch (StorageException | AuthenticationException | InvalidRequestException | APIConnectionException | CardException | APIException ex)
......
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