Subversion Repositories SmartDukaan

Rev

Rev 786 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 786 Rev 801
Line 9... Line 9...
9
import in.shop2020.serving.utils.Utils;
9
import in.shop2020.serving.utils.Utils;
10
import in.shop2020.thrift.clients.UserContextServiceClient;
10
import in.shop2020.thrift.clients.UserContextServiceClient;
11
 
11
 
12
import org.apache.juli.logging.Log;
12
import org.apache.juli.logging.Log;
13
import org.apache.juli.logging.LogFactory;
13
import org.apache.juli.logging.LogFactory;
-
 
14
import org.apache.struts2.convention.annotation.Result;
14
import org.apache.struts2.interceptor.ParameterAware;
15
import org.apache.struts2.interceptor.ParameterAware;
15
import org.apache.thrift.TException;
16
import org.apache.thrift.TException;
16
 
17
 
-
 
18
@Result(name="redirect", type="redirectAction", 
-
 
19
   		params = {"actionName" , "cart"})
17
public class CartController extends BaseController implements ParameterAware{
20
public class CartController extends BaseController implements ParameterAware{
18
	
21
	
19
	private static final long serialVersionUID = 1L;
22
	private static final long serialVersionUID = 1L;
20
	private static Log log = LogFactory.getLog(CartController.class);
23
	private static Log log = LogFactory.getLog(CartController.class);
21
	Map<String, String[]> reqparams = null;
24
	Map<String, String[]> reqparams = null;
Line 99... Line 102...
99
			if(userinfo.getCartId() == -1){
102
			if(userinfo.getCartId() == -1){
100
				log.info("Cart does not exist. Nothing to delete.");
103
				log.info("Cart does not exist. Nothing to delete.");
101
			}else{
104
			}else{
102
				if(deleteItemFromCart(userinfo.getCartId(), itemId, userinfo.getUserId(), userinfo.isSessionId())){
105
				if(deleteItemFromCart(userinfo.getCartId(), itemId, userinfo.getUserId(), userinfo.isSessionId())){
103
					userinfo.setTotalItems(getNumberOfItemsInCart(userinfo.getCartId()));
106
					userinfo.setTotalItems(getNumberOfItemsInCart(userinfo.getCartId()));
104
					return "delsuccess";	
107
					return "redirect";	
105
				}
108
				}
106
			}
109
			}
107
			return "delfailure";
110
			return "redirect";
108
		}
111
		}
109
		
112
		
110
		
113
		
111
		// DELETE /entity
114
		// DELETE /entity
112
		public String update() {
115
		public String update() {
Line 120... Line 123...
120
			long quantity = Long.parseLong(quantityString);
123
			long quantity = Long.parseLong(quantityString);
121
			if(quantity <= 0){
124
			if(quantity <= 0){
122
				log.info("Not valid item quantity. Unable to change item quantity.");
125
				log.info("Not valid item quantity. Unable to change item quantity.");
123
			}else{
126
			}else{
124
				if(updateItemQuantityInCart(userinfo.getCartId(), itemId, quantity)){
127
				if(updateItemQuantityInCart(userinfo.getCartId(), itemId, quantity)){
125
					return "delsuccess";	
128
					return "redirect";	
126
				}
129
				}
127
			}
130
			}
-
 
131
			addActionError("Unable to update the quantity");
128
			return "delfailure";
132
			return "redirect";
129
		}
133
		}
130
		
134
		
131
		
135
		
132
    public void printParams(){
136
    public void printParams(){
133
    	for(String param : reqparams.keySet()) {
137
    	for(String param : reqparams.keySet()) {