Subversion Repositories SmartDukaan

Rev

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

Rev 17857 Rev 17858
Line 428... Line 428...
428
    }
428
    }
429
    
429
    
430
    
430
    
431
    public String validateCart() {
431
    public String validateCart() {
432
    	log.info(this.cartMap);
432
    	log.info(this.cartMap);
-
 
433
    	JSONObject jsonObj  = null;
433
    	if(!userinfo.isPrivateDealUser()){
434
    	if(!userinfo.isPrivateDealUser()){
434
    		cartPojoJson = "{\"response\":\"error\", \"message\":\"Invalid request.\"}";
435
    		cartPojoJson = "{\"response\":\"error\", \"message\":\"Invalid request.\"}";
435
    	} else {
436
    	} else {
436
    		if(StringUtils.isEmpty(cartMap))
437
    		if(StringUtils.isEmpty(cartMap)){
437
    			cartPojoJson = "{\"response\":\"error\", \"message\":\"Empty Cart.\"}";
438
    			jsonObj = new JSONObject("{\"cartItems\":\"[]\"}");
438
    		else {
439
    		}else {
-
 
440
    			jsonObj = new JSONObject(cartMap);
-
 
441
    		}
439
    			try{
442
    			try{
440
    				List<ItemQuantity> itemQuantities = new ArrayList<ItemQuantity>();
443
    				List<ItemQuantity> itemQuantities = new ArrayList<ItemQuantity>();
441
    				JSONObject jsonObj = new JSONObject(cartMap);
-
 
442
    				JSONArray cartItems = jsonObj.getJSONArray("cartItems");
444
    				JSONArray cartItems = jsonObj.getJSONArray("cartItems");
443
    				List<Integer> itemsList = new ArrayList<Integer>();
445
    				List<Integer> itemsList = new ArrayList<Integer>();
444
					for (int i=0; i< cartItems.length(); i++) {
446
					for (int i=0; i< cartItems.length(); i++) {
445
						JSONObject obj = cartItems.getJSONObject(i);
447
						JSONObject obj = cartItems.getJSONObject(i);
446
						int itemId = obj.getInt("itemId");
448
						int itemId = obj.getInt("itemId");
Line 545... Line 547...
545
					}
547
					}
546
    			}catch(Exception e) {
548
    			}catch(Exception e) {
547
    				cartPojoJson = "{\"response\":\"error\", \"message\":\"Something went wrong while validation\"}";
549
    				cartPojoJson = "{\"response\":\"error\", \"message\":\"Something went wrong while validation\"}";
548
    				e.printStackTrace();
550
    				e.printStackTrace();
549
    			}
551
    			}
550
    		}
-
 
551
    		
-
 
552
    	}
552
    	}
553
    	setResultJson(cartPojoJson);
553
    	setResultJson(cartPojoJson);
554
    	return "index";
554
    	return "index";
555
    }
555
    }
556
 
556