Subversion Repositories SmartDukaan

Rev

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

Rev 7461 Rev 7524
Line 1... Line 1...
1
package in.shop2020.support.controllers;
1
package in.shop2020.support.controllers;
2
 
2
 
-
 
3
import java.io.File;
-
 
4
import java.io.IOException;
3
import java.util.HashMap;
5
import java.util.HashMap;
4
import java.util.List;
6
import java.util.List;
5
import java.util.Map;
7
import java.util.Map;
6
 
8
 
7
import javax.servlet.ServletRequest;
9
import javax.servlet.ServletRequest;
Line 19... Line 21...
19
import in.shop2020.logistics.DeliveryType;
21
import in.shop2020.logistics.DeliveryType;
20
import in.shop2020.logistics.LogisticsInfo;
22
import in.shop2020.logistics.LogisticsInfo;
21
import in.shop2020.logistics.LogisticsServiceException;
23
import in.shop2020.logistics.LogisticsServiceException;
22
import in.shop2020.logistics.PickUpType;
24
import in.shop2020.logistics.PickUpType;
23
 
25
 
-
 
26
import org.apache.commons.io.FileUtils;
24
import org.apache.commons.lang.xwork.StringUtils;
27
import org.apache.commons.lang.xwork.StringUtils;
25
import org.apache.struts2.convention.annotation.Result;
28
import org.apache.struts2.convention.annotation.Result;
26
import org.apache.struts2.convention.annotation.Results;
29
import org.apache.struts2.convention.annotation.Results;
27
import org.apache.struts2.interceptor.ServletRequestAware;
30
import org.apache.struts2.interceptor.ServletRequestAware;
28
import org.apache.thrift.TException;
31
import org.apache.thrift.TException;
29
import org.apache.thrift.transport.TTransportException;
-
 
30
import org.slf4j.Logger;
32
import org.slf4j.Logger;
31
import org.slf4j.LoggerFactory;
33
import org.slf4j.LoggerFactory;
32
 
34
 
33
import com.opensymphony.xwork2.ValidationAwareSupport;
35
import com.opensymphony.xwork2.ValidationAwareSupport;
34
 
36
 
35
@SuppressWarnings("serial")
37
@SuppressWarnings("serial")
36
@Results({
38
@Results({
37
	@Result(name = "redirect", location = "${url}", type = "redirect") })
39
	@Result(name = "redirect", location = "${url}", type = "redirect"),
-
 
40
	@Result(name="authsuccess", type="redirectAction", params = {"actionName" , "reports"})
-
 
41
})
38
	public class AmazonListController extends ValidationAwareSupport implements ServletRequestAware {
42
public class AmazonListController extends ValidationAwareSupport implements ServletRequestAware {
39
 
43
 
40
	private static Logger logger = LoggerFactory.getLogger(AmazonListController.class);
44
	private static Logger logger = LoggerFactory.getLogger(AmazonListController.class);
41
 
45
 
42
	private ServletRequest request;
46
	private ServletRequest request;
43
	private String url;
47
	private String url;
Line 52... Line 56...
52
	private String isTime;
56
	private String isTime;
53
	private String handlingTime;
57
	private String handlingTime;
54
	private String customHandlingTime;
58
	private String customHandlingTime;
55
	private String holdInventory;
59
	private String holdInventory;
56
	private String defaultInventory;
60
	private String defaultInventory;
-
 
61
	private String fileUploadFileName;
-
 
62
	private String fileUploadContentType;
-
 
63
	private File file;
57
 
64
 
58
	public String index() {
65
	public String index() {
59
		return "index";
66
		return "index";
60
	}
67
	}
61
 
68
 
Line 95... Line 102...
95
		setUrl("/amazon-list/");
102
		setUrl("/amazon-list/");
96
		return "redirect";
103
		return "redirect";
97
 
104
 
98
	}
105
	}
99
 
106
 
-
 
107
	public String upload() throws IOException {
-
 
108
		File fileToCreate = new File("/tmp/", "Amazon-shipping.xls");
-
 
109
		FileUtils.copyFile(this.file, fileToCreate);
-
 
110
		return "authsuccess";
-
 
111
	}
-
 
112
 
100
	private void changeItemInventory() throws NumberFormatException, TException {
113
	private void changeItemInventory() throws NumberFormatException, TException {
101
		Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
114
		Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
-
 
115
 
102
		if (StringUtils.isEmpty(holdInventory)) {
116
		if (StringUtils.isEmpty(holdInventory)) {
103
			holdInventory = "0";
117
			holdInventory = "0";
104
		}
118
		}
105
		if (StringUtils.isEmpty(defaultInventory)) {
119
		if (StringUtils.isEmpty(defaultInventory)) {
106
			defaultInventory = "0";
120
			defaultInventory = "0";
107
		}
121
		}
108
		
122
 
109
		CatalogClient.updateItemInventory(Long.valueOf(itemId),Long.valueOf(holdInventory),Long.valueOf(defaultInventory));
123
		CatalogClient.updateItemInventory(Long.valueOf(itemId),Long.valueOf(holdInventory),Long.valueOf(defaultInventory));
110
	}
124
	}
111
 
125
 
112
 
126
 
113
	public Map<Long, Long> getAvailableItemInventory(String itemId) throws NumberFormatException, InventoryServiceException, TException{
127
	public Map<Long, Long> getAvailableItemInventory(String itemId) throws NumberFormatException, InventoryServiceException, TException{
Line 167... Line 181...
167
 
181
 
168
	public String editNew() {
182
	public String editNew() {
169
		return "editNew";
183
		return "editNew";
170
	}
184
	}
171
 
185
 
172
 
-
 
173
 
-
 
174
	public void setId(String id) {
186
	public void setId(String id) {
175
		this.id = id;
187
		this.id = id;
176
	}
188
	}
177
 
189
 
178
	public void setUrl(String url) {
190
	public void setUrl(String url) {
Line 264... Line 276...
264
	}
276
	}
265
 
277
 
266
	public String getCustomHandlingTime(){
278
	public String getCustomHandlingTime(){
267
		return customHandlingTime;
279
		return customHandlingTime;
268
	}
280
	}
269
	
281
 
270
	public void setHoldInventory(String holdInventory){
282
	public void setHoldInventory(String holdInventory){
271
		this.holdInventory = holdInventory;
283
		this.holdInventory = holdInventory;
272
	}
284
	}
273
 
285
 
274
	public String getHoldInventory(){
286
	public String getHoldInventory(){
275
		return holdInventory;
287
		return holdInventory;
276
	}
288
	}
277
	
289
 
278
	public void setDefaultInventory(String defaultInventory){
290
	public void setDefaultInventory(String defaultInventory){
279
		this.defaultInventory = defaultInventory;
291
		this.defaultInventory = defaultInventory;
280
	}
292
	}
281
 
293
 
282
	public String getDefaultInventory(){
294
	public String getDefaultInventory(){
283
		return defaultInventory;
295
		return defaultInventory;
284
	}
296
	}
285
 
297
 
-
 
298
	public File getFile() {
-
 
299
		return file;
-
 
300
	}
-
 
301
 
-
 
302
	public void setFile(File file) {
-
 
303
		this.file = file;
-
 
304
	}
-
 
305
 
-
 
306
	public String getFileUploadContentType() {
-
 
307
		return fileUploadContentType;
-
 
308
	}
-
 
309
 
-
 
310
	public void setFileUploadContentType(String fileUploadContentType) {
-
 
311
		this.fileUploadContentType = fileUploadContentType;
-
 
312
	}
-
 
313
 
-
 
314
	public String getFileUploadFileName() {
-
 
315
		return fileUploadFileName;
-
 
316
	}
-
 
317
 
-
 
318
	public void setFileUploadFileName(String fileUploadFileName) {
-
 
319
		this.fileUploadFileName = fileUploadFileName;
-
 
320
	}
-
 
321
 
286
	@Override
322
	@Override
287
	public void setServletRequest(HttpServletRequest request) {
323
	public void setServletRequest(HttpServletRequest request) {
288
		this.request = request;
324
		this.request = request;
289
 
325
 
290
	}
326
	}