diff --git a/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/AppUserReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/AppUserReadPlatformServiceImpl.java index 8ea66fc2c..e22c3ad85 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/AppUserReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/AppUserReadPlatformServiceImpl.java @@ -5,6 +5,12 @@ */ package org.mifosplatform.useradministration.service; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Set; + import org.mifosplatform.infrastructure.core.domain.JdbcSupport; import org.mifosplatform.infrastructure.core.service.RoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; @@ -22,12 +28,6 @@ import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.stereotype.Service; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Set; - @Service public class AppUserReadPlatformServiceImpl implements AppUserReadPlatformService { @@ -48,6 +48,13 @@ public class AppUserReadPlatformServiceImpl implements AppUserReadPlatformServic this.jdbcTemplate = new JdbcTemplate(dataSource); } + /* + * used for caching in spring expression language. + */ + public PlatformSecurityContext getContext() { + return this.context; + } + @Override @Cacheable(value = "users", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy())") public Collection retrieveAllUsers() { @@ -83,7 +90,6 @@ public class AppUserReadPlatformServiceImpl implements AppUserReadPlatformServic return AppUserData.template(offices, availableRoles); } - @Override public AppUserData retrieveUser(final Long userId) { @@ -110,9 +116,10 @@ public class AppUserReadPlatformServiceImpl implements AppUserReadPlatformServic private final RoleReadPlatformService roleReadPlatformService; - public AppUserMapper(final RoleReadPlatformService roleReadPlatformService){ + public AppUserMapper(final RoleReadPlatformService roleReadPlatformService) { this.roleReadPlatformService = roleReadPlatformService; } + @Override public AppUserData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException { @@ -124,8 +131,7 @@ public class AppUserReadPlatformServiceImpl implements AppUserReadPlatformServic final Long officeId = JdbcSupport.getLong(rs, "officeId"); final String officeName = rs.getString("officeName"); - //pass the client id to retrieve the clients assigned roles - final Collection selectedRoles = this.roleReadPlatformService.retrieveClientRoles(id); + final Collection selectedRoles = this.roleReadPlatformService.retrieveAppUserRoles(id); return AppUserData.instance(id, username, email, officeId, officeName, firstname, lastname, null, selectedRoles); } @@ -154,8 +160,4 @@ 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"; } } - - public PlatformSecurityContext getContext() { - return this.context; - } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/RoleReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/RoleReadPlatformService.java index 1ddac1339..bec415bba 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/RoleReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/RoleReadPlatformService.java @@ -15,5 +15,5 @@ public interface RoleReadPlatformService { RoleData retrieveOne(Long roleId); - Collection retrieveClientRoles(Long clientId); + Collection retrieveAppUserRoles(Long appUserId); } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/RoleReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/RoleReadPlatformServiceImpl.java index 3a8b99f33..02bf88e1d 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/RoleReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/useradministration/service/RoleReadPlatformServiceImpl.java @@ -5,6 +5,10 @@ */ package org.mifosplatform.useradministration.service; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Collection; + import org.mifosplatform.infrastructure.core.domain.JdbcSupport; import org.mifosplatform.infrastructure.core.service.RoutingDataSource; import org.mifosplatform.useradministration.data.RoleData; @@ -15,10 +19,6 @@ import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.stereotype.Service; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Collection; - @Service public class RoleReadPlatformServiceImpl implements RoleReadPlatformService { @@ -68,10 +68,10 @@ public class RoleReadPlatformServiceImpl implements RoleReadPlatformService { } @Override - public Collection retrieveClientRoles(Long clientId) { + public Collection retrieveAppUserRoles(final Long appUserId) { final String sql = "select " + this.roleRowMapper.schema() + " inner join m_appuser_role" + " ar on ar.role_id = r.id where ar.appuser_id= ?"; - return this.jdbcTemplate.query(sql,this.roleRowMapper,new Object[]{clientId}); + return this.jdbcTemplate.query(sql,this.roleRowMapper,new Object[]{appUserId}); } } \ No newline at end of file