first steps around moving users to new approach.
This commit is contained in:
+1
-14
@@ -33,25 +33,12 @@ public interface CommonRestOperations {
|
||||
|
||||
void logout(String accessToken);
|
||||
|
||||
void updateProtectedResource(
|
||||
ProtectedResourceDetails loadProtectedResourceDetailsById);
|
||||
|
||||
Collection<AppUserData> retrieveAllUsers();
|
||||
|
||||
AppUserData retrieveNewUserDetails();
|
||||
|
||||
AppUserData retrieveUser(Long userId);
|
||||
void updateProtectedResource(ProtectedResourceDetails loadProtectedResourceDetailsById);
|
||||
|
||||
AppUserData retrieveCurrentUser();
|
||||
|
||||
EntityIdentifier createUser(UserCommand command);
|
||||
|
||||
EntityIdentifier updateUser(UserCommand command);
|
||||
|
||||
EntityIdentifier updateCurrentUserPassword(ChangePasswordCommand command);
|
||||
|
||||
void deleteUser(Long userId);
|
||||
|
||||
Collection<RoleData> retrieveAllRoles();
|
||||
|
||||
RoleData retrieveRole(Long roleId);
|
||||
|
||||
-84
@@ -27,7 +27,6 @@ import org.mifosng.data.PermissionData;
|
||||
import org.mifosng.data.PermissionList;
|
||||
import org.mifosng.data.RoleData;
|
||||
import org.mifosng.data.RoleList;
|
||||
import org.mifosng.data.UserList;
|
||||
import org.mifosng.data.command.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.data.command.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.data.command.ChangePasswordCommand;
|
||||
@@ -531,41 +530,6 @@ public class CommonRestOperationsImpl implements CommonRestOperations {
|
||||
requestHeaders);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityIdentifier createUser(final UserCommand command) {
|
||||
try {
|
||||
URI restUri = URI.create(getBaseServerUrl().concat(
|
||||
"api/protected/admin/user/new"));
|
||||
|
||||
ResponseEntity<EntityIdentifier> s = this.oauthRestServiceTemplate
|
||||
.postForEntity(restUri, createUserRequest(command),
|
||||
EntityIdentifier.class);
|
||||
|
||||
return s.getBody();
|
||||
} catch (HttpStatusCodeException e) {
|
||||
ErrorResponseList errorList = parseErrors(e);
|
||||
throw new ClientValidationException(errorList.getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityIdentifier updateUser(UserCommand command) {
|
||||
try {
|
||||
URI restUri = URI.create(getBaseServerUrl().concat(
|
||||
"api/protected/admin/user/").concat(
|
||||
command.getId().toString()));
|
||||
|
||||
ResponseEntity<EntityIdentifier> s = this.oauthRestServiceTemplate
|
||||
.postForEntity(restUri, createUserRequest(command),
|
||||
EntityIdentifier.class);
|
||||
|
||||
return s.getBody();
|
||||
} catch (HttpStatusCodeException e) {
|
||||
ErrorResponseList errorList = parseErrors(e);
|
||||
throw new ClientValidationException(errorList.getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityIdentifier updateCurrentUserDetails(UserCommand command) {
|
||||
try {
|
||||
@@ -602,14 +566,6 @@ public class CommonRestOperationsImpl implements CommonRestOperations {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUser(Long userId) {
|
||||
URI restUri = URI.create(getBaseServerUrl().concat(
|
||||
"api/protected/admin/user/").concat(userId.toString()));
|
||||
|
||||
this.oauthRestServiceTemplate.delete(restUri);
|
||||
}
|
||||
|
||||
private HttpEntity<UserCommand> createUserRequest(final UserCommand command) {
|
||||
|
||||
HttpHeaders requestHeaders = new HttpHeaders();
|
||||
@@ -644,46 +600,6 @@ public class CommonRestOperationsImpl implements CommonRestOperations {
|
||||
return requestEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<AppUserData> retrieveAllUsers() {
|
||||
try {
|
||||
URI restUri = URI.create(getBaseServerUrl().concat(
|
||||
"api/protected/admin/user/all"));
|
||||
|
||||
ResponseEntity<UserList> s = this.oauthRestServiceTemplate
|
||||
.exchange(restUri, HttpMethod.GET, emptyRequest(),
|
||||
UserList.class);
|
||||
|
||||
return s.getBody().getUsers();
|
||||
} catch (HttpStatusCodeException e) {
|
||||
ErrorResponseList errorList = parseErrors(e);
|
||||
throw new ClientValidationException(errorList.getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppUserData retrieveNewUserDetails() {
|
||||
|
||||
URI restUri = URI.create(getBaseServerUrl().concat(
|
||||
"api/protected/admin/user/new"));
|
||||
|
||||
ResponseEntity<AppUserData> s = this.oauthRestServiceTemplate.exchange(
|
||||
restUri, HttpMethod.GET, emptyRequest(), AppUserData.class);
|
||||
|
||||
return s.getBody();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppUserData retrieveUser(Long userId) {
|
||||
URI restUri = URI.create(getBaseServerUrl().concat(
|
||||
"api/protected/admin/user/").concat(userId.toString()));
|
||||
|
||||
ResponseEntity<AppUserData> s = this.oauthRestServiceTemplate.exchange(
|
||||
restUri, HttpMethod.GET, emptyRequest(), AppUserData.class);
|
||||
|
||||
return s.getBody();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppUserData retrieveCurrentUser() {
|
||||
URI restUri = URI.create(getBaseServerUrl().concat(
|
||||
|
||||
+5
-1
@@ -78,7 +78,11 @@ public class AdministrationController {
|
||||
@RequestParam(value="lastname", required=false) String lastname,
|
||||
@RequestParam(value="email", required=false) String email) {
|
||||
|
||||
UserCommand command = new UserCommand(username, firstname, lastname, email);
|
||||
UserCommand command = new UserCommand();
|
||||
command.setUsername(username);
|
||||
command.setFirstname(firstname);
|
||||
command.setLastname(lastname);
|
||||
command.setEmail(email);
|
||||
|
||||
return this.commonRestOperations.updateCurrentUserDetails(command);
|
||||
}
|
||||
|
||||
-59
@@ -4,13 +4,11 @@ import java.util.Collection;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.mifosng.data.AppUserData;
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.ErrorResponse;
|
||||
import org.mifosng.data.PermissionData;
|
||||
import org.mifosng.data.RoleData;
|
||||
import org.mifosng.data.command.RoleCommand;
|
||||
import org.mifosng.data.command.UserCommand;
|
||||
import org.mifosng.ui.CommonRestOperations;
|
||||
import org.mifosng.ui.loanproduct.ClientValidationException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -83,63 +81,6 @@ public class AppUserController {
|
||||
return this.commonRestOperations.updateRole(command);
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/json", produces="application/json", value = "/admin/user/all", method = RequestMethod.GET)
|
||||
public @ResponseBody Collection<AppUserData> viewAllUsers() {
|
||||
|
||||
return this.commonRestOperations.retrieveAllUsers();
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/json", produces="application/json", value = "/admin/user/new", method = RequestMethod.GET)
|
||||
public @ResponseBody AppUserData viewUser() {
|
||||
|
||||
return this.commonRestOperations.retrieveNewUserDetails();
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/x-www-form-urlencoded", produces="application/json", value = "/admin/user/new", method = RequestMethod.POST)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public @ResponseBody EntityIdentifier createNewUser(@RequestParam(value="selectedItems", required=false) String[] selectedRoles,
|
||||
@RequestParam(value="username") String username,
|
||||
@RequestParam(value="firstname") String firstname,
|
||||
@RequestParam(value="lastname") String lastname,
|
||||
@RequestParam(value="email") String email,
|
||||
@RequestParam(value="officeId") Long officeId) {
|
||||
|
||||
UserCommand command = new UserCommand(username, firstname, lastname, "", email, selectedRoles, officeId);
|
||||
|
||||
return this.commonRestOperations.createUser(command);
|
||||
}
|
||||
|
||||
@RequestMapping(consumes = "application/json", produces = "application/json", value = "/admin/user/{userId}", method = RequestMethod.DELETE)
|
||||
public @ResponseBody
|
||||
EntityIdentifier attemptToDeleteUser(@PathVariable("userId") Long userId) {
|
||||
|
||||
this.commonRestOperations.deleteUser(userId);
|
||||
|
||||
return new EntityIdentifier(Long.valueOf(1));
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/json", produces="application/json", value = "/admin/user/{userId}", method = RequestMethod.GET)
|
||||
public @ResponseBody AppUserData viewUser(@PathVariable("userId") Long userId) {
|
||||
|
||||
return this.commonRestOperations.retrieveUser(userId);
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/x-www-form-urlencoded", produces="application/json", value = "/admin/user/{userId}", method = RequestMethod.POST)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public @ResponseBody EntityIdentifier updateUser(@PathVariable("userId") Long userId,
|
||||
@RequestParam(value="selectedItems", required=false) String[] selectedRoles,
|
||||
@RequestParam(value="username") String username,
|
||||
@RequestParam(value="firstname") String firstname,
|
||||
@RequestParam(value="lastname") String lastname,
|
||||
@RequestParam(value="email") String email,
|
||||
@RequestParam(value="officeId") Long officeId) {
|
||||
|
||||
UserCommand command = new UserCommand(username, firstname, lastname, "", email, selectedRoles, officeId);
|
||||
command.setId(userId);
|
||||
|
||||
return this.commonRestOperations.updateUser(command);
|
||||
}
|
||||
|
||||
@ExceptionHandler(ClientValidationException.class)
|
||||
public @ResponseBody Collection<ErrorResponse> validationException(ClientValidationException ex, HttpServletResponse response) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user