Skip to content

Commit

Permalink
merge from 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
shopizer-ecommerce committed Dec 12, 2021
2 parents 3346ec5 + 6d9c834 commit 36fe2a5
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 46 deletions.
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ Java open source e-commerce software

Headless commerce and Rest api for ecommerce

Catalogue
Shopping cart
Checkout
Merchant
Order
Customer
User
- Catalogue
- Shopping cart
- Checkout
- Merchant
- Order
- Customer
- User

Shopizer Headless commerce consists of the following components:

Expand All @@ -37,10 +37,9 @@ Available soon

Demo site for Shopizer 2.X is still available [Legacy Shopizer demo](http://demo.shopizer.com)

Run from Docker images:
-------------------
1. Run from Docker images:

1. Run java backend
From the command line:

```
docker run -p 8080:8080 shopizerecomm/shopizer:3.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public interface UserFacade {
/**
* Find user by id
* @param id
* @param merchant
* @param store
* @param lang
* @return
*/
Expand Down Expand Up @@ -81,7 +81,7 @@ public interface UserFacade {
/**
* Determines if a user is in a specific group
* @param userName
* @param groupName
* @param groupNames
*/
void authorizedGroup(String userName, List<String> groupNames);

Expand Down Expand Up @@ -142,7 +142,6 @@ public interface UserFacade {
* Change password request
* @param userId
* @param authenticatedUser
* @param storeCode
* @param changePassword
*/
void changePassword(Long userId, String authenticatedUser, UserPassword changePassword);
Expand Down
6 changes: 6 additions & 0 deletions sm-shop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-rng-simple -->
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,87 +6,103 @@
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.TypeMismatchException;
import org.springframework.http.HttpStatus;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.ui.Model;
import org.springframework.validation.BindException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.multipart.support.MissingServletRequestPartException;
import org.springframework.web.servlet.ModelAndView;

@ControllerAdvice("com.salesmanager.shop.admin")
public class AdminErrorController {


private static final Logger LOGGER = LoggerFactory.getLogger(AdminErrorController.class);

private static final String LOG_ERROR_MESSAGE = "Error page controller";

/**
* Handles specific Spring MVC internal exceptions as HTTP status 400
* @param ex the actual exception
* @return an error model
*/
// list of "BAD REQUEST"-related exceptions are taken over from Springs DefaultHandlerExceptionResolver
@ExceptionHandler({
MissingServletRequestParameterException.class,
ServletRequestBindingException.class,
TypeMismatchException.class,
HttpMessageNotReadableException.class,
MethodArgumentNotValidException.class,
MissingServletRequestPartException.class,
BindException.class
})
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
@Produces({MediaType.APPLICATION_JSON})
public ModelAndView handleBadRequest(Exception ex) {

LOGGER.error(LOG_ERROR_MESSAGE,ex);
return createGenericErrorModel(ex);

}

@ExceptionHandler(Exception.class)
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
@Produces({MediaType.APPLICATION_JSON})
public ModelAndView handleException(Exception ex) {

LOGGER.error("Error page controller",ex);
LOGGER.error(LOG_ERROR_MESSAGE,ex);

ModelAndView model = null;
ModelAndView model;
if(ex instanceof AccessDeniedException) {

model = new ModelAndView("error/access_denied");

} else {

model = new ModelAndView("error/generic_error");
model.addObject("stackError", ExceptionUtils.getStackTrace(ex));
model.addObject("errMsg", ex.getMessage());


model = createGenericErrorModel(ex);

}

return model;

}



@ExceptionHandler(RuntimeException.class)
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
@Produces({MediaType.APPLICATION_JSON})
public ModelAndView handleRuntimeException(Exception ex) {

LOGGER.error("Error page controller",ex);
LOGGER.error(LOG_ERROR_MESSAGE,ex);

ModelAndView model = null;
return createGenericErrorModel(ex);


model = new ModelAndView("error/generic_error");
model.addObject("stackError", ExceptionUtils.getStackTrace(ex));
model.addObject("errMsg", ex.getMessage());




return model;

}

/**
* Generic exception catch allpage
* @param ex
* @param model
* @return
*/
@RequestMapping(value="/error", method=RequestMethod.GET)
public ModelAndView handleCatchAllException(Model model) {


ModelAndView modelAndView = null;
return new ModelAndView("error/generic_error");


modelAndView = new ModelAndView("error/generic_error");

return modelAndView;

}


private ModelAndView createGenericErrorModel(Exception ex) {
ModelAndView model = new ModelAndView("error/generic_error");
model.addObject("stackError", ExceptionUtils.getStackTrace(ex));
model.addObject("errMsg", ex.getMessage());
return model;
}
}

0 comments on commit 36fe2a5

Please sign in to comment.