MIFOSX-794: remove call to service that fetches roles for now.

This commit is contained in:
Keith Woodlock
2013-11-21 10:16:55 +00:00
parent 9976a0d148
commit 779f40e567
3 changed files with 31 additions and 30 deletions
@@ -5,6 +5,23 @@
*/
package org.mifosplatform.useradministration.api;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriInfo;
import org.mifosplatform.commands.domain.CommandWrapper;
import org.mifosplatform.commands.service.CommandWrapperBuilder;
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
@@ -21,16 +38,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriInfo;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@Path("/users")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Component
@Scope("singleton")
public class UsersApiResource {
@@ -65,13 +75,11 @@ public class UsersApiResource {
}
@GET
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public String retrieveAll(@Context final UriInfo uriInfo) {
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
final Collection<AppUserData> users = this.readPlatformService.retrieveAllUsersWithRoles();
final Collection<AppUserData> users = this.readPlatformService.retrieveAllUsers(); // this.readPlatformService.retrieveAllUsersWithRoles();
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
return this.toApiJsonSerializer.serialize(settings, users, this.RESPONSE_DATA_PARAMETERS);
@@ -79,8 +87,6 @@ public class UsersApiResource {
@GET
@Path("{userId}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public String retrieveOne(@PathParam("userId") final Long userId, @Context final UriInfo uriInfo) {
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions, userId);
@@ -98,8 +104,6 @@ public class UsersApiResource {
@GET
@Path("template")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public String template(@Context final UriInfo uriInfo) {
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
@@ -111,8 +115,6 @@ public class UsersApiResource {
}
@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public String create(final String apiRequestBodyAsJson) {
final CommandWrapper commandRequest = new CommandWrapperBuilder() //
@@ -127,8 +129,6 @@ public class UsersApiResource {
@PUT
@Path("{userId}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public String update(@PathParam("userId") final Long userId, final String apiRequestBodyAsJson) {
final CommandWrapper commandRequest = new CommandWrapperBuilder() //
@@ -143,8 +143,6 @@ public class UsersApiResource {
@DELETE
@Path("{userId}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public String delete(@PathParam("userId") final Long userId) {
final CommandWrapper commandRequest = new CommandWrapperBuilder() //
@@ -5,10 +5,10 @@
*/
package org.mifosplatform.useradministration.service;
import org.mifosplatform.useradministration.data.AppUserData;
import java.util.Collection;
import org.mifosplatform.useradministration.data.AppUserData;
public interface AppUserReadPlatformService {
Collection<AppUserData> retrieveAllUsers();
@@ -5,6 +5,13 @@
*/
package org.mifosplatform.useradministration.service;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
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,10 +29,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.*;
@Service
public class AppUserReadPlatformServiceImpl implements AppUserReadPlatformService {
@@ -83,9 +86,9 @@ public class AppUserReadPlatformServiceImpl implements AppUserReadPlatformServic
@Override
public Collection<AppUserData> retrieveAllUsersWithRoles() {
this.context.authenticatedUser();
final Collection<AppUser> users = this.appUserRepository.findAll();
Collection<AppUserData> appUserData = new HashSet<AppUserData>();
final Collection<AppUserData> appUserData = new HashSet<AppUserData>();
for(final AppUser user : users){
final Set<RoleData> selectedUserRoles = new HashSet<RoleData>();
for(final Role role : user.getRoles()){