Subversion Repositories SmartDukaan

Rev

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

Rev 2263 Rev 2296
Line 80... Line 80...
80
    			addActionError("We are experiencing some problems. Please try later.");
80
    			addActionError("We are experiencing some problems. Please try later.");
81
    			return "shipping-redirect";
81
    			return "shipping-redirect";
82
    		}
82
    		}
83
    	}catch (Exception e) {
83
    	}catch (Exception e) {
84
    		addActionError("We are experiencing some problems. Please try later.");
84
    		addActionError("We are experiencing some problems. Please try later.");
85
    		log.error("Exception in createOrders function. Something want wrong.");
85
    		log.error("Exception in createOrders function. Something went wrong.", e);
86
    		e.printStackTrace();
-
 
87
    		return "shipping-redirect";
86
    		return "shipping-redirect";
88
		}
87
		}
89
    	
88
    	
90
		if (paymentOption.equals(IPaymentService.EBS_MASTERCARD) || paymentOption.equals(IPaymentService.EBS_VISA) || paymentOption.equals(IPaymentService.EBS_VISA_ELECTRON)) {
89
		if (paymentOption.equals(IPaymentService.EBS_MASTERCARD) || paymentOption.equals(IPaymentService.EBS_VISA) || paymentOption.equals(IPaymentService.EBS_VISA_ELECTRON)) {
91
			// User has selected Visa or MasterCard CC
90
			// User has selected Visa or MasterCard CC
Line 143... Line 142...
143
	private boolean createOrders(long addressId, long currentCartId){
142
	private boolean createOrders(long addressId, long currentCartId){
144
		UserContextServiceClient userServiceClient = null;
143
		UserContextServiceClient userServiceClient = null;
145
		try {
144
		try {
146
			userServiceClient = new UserContextServiceClient();
145
			userServiceClient = new UserContextServiceClient();
147
		} catch (Exception e) {
146
		} catch (Exception e) {
148
			e.printStackTrace();
147
			log.error("Unable to talk to the user context service.", e);
149
			return false;
148
			return false;
150
		}
149
		}
151
		
150
		
152
		in.shop2020.model.v1.user.UserContextService.Client userClient = userServiceClient.getClient();
151
		in.shop2020.model.v1.user.UserContextService.Client userClient = userServiceClient.getClient();
153
		try {
152
		try {
154
			userClient.addAddressToCart(currentCartId, addressId);
153
			userClient.addAddressToCart(currentCartId, addressId);
155
		} catch (ShoppingCartException e1) {
154
		} catch (ShoppingCartException e1) {
156
			log.error("Not able to set address in the cart." + e1.getId() + e1.getMessage());
155
			log.error("Not able to set address in the cart.", e1);
157
			e1.printStackTrace();
-
 
158
			return false;
156
			return false;
159
		} catch (TException e1) {
157
		} catch (TException e1) {
160
			log.error("Thrift exception while setting address in cart." + e1.getMessage());
158
			log.error("Thrift exception while setting address in cart.", e1);
161
			e1.printStackTrace();
-
 
162
			return false;
159
			return false;
163
		}
160
		}
164
		
161
		
165
		
162
		
166
		try {
163
		try {
Line 168... Line 165...
168
			if(!errorMsg.isEmpty()){
165
			if(!errorMsg.isEmpty()){
169
				addActionError(errorMsg);
166
				addActionError(errorMsg);
170
				return false;
167
				return false;
171
			}
168
			}
172
		} catch (ShoppingCartException e1) {
169
		} catch (ShoppingCartException e1) {
173
			log.error("Error while validating shopping cart." + e1.getId() + e1.getMessage());
170
			log.error("Error while validating shopping cart.", e1);
174
			e1.printStackTrace();
-
 
175
			return false;
171
			return false;
176
		} catch (TException e) {
172
		} catch (TException e) {
177
			log.error("Thrift exception while validating cart." + e.getMessage());
173
			log.error("Thrift exception while validating cart.", e);
178
			e.printStackTrace();
-
 
179
			return false;
174
			return false;
180
		}
175
		}
181
		
176
		
182
		
177
		
183
		try {
178
		try {
184
			txnId = userClient.createOrders(currentCartId);
179
			txnId = userClient.createOrders(currentCartId);
185
		} catch (ShoppingCartException e1) {
180
		} catch (ShoppingCartException e1) {
186
			log.error("Error while creating orders from cart." + e1.getId() + e1.getMessage());
181
			log.error("Error while creating orders from cart.", e1);
187
			e1.printStackTrace();
-
 
188
			return false;
182
			return false;
189
		} catch (TException e) {
183
		} catch (TException e) {
190
			log.error("Thrift exception while creating orders from cart." + e.getMessage());
184
			log.error("Thrift exception while creating orders from cart.", e);
191
			e.printStackTrace();
-
 
192
			return false;
185
			return false;
193
		}
186
		}
194
		
187
		
195
		TransactionServiceClient transactionServiceClient = null;
188
		TransactionServiceClient transactionServiceClient = null;
196
        try {
189
        try {
Line 200... Line 193...
200
                DataLogger.logData(EventType.ORDER_CREATION.name(), session.getId(),
193
                DataLogger.logData(EventType.ORDER_CREATION.name(), session.getId(),
201
                        Long.toString(userinfo.getUserId()),
194
                        Long.toString(userinfo.getUserId()),
202
                        userinfo.getEmail(), Long.toString(order.getId()));
195
                        userinfo.getEmail(), Long.toString(order.getId()));
203
            }
196
            }
204
        } catch (Exception e1) {
197
        } catch (Exception e1) {
205
            e1.printStackTrace();
198
        	log.warn("Unable to log orders through the datalogger", e1);
206
        }
199
        }
207
		
200
		
208
		return true;
201
		return true;
209
	}
202
	}
210
	
203