Subversion Repositories SmartDukaan

Rev

Rev 9612 | Rev 9676 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9612 Rev 9667
Line 1... Line 1...
1
package in.shop2020.mobileapi.serving.controllers;
1
package in.shop2020.mobileapi.serving.controllers;
2
 
2
 
3
import in.shop2020.datalogger.EventType;
3
import in.shop2020.datalogger.EventType;
4
import in.shop2020.mobileapi.serving.services.ContentServingService;
4
import in.shop2020.mobileapi.serving.services.ContentServingService;
-
 
5
import in.shop2020.mobileapi.serving.utils.PojoPopulator;
5
import in.shop2020.mobileapi.serving.utils.SnippetType;
6
import in.shop2020.mobileapi.serving.utils.SnippetType;
6
import in.shop2020.model.v1.catalog.CatalogService.Client;
7
import in.shop2020.model.v1.catalog.CatalogService.Client;
7
import in.shop2020.model.v1.catalog.Item;
8
import in.shop2020.model.v1.catalog.Item;
8
import in.shop2020.model.v1.user.Cart;
9
import in.shop2020.model.v1.user.Cart;
9
import in.shop2020.model.v1.user.ShoppingCartException;
10
import in.shop2020.model.v1.user.ShoppingCartException;
Line 24... Line 25...
24
import org.apache.struts2.convention.annotation.Result;
25
import org.apache.struts2.convention.annotation.Result;
25
import org.apache.struts2.convention.annotation.Results;
26
import org.apache.struts2.convention.annotation.Results;
26
import org.apache.struts2.interceptor.ParameterAware;
27
import org.apache.struts2.interceptor.ParameterAware;
27
import org.apache.thrift.TException;
28
import org.apache.thrift.TException;
28
 
29
 
-
 
30
import com.google.gson.Gson;
-
 
31
 
29
 
32
 
30
@Results({
33
@Results({
31
    @Result(name = "index", location = "cart-index.vm"),
34
    @Result(name = "index", location = "cart-index.vm"),
32
    @Result(name="redirect", type="redirectAction", params = {"actionName" , "cart"}),
35
    @Result(name="redirect", type="redirectAction", params = {"actionName" , "cart"}),
33
    @Result(name="failure", location="cart-failure.vm"),
36
    @Result(name="failure", location="cart-failure.vm"),
Line 57... Line 60...
57
    
60
    
58
    private boolean toInsure;
61
    private boolean toInsure;
59
    private long productId;
62
    private long productId;
60
    
63
    
61
    private long cartId;
64
    private long cartId;
-
 
65
    private String cartPojoJson;
62
    
66
    
63
    public CartController(){
67
    public CartController(){
64
        super();
68
        super();
65
    }
69
    }
66
    
70
    
67
 
71
 
68
    public String index()  {
72
    public String index()  {
69
        this.setVariationId(request.getRequestURI());
-
 
70
        log.info(this.getVariationId());
-
 
71
        
-
 
72
        if(cartId != -1){
73
        if(cartId != -1){
73
            try {
74
            try {
74
                UserContextService.Client userClient = (new UserClient()).getClient();
75
                UserContextService.Client userClient = (new UserClient()).getClient();
75
                Cart cart = userClient.getCurrentCart(userinfo.getUserId());
76
                Cart cart = userClient.getCurrentCart(userinfo.getUserId());
76
                cartId = cart.getId();
77
                cartId = cart.getId();
Line 78... Line 79...
78
                errorMsg = cartResponse.get(0);
79
                errorMsg = cartResponse.get(0);
79
                if(StringUtils.isNotEmpty(cartResponse.get(1))) {
80
                if(StringUtils.isNotEmpty(cartResponse.get(1))) {
80
                    addActionMessage(cartResponse.get(1));
81
                    addActionMessage(cartResponse.get(1));
81
                }
82
                }
82
                log.info("Cart Change/EMI Message rcvd from the service is:" + errorMsg);
83
                log.info("Cart Change/EMI Message rcvd from the service is:" + errorMsg);
-
 
84
                
-
 
85
                cartPojoJson = new Gson().toJson(PojoPopulator.getCartPojo(cart, errorMsg));
-
 
86
                
83
            } catch (Exception e) {
87
            } catch (Exception e) {
84
                // This exception can be ignored for showing the cart. Not so
88
                // This exception can be ignored for showing the cart. Not so
85
                // innocent when this occurs at the time of checkout or when the
89
                // innocent when this occurs at the time of checkout or when the
86
                // user is proceeding to pay.
90
                // user is proceeding to pay.
87
                log.warn("Unable to validate the cart: ", e);
91
                log.warn("Unable to validate the cart: ", e);
Line 492... Line 496...
492
    }
496
    }
493
 
497
 
494
    public void setCartId(long cartId) {
498
    public void setCartId(long cartId) {
495
        this.cartId = cartId;
499
        this.cartId = cartId;
496
    }
500
    }
-
 
501
 
-
 
502
 
-
 
503
    public void setCartPojoJson(String cartPojoJson) {
-
 
504
        this.cartPojoJson = cartPojoJson;
-
 
505
    }
-
 
506
 
-
 
507
 
-
 
508
    public String getCartPojoJson() {
-
 
509
        return cartPojoJson;
-
 
510
    }
497
}
511
}