diff --git a/sample.secrets.json b/sample.secrets.json index f3be477d..f804c4e4 100644 --- a/sample.secrets.json +++ b/sample.secrets.json @@ -14,5 +14,7 @@ "ERROR_MAIL_FROM": "", "ERROR_MAIL_TO": "", "COOKIE_DOMAIN": "", - "OPENAI_API_KEY": "" + "OPENAI_API_KEY": "", + "DEFAULT_TEST_USER":"", + "DEFAULT_TEST_USER_PASSWORD":"" } \ No newline at end of file diff --git a/src/main/java/com/salessparrow/api/lib/globalConstants/CacheConstants.java b/src/main/java/com/salessparrow/api/lib/globalConstants/CacheConstants.java index bb4ae3e5..9827578f 100644 --- a/src/main/java/com/salessparrow/api/lib/globalConstants/CacheConstants.java +++ b/src/main/java/com/salessparrow/api/lib/globalConstants/CacheConstants.java @@ -6,23 +6,23 @@ @Component public class CacheConstants { - public static final String CACHE_PREFIX; + public static final String CACHE_SUFFIX; static { if (CoreConstants.isProductionEnvironment()) { - CACHE_PREFIX = "prod_"; + CACHE_SUFFIX = "_prod"; } else if (CoreConstants.isStagingEnvironment()) { - CACHE_PREFIX = "stag_"; + CACHE_SUFFIX = "_stag"; } else if (CoreConstants.isTestEnvironment()) { - CACHE_PREFIX = "test_"; + CACHE_SUFFIX = "_test"; } else if (CoreConstants.isLocalTestEnvironment()) { - CACHE_PREFIX = "ltest_"; + CACHE_SUFFIX = "_ltest"; } else { - CACHE_PREFIX = "dev_"; + CACHE_SUFFIX = "_dev"; } } diff --git a/src/main/java/com/salessparrow/api/repositories/SalesforceOauthTokenRepository.java b/src/main/java/com/salessparrow/api/repositories/SalesforceOauthTokenRepository.java index 6dab2d73..87b7495a 100644 --- a/src/main/java/com/salessparrow/api/repositories/SalesforceOauthTokenRepository.java +++ b/src/main/java/com/salessparrow/api/repositories/SalesforceOauthTokenRepository.java @@ -29,7 +29,7 @@ public SalesforceOauthTokenRepository(DynamoDBMapper dynamoDBMapper) { * @return SalesforceOauthToken */ @CacheEvict(value = CacheConstants.SALESFORCE_OAUTH_TOKEN_CACHE, - key = "T(com.salessparrow.api.lib.globalConstants.CacheConstants).CACHE_PREFIX + #salesforceOauthToken.externalUserId") + key = "#salesforceOauthToken.externalUserId + T(com.salessparrow.api.lib.globalConstants.CacheConstants).CACHE_SUFFIX") public SalesforceOauthToken createSalesforceOauthToken(SalesforceOauthToken salesforceOauthToken) { // Create a row with status active and created at as current time salesforceOauthToken.setStatus(SalesforceOauthToken.Status.ACTIVE); @@ -50,7 +50,7 @@ public SalesforceOauthToken createSalesforceOauthToken(SalesforceOauthToken sale * @return SalesforceOauthToken */ @CacheEvict(value = CacheConstants.SALESFORCE_OAUTH_TOKEN_CACHE, - key = "T(com.salessparrow.api.lib.globalConstants.CacheConstants).CACHE_PREFIX + #salesforceOauthToken.externalUserId") + key = "#salesforceOauthToken.externalUserId + T(com.salessparrow.api.lib.globalConstants.CacheConstants).CACHE_SUFFIX") public SalesforceOauthToken updateSalesforceOauthToken(SalesforceOauthToken salesforceOauthToken) { try { dynamoDBMapper.save(salesforceOauthToken); @@ -68,7 +68,7 @@ public SalesforceOauthToken updateSalesforceOauthToken(SalesforceOauthToken sale * @return SalesforceOauthToken */ @Cacheable(value = CacheConstants.SALESFORCE_OAUTH_TOKEN_CACHE, - key = "T(com.salessparrow.api.lib.globalConstants.CacheConstants).CACHE_PREFIX + #externalUserId") + key = "#externalUserId + T(com.salessparrow.api.lib.globalConstants.CacheConstants).CACHE_SUFFIX") public SalesforceOauthToken getSalesforceOauthTokenByExternalUserId(String externalUserId) { try { return dynamoDBMapper.load(SalesforceOauthToken.class, externalUserId); @@ -85,7 +85,7 @@ public SalesforceOauthToken getSalesforceOauthTokenByExternalUserId(String exter * @return void */ @CacheEvict(value = CacheConstants.SALESFORCE_OAUTH_TOKEN_CACHE, - key = "T(com.salessparrow.api.lib.globalConstants.CacheConstants).CACHE_PREFIX + #salesforceOauthToken.externalUserId") + key = "#salesforceOauthToken.externalUserId + T(com.salessparrow.api.lib.globalConstants.CacheConstants).CACHE_SUFFIX") public void deleteSalesforceOauthTokenBySalesforceOauthToken(SalesforceOauthToken salesforceOauthToken) { try { dynamoDBMapper.delete(salesforceOauthToken); diff --git a/src/main/java/com/salessparrow/api/repositories/SalesforceUserRepository.java b/src/main/java/com/salessparrow/api/repositories/SalesforceUserRepository.java index 7e74d38a..4f3600ef 100644 --- a/src/main/java/com/salessparrow/api/repositories/SalesforceUserRepository.java +++ b/src/main/java/com/salessparrow/api/repositories/SalesforceUserRepository.java @@ -30,7 +30,7 @@ public SalesforceUserRepository(DynamoDBMapper dynamoDBMapper) { * @return SalesforceUser */ @CacheEvict(value = CacheConstants.SALESFORCE_USER_CACHE, - key = "T(com.salessparrow.api.lib.globalConstants.CacheConstants).CACHE_PREFIX + #salesforceUser.externalUserId") + key = "#salesforceUser.externalUserId + T(com.salessparrow.api.lib.globalConstants.CacheConstants).CACHE_SUFFIX") public SalesforceUser createSalesforceUser(SalesforceUser salesforceUser) { // Create a row with status active and created at as current time salesforceUser.setStatus(SalesforceUser.Status.ACTIVE); @@ -51,7 +51,7 @@ public SalesforceUser createSalesforceUser(SalesforceUser salesforceUser) { * @return SalesforceUser */ @CacheEvict(value = CacheConstants.SALESFORCE_USER_CACHE, - key = "T(com.salessparrow.api.lib.globalConstants.CacheConstants).CACHE_PREFIX + #salesforceUser.externalUserId") + key = "#salesforceUser.externalUserId + T(com.salessparrow.api.lib.globalConstants.CacheConstants).CACHE_SUFFIX") public SalesforceUser updateSalesforceUser(SalesforceUser salesforceUser) { try { dynamoDBMapper.save(salesforceUser); @@ -69,7 +69,7 @@ public SalesforceUser updateSalesforceUser(SalesforceUser salesforceUser) { * @return SalesforceUser */ @Cacheable(value = CacheConstants.SALESFORCE_USER_CACHE, - key = "T(com.salessparrow.api.lib.globalConstants.CacheConstants).CACHE_PREFIX + #externalUserId") + key = "#externalUserId + T(com.salessparrow.api.lib.globalConstants.CacheConstants).CACHE_SUFFIX") public SalesforceUser getSalesforceUserByExternalUserId(String externalUserId) { try { return dynamoDBMapper.load(SalesforceUser.class, externalUserId); @@ -80,7 +80,7 @@ public SalesforceUser getSalesforceUserByExternalUserId(String externalUserId) { } @CacheEvict(value = CacheConstants.SALESFORCE_USER_CACHE, - key = "T(com.salessparrow.api.lib.globalConstants.CacheConstants).CACHE_PREFIX + #externalUserId") + key = "#externalUserId + T(com.salessparrow.api.lib.globalConstants.CacheConstants).CACHE_SUFFIX") public void removeSalesforceUserData(String externalUserId) { SalesforceUser salesforceUser = getSalesforceUserByExternalUserId(externalUserId); salesforceUser.setIdentityUrl(null);