Update cache zone namings, Remove roles from being cached, added caching to loadOfficeById, added caching to loadTenantById(not cached though), made basicAuthenticationProcessingFilter bean to be depend on cachemanager bean
This commit is contained in:
committed by
Keith Woodlock
parent
802df9b34a
commit
822eea631f
+2
@@ -15,6 +15,7 @@ import org.mifosplatform.infrastructure.core.domain.MifosPlatformTenant;
|
|||||||
import org.mifosplatform.infrastructure.security.exception.InvalidTenantIdentiferException;
|
import org.mifosplatform.infrastructure.security.exception.InvalidTenantIdentiferException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.dao.EmptyResultDataAccessException;
|
import org.springframework.dao.EmptyResultDataAccessException;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
@@ -65,6 +66,7 @@ public class JdbcTenantDetailsService implements TenantDetailsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Cacheable(value = "tenantsById", key = "#tenantIdentifier")
|
||||||
public MifosPlatformTenant loadTenantById(final String tenantIdentifier) {
|
public MifosPlatformTenant loadTenantById(final String tenantIdentifier) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@ public class TenantAwareJpaPlatformUserDetailsService implements PlatformUserDet
|
|||||||
private PlatformUserRepository platformUserRepository;
|
private PlatformUserRepository platformUserRepository;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Cacheable(value = "users", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#username+'un')")
|
@Cacheable(value = "usersByUsername", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#username+'ubu')")
|
||||||
public UserDetails loadUserByUsername(final String username) throws UsernameNotFoundException, DataAccessException {
|
public UserDetails loadUserByUsername(final String username) throws UsernameNotFoundException, DataAccessException {
|
||||||
|
|
||||||
final PlatformUser appUser = this.platformUserRepository.findByUsername(username);
|
final PlatformUser appUser = this.platformUserRepository.findByUsername(username);
|
||||||
|
|||||||
+2
-1
@@ -142,7 +142,7 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Cacheable(value = "office_template", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy()+'oft')")
|
@Cacheable(value = "officesForDropdown", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy()+'ofd')")
|
||||||
public Collection<OfficeData> retrieveAllOfficesForDropdown() {
|
public Collection<OfficeData> retrieveAllOfficesForDropdown() {
|
||||||
final AppUser currentUser = context.authenticatedUser();
|
final AppUser currentUser = context.authenticatedUser();
|
||||||
|
|
||||||
@@ -156,6 +156,7 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Cacheable(value = "officesById", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#officeId)")
|
||||||
public OfficeData retrieveOffice(final Long officeId) {
|
public OfficeData retrieveOffice(final Long officeId) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
+3
-2
@@ -64,7 +64,7 @@ public class OfficeWritePlatformServiceJpaRepositoryImpl implements OfficeWriteP
|
|||||||
@Override
|
@Override
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(value = "offices", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy()+'of')"),
|
@CacheEvict(value = "offices", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy()+'of')"),
|
||||||
@CacheEvict(value = "office_template", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy()+'oft')") })
|
@CacheEvict(value = "officesForDropdown", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy()+'ofd')") })
|
||||||
public CommandProcessingResult createOffice(final JsonCommand command) {
|
public CommandProcessingResult createOffice(final JsonCommand command) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -102,7 +102,8 @@ public class OfficeWritePlatformServiceJpaRepositoryImpl implements OfficeWriteP
|
|||||||
@Override
|
@Override
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(value = "offices", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy()+'of')"),
|
@CacheEvict(value = "offices", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy()+'of')"),
|
||||||
@CacheEvict(value = "office_template", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy()+'oft')") })
|
@CacheEvict(value = "officesForDropdown", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy()+'ofd')"),
|
||||||
|
@CacheEvict(value = "officesById", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#officeId)")})
|
||||||
public CommandProcessingResult updateOffice(final Long officeId, final JsonCommand command) {
|
public CommandProcessingResult updateOffice(final Long officeId, final JsonCommand command) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
+6
@@ -23,6 +23,7 @@ import org.mifosplatform.useradministration.domain.AppUserRepository;
|
|||||||
import org.mifosplatform.useradministration.domain.Role;
|
import org.mifosplatform.useradministration.domain.Role;
|
||||||
import org.mifosplatform.useradministration.exception.UserNotFoundException;
|
import org.mifosplatform.useradministration.exception.UserNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -48,6 +49,7 @@ public class AppUserReadPlatformServiceImpl implements AppUserReadPlatformServic
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Cacheable(value = "users", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy())")
|
||||||
public Collection<AppUserData> retrieveAllUsers() {
|
public Collection<AppUserData> retrieveAllUsers() {
|
||||||
|
|
||||||
AppUser currentUser = context.authenticatedUser();
|
AppUser currentUser = context.authenticatedUser();
|
||||||
@@ -143,4 +145,8 @@ public class AppUserReadPlatformServiceImpl implements AppUserReadPlatformServic
|
|||||||
+ " join m_office o on o.id = u.office_id where o.hierarchy like ? and u.is_deleted=0 order by u.username";
|
+ " join m_office o on o.id = u.office_id where o.hierarchy like ? and u.is_deleted=0 order by u.username";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PlatformSecurityContext getContext() {
|
||||||
|
return this.context;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+3
-3
@@ -67,7 +67,7 @@ public class AppUserWritePlatformServiceJpaRepositoryImpl implements AppUserWrit
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
@CacheEvict(value = "users", allEntries = true)
|
@CacheEvict(value = "usersByUsername", allEntries = true)
|
||||||
public CommandProcessingResult createUser(final JsonCommand command) {
|
public CommandProcessingResult createUser(final JsonCommand command) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -111,7 +111,7 @@ public class AppUserWritePlatformServiceJpaRepositoryImpl implements AppUserWrit
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
@CacheEvict(value = "users", allEntries = true)
|
@CacheEvict(value = "usersByUsername", allEntries = true)
|
||||||
public CommandProcessingResult updateUser(final Long userId, final JsonCommand command) {
|
public CommandProcessingResult updateUser(final Long userId, final JsonCommand command) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -172,7 +172,7 @@ public class AppUserWritePlatformServiceJpaRepositoryImpl implements AppUserWrit
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
@CacheEvict(value = "users", allEntries = true)
|
@CacheEvict(value = "usersByUsername", allEntries = true)
|
||||||
public CommandProcessingResult deleteUser(final Long userId) {
|
public CommandProcessingResult deleteUser(final Long userId) {
|
||||||
|
|
||||||
final AppUser user = this.appUserRepository.findOne(userId);
|
final AppUser user = this.appUserRepository.findOne(userId);
|
||||||
|
|||||||
-3
@@ -14,8 +14,6 @@ import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
|||||||
import org.mifosplatform.useradministration.data.RoleData;
|
import org.mifosplatform.useradministration.data.RoleData;
|
||||||
import org.mifosplatform.useradministration.exception.RoleNotFoundException;
|
import org.mifosplatform.useradministration.exception.RoleNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
|
||||||
import org.springframework.dao.EmptyResultDataAccessException;
|
import org.springframework.dao.EmptyResultDataAccessException;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
@@ -34,7 +32,6 @@ public class RoleReadPlatformServiceImpl implements RoleReadPlatformService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Cacheable(value = "roles", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat('rl')")
|
|
||||||
public Collection<RoleData> retrieveAll() {
|
public Collection<RoleData> retrieveAll() {
|
||||||
final String sql = "select " + roleRowMapper.schema() + " order by r.id";
|
final String sql = "select " + roleRowMapper.schema() + " order by r.id";
|
||||||
|
|
||||||
|
|||||||
-4
@@ -25,7 +25,6 @@ import org.mifosplatform.useradministration.serialization.PermissionsCommandFrom
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
|
||||||
import org.springframework.dao.DataIntegrityViolationException;
|
import org.springframework.dao.DataIntegrityViolationException;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -53,7 +52,6 @@ public class RoleWritePlatformServiceJpaRepositoryImpl implements RoleWritePlatf
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
@CacheEvict(value = "roles", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat('rl')")
|
|
||||||
public CommandProcessingResult createRole(final JsonCommand command) {
|
public CommandProcessingResult createRole(final JsonCommand command) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -99,7 +97,6 @@ public class RoleWritePlatformServiceJpaRepositoryImpl implements RoleWritePlatf
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
@CacheEvict(value = "roles", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat('rl')")
|
|
||||||
public CommandProcessingResult updateRole(final Long roleId, final JsonCommand command) {
|
public CommandProcessingResult updateRole(final Long roleId, final JsonCommand command) {
|
||||||
try {
|
try {
|
||||||
context.authenticatedUser();
|
context.authenticatedUser();
|
||||||
@@ -129,7 +126,6 @@ public class RoleWritePlatformServiceJpaRepositoryImpl implements RoleWritePlatf
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
@CacheEvict(value = "roles", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat('rl')")
|
|
||||||
public CommandProcessingResult updateRolePermissions(final Long roleId, final JsonCommand command) {
|
public CommandProcessingResult updateRolePermissions(final Long roleId, final JsonCommand command) {
|
||||||
context.authenticatedUser();
|
context.authenticatedUser();
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!--
|
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
This Source Code Form is subject to the terms of the Mozilla Public
|
You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||||
License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
||||||
You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
-->
|
|
||||||
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">
|
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">
|
||||||
<defaultCache eternal="true" maxEntriesLocalHeap="100"
|
<defaultCache eternal="true" maxEntriesLocalHeap="100"
|
||||||
overflowToDisk="false" />
|
overflowToDisk="false" />
|
||||||
<cache name="users" maxEntriesLocalHeap="10000" eternal="true"
|
<cache name="usersByUsername" maxEntriesLocalHeap="10000"
|
||||||
overflowToDisk="false" />
|
eternal="true" overflowToDisk="false" />
|
||||||
|
<cache name="tenantsById" maxEntriesLocalHeap="10000"
|
||||||
|
eternal="true" overflowToDisk="false" />
|
||||||
<cache name="offices" maxEntriesLocalHeap="10000" eternal="true"
|
<cache name="offices" maxEntriesLocalHeap="10000" eternal="true"
|
||||||
overflowToDisk="false" />
|
overflowToDisk="false" />
|
||||||
<cache name="office_template" maxEntriesLocalHeap="10000"
|
<cache name="officesForDropdown" maxEntriesLocalHeap="10000"
|
||||||
eternal="true" overflowToDisk="false" />
|
eternal="true" overflowToDisk="false" />
|
||||||
|
<cache name="officesById" maxEntriesLocalHeap="10000" eternal="true"
|
||||||
|
overflowToDisk="false" />
|
||||||
<cache name="charges" maxEntriesLocalHeap="10000" eternal="true"
|
<cache name="charges" maxEntriesLocalHeap="10000" eternal="true"
|
||||||
overflowToDisk="false" />
|
overflowToDisk="false" />
|
||||||
<cache name="funds" maxEntriesLocalHeap="10000" eternal="true"
|
<cache name="funds" maxEntriesLocalHeap="10000" eternal="true"
|
||||||
@@ -24,6 +24,4 @@
|
|||||||
overflowToDisk="false" />
|
overflowToDisk="false" />
|
||||||
<cache name="codes" maxEntriesLocalHeap="10000" eternal="true"
|
<cache name="codes" maxEntriesLocalHeap="10000" eternal="true"
|
||||||
overflowToDisk="false" />
|
overflowToDisk="false" />
|
||||||
<cache name="roles" maxEntriesLocalHeap="10000" eternal="true"
|
|
||||||
overflowToDisk="false" />
|
|
||||||
</ehcache>
|
</ehcache>
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
<beans:property name="realmName" value="Mifos Platform API" />
|
<beans:property name="realmName" value="Mifos Platform API" />
|
||||||
</beans:bean>
|
</beans:bean>
|
||||||
|
|
||||||
<beans:bean id="basicAuthenticationProcessingFilter" class="org.mifosplatform.infrastructure.security.filter.TenantAwareBasicAuthenticationFilter">
|
<beans:bean id="basicAuthenticationProcessingFilter" class="org.mifosplatform.infrastructure.security.filter.TenantAwareBasicAuthenticationFilter" depends-on="cacheManager">
|
||||||
<beans:constructor-arg ref="authenticationManager" />
|
<beans:constructor-arg ref="authenticationManager" />
|
||||||
<beans:constructor-arg ref="basicAuthenticationEntryPoint" />
|
<beans:constructor-arg ref="basicAuthenticationEntryPoint" />
|
||||||
</beans:bean>
|
</beans:bean>
|
||||||
|
|||||||
Reference in New Issue
Block a user