@Override public String getComment() { return auditLogModelDao.getCallContext().getComments(); }
/** * Create an internal call callcontext using an existing account to retrieve tenant and account record ids * <p/> * This is used for r/w operations - we need the account id to populate the account_record_id field * * @param accountId account id * @param context original call callcontext * @return internal call callcontext */ public InternalCallContext createInternalCallContext(final UUID accountId, final CallContext context) { return createInternalCallContext(accountId, ObjectType.ACCOUNT, context.getUserName(), context.getCallOrigin(), context.getUserType(), context.getUserToken(), context.getReasonCode(), context.getComments(), context.getCreatedDate(), context.getUpdatedDate()); }
private void verifyInternalCallContext(final InternalCallContext context) { Assert.assertEquals(context.getCallOrigin(), callContext.getCallOrigin()); Assert.assertEquals(context.getComments(), callContext.getComments()); Assert.assertEquals(context.getCreatedDate(), callContext.getCreatedDate()); Assert.assertEquals(context.getReasonCode(), callContext.getReasonCode()); Assert.assertEquals(context.getUpdatedDate(), callContext.getUpdatedDate()); Assert.assertEquals(context.getCreatedBy(), callContext.getUserName()); Assert.assertEquals(context.getUserToken(), callContext.getUserToken()); Assert.assertEquals(context.getContextUserType(), callContext.getUserType()); // Our test callcontext doesn't have a tenant id Assert.assertEquals(context.getTenantRecordId(), (Long) InternalCallContextFactory.INTERNAL_TENANT_RECORD_ID); } }
@Test(groups = "fast") public void testConstructor() throws Exception { final TableName tableName = TableName.ACCOUNT_EMAIL_HISTORY; final long recordId = Long.MAX_VALUE; final ChangeType changeType = ChangeType.DELETE; final EntityAudit entityAudit = new EntityAudit(tableName, recordId, changeType, null); final AuditLog auditLog = new DefaultAuditLog(new AuditLogModelDao(entityAudit, callContext), ObjectType.ACCOUNT_EMAIL, UUID.randomUUID()); final AuditLogJson auditLogJson = new AuditLogJson(auditLog); Assert.assertEquals(auditLogJson.getChangeType(), changeType.toString()); Assert.assertNotNull(auditLogJson.getChangeDate()); Assert.assertEquals(auditLogJson.getChangedBy(), callContext.getUserName()); Assert.assertEquals(auditLogJson.getReasonCode(), callContext.getReasonCode()); Assert.assertEquals(auditLogJson.getComments(), callContext.getComments()); Assert.assertEquals(auditLogJson.getUserToken(), callContext.getUserToken().toString()); } }
/** * Create an internal call callcontext from a call callcontext, and retrieving the account_record_id from another table * * @param objectId the id of the row in the table pointed by object type where to look for account_record_id * @param objectType the object type pointed by this objectId * @param context original call callcontext * @return internal call callcontext from callcontext, with a non null account_record_id (if found) */ public InternalCallContext createInternalCallContext(final UUID objectId, final ObjectType objectType, final CallContext context) { // The callcontext may come from a user API - for security, check we're not doing cross-tenants operations //final Long tenantRecordIdFromObject = retrieveTenantRecordIdFromObject(objectId, objectType); //final Long tenantRecordIdFromContext = getTenantRecordId(callcontext); //Preconditions.checkState(tenantRecordIdFromContext.equals(tenantRecordIdFromObject), // "tenant of the pointed object (%s) and the callcontext (%s) don't match!", tenantRecordIdFromObject, tenantRecordIdFromContext); return createInternalCallContext(objectId, objectType, context.getUserName(), context.getCallOrigin(), context.getUserType(), context.getUserToken(), context.getReasonCode(), context.getComments(), context.getCreatedDate(), context.getUpdatedDate()); }