small fixes
This commit is contained in:
		
							parent
							
								
									b6f5e73401
								
							
						
					
					
						commit
						f6447e7094
					
				| @ -33,7 +33,7 @@ public class UserDto { | |||||||
|         return email; |         return email; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void setEmail(String email) { |     public void setEmail(final String email) { | ||||||
|         this.email = email; |         this.email = email; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -43,7 +43,7 @@ public class UserDto { | |||||||
|         return role; |         return role; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void setRole(Integer role) { |     public void setRole(final Integer role) { | ||||||
|         this.role = role; |         this.role = role; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -51,7 +51,7 @@ public class UserDto { | |||||||
|         return firstName; |         return firstName; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void setFirstName(String firstName) { |     public void setFirstName(final String firstName) { | ||||||
|         this.firstName = firstName; |         this.firstName = firstName; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -59,7 +59,7 @@ public class UserDto { | |||||||
|         return lastName; |         return lastName; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void setLastName(String lastName) { |     public void setLastName(final String lastName) { | ||||||
|         this.lastName = lastName; |         this.lastName = lastName; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -67,7 +67,7 @@ public class UserDto { | |||||||
|         return password; |         return password; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void setPassword(String password) { |     public void setPassword(final String password) { | ||||||
|         this.password = password; |         this.password = password; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -75,7 +75,7 @@ public class UserDto { | |||||||
|         return matchingPassword; |         return matchingPassword; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void setMatchingPassword(String matchingPassword) { |     public void setMatchingPassword(final String matchingPassword) { | ||||||
|         this.matchingPassword = matchingPassword; |         this.matchingPassword = matchingPassword; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -30,7 +30,6 @@ import org.springframework.security.core.context.SecurityContextHolder; | |||||||
| import org.springframework.security.core.userdetails.UserDetailsService; | import org.springframework.security.core.userdetails.UserDetailsService; | ||||||
| import org.springframework.stereotype.Controller; | import org.springframework.stereotype.Controller; | ||||||
| import org.springframework.ui.Model; | import org.springframework.ui.Model; | ||||||
| import org.springframework.validation.BindingResult; |  | ||||||
| import org.springframework.validation.Errors; | import org.springframework.validation.Errors; | ||||||
| import org.springframework.web.bind.annotation.ModelAttribute; | import org.springframework.web.bind.annotation.ModelAttribute; | ||||||
| import org.springframework.web.bind.annotation.RequestMapping; | import org.springframework.web.bind.annotation.RequestMapping; | ||||||
| @ -102,25 +101,22 @@ public class OldRegistrationController { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @RequestMapping(value = "/user/registration", method = RequestMethod.POST) |     @RequestMapping(value = "/user/registration", method = RequestMethod.POST) | ||||||
|     public ModelAndView registerUserAccount(@ModelAttribute("user") @Valid final UserDto accountDto, final BindingResult result, final HttpServletRequest request, final Errors errors) { |     public ModelAndView registerUserAccount(@ModelAttribute("user") @Valid final UserDto userDto, final HttpServletRequest request, final Errors errors) { | ||||||
|         LOGGER.debug("Registering user account with information: {}", accountDto); |         LOGGER.debug("Registering user account with information: {}", userDto); | ||||||
|         if (result.hasErrors()) { |  | ||||||
|             return new ModelAndView("registration", "user", accountDto); |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         final User registered = createUserAccount(accountDto); |         final User registered = createUserAccount(userDto); | ||||||
|         if (registered == null) { |         if (registered == null) { | ||||||
|             result.rejectValue("email", "message.regError"); |             // result.rejectValue("email", "message.regError"); | ||||||
|             return new ModelAndView("registration", "user", accountDto); |             return new ModelAndView("registration", "user", userDto); | ||||||
|         } |         } | ||||||
|         try { |         try { | ||||||
|             final String appUrl = "http://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath(); |             final String appUrl = "http://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath(); | ||||||
|             eventPublisher.publishEvent(new OnRegistrationCompleteEvent(registered, request.getLocale(), appUrl)); |             eventPublisher.publishEvent(new OnRegistrationCompleteEvent(registered, request.getLocale(), appUrl)); | ||||||
|         } catch (final Exception ex) { |         } catch (final Exception ex) { | ||||||
|             LOGGER.warn("Unable to register user", ex); |             LOGGER.warn("Unable to register user", ex); | ||||||
|             return new ModelAndView("emailError", "user", accountDto); |             return new ModelAndView("emailError", "user", userDto); | ||||||
|         } |         } | ||||||
|         return new ModelAndView("successRegister", "user", accountDto); |         return new ModelAndView("successRegister", "user", userDto); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @RequestMapping(value = "/user/resendRegistrationToken", method = RequestMethod.GET) |     @RequestMapping(value = "/user/resendRegistrationToken", method = RequestMethod.GET) | ||||||
|  | |||||||
| @ -28,9 +28,9 @@ public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionH | |||||||
| 
 | 
 | ||||||
|     // 400 |     // 400 | ||||||
|     @Override |     @Override | ||||||
|     protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { |     protected ResponseEntity<Object> handleMethodArgumentNotValid(final MethodArgumentNotValidException ex, final HttpHeaders headers, final HttpStatus status, final WebRequest request) { | ||||||
|         logger.error("400 Status Code", ex); |         logger.error("400 Status Code", ex); | ||||||
|         BindingResult result = ex.getBindingResult(); |         final BindingResult result = ex.getBindingResult(); | ||||||
|         final GenericResponse bodyOfResponse = new GenericResponse(result.getFieldErrors(), result.getGlobalErrors()); |         final GenericResponse bodyOfResponse = new GenericResponse(result.getFieldErrors(), result.getGlobalErrors()); | ||||||
|         return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.BAD_REQUEST, request); |         return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.BAD_REQUEST, request); | ||||||
|     } |     } | ||||||
| @ -48,14 +48,14 @@ public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionH | |||||||
|     public ResponseEntity<Object> handleMail(final RuntimeException ex, final WebRequest request) { |     public ResponseEntity<Object> handleMail(final RuntimeException ex, final WebRequest request) { | ||||||
|         logger.error("500 Status Code", ex); |         logger.error("500 Status Code", ex); | ||||||
|         final GenericResponse bodyOfResponse = new GenericResponse(messages.getMessage("message.email.config.error", null, request.getLocale()), "MailError"); |         final GenericResponse bodyOfResponse = new GenericResponse(messages.getMessage("message.email.config.error", null, request.getLocale()), "MailError"); | ||||||
|         return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.NOT_FOUND, request); |         return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.INTERNAL_SERVER_ERROR, request); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @ExceptionHandler({ Exception.class }) |     @ExceptionHandler({ Exception.class }) | ||||||
|     public ResponseEntity<Object> handleInternal(final RuntimeException ex, final WebRequest request) { |     public ResponseEntity<Object> handleInternal(final RuntimeException ex, final WebRequest request) { | ||||||
|         logger.error("500 Status Code", ex); |         logger.error("500 Status Code", ex); | ||||||
|         final GenericResponse bodyOfResponse = new GenericResponse(messages.getMessage("message.error", null, request.getLocale()), "InternalError"); |         final GenericResponse bodyOfResponse = new GenericResponse(messages.getMessage("message.error", null, request.getLocale()), "InternalError"); | ||||||
|         return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.NOT_FOUND, request); |         return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.INTERNAL_SERVER_ERROR, request); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user