Subversion Repositories SmartDukaan

Rev

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

Rev 7524 Rev 7591
Line 4... Line 4...
4
import java.io.IOException;
4
import java.io.IOException;
5
import java.util.HashMap;
5
import java.util.HashMap;
6
import java.util.List;
6
import java.util.List;
7
import java.util.Map;
7
import java.util.Map;
8
 
8
 
-
 
9
import javax.servlet.ServletContext;
9
import javax.servlet.ServletRequest;
10
import javax.servlet.ServletRequest;
10
import javax.servlet.http.HttpServletRequest;
11
import javax.servlet.http.HttpServletRequest;
-
 
12
import javax.servlet.http.HttpSession;
11
 
13
 
12
import in.shop2020.model.v1.catalog.Amazonlisted;
14
import in.shop2020.model.v1.catalog.Amazonlisted;
13
import in.shop2020.model.v1.catalog.CatalogServiceException;
15
import in.shop2020.model.v1.catalog.CatalogServiceException;
14
import in.shop2020.model.v1.catalog.Item;
16
import in.shop2020.model.v1.catalog.Item;
15
import in.shop2020.model.v1.inventory.AmazonInventorySnapshot;
17
import in.shop2020.model.v1.inventory.AmazonInventorySnapshot;
16
import in.shop2020.model.v1.catalog.CatalogService.Client;
18
import in.shop2020.model.v1.catalog.CatalogService.Client;
17
import in.shop2020.model.v1.inventory.InventoryServiceException;
19
import in.shop2020.model.v1.inventory.InventoryServiceException;
-
 
20
import in.shop2020.support.utils.ReportsUtils;
18
import in.shop2020.thrift.clients.CatalogClient;
21
import in.shop2020.thrift.clients.CatalogClient;
19
import in.shop2020.thrift.clients.InventoryClient;
22
import in.shop2020.thrift.clients.InventoryClient;
20
import in.shop2020.thrift.clients.LogisticsClient;
23
import in.shop2020.thrift.clients.LogisticsClient;
21
import in.shop2020.logistics.DeliveryType;
24
import in.shop2020.logistics.DeliveryType;
22
import in.shop2020.logistics.LogisticsInfo;
25
import in.shop2020.logistics.LogisticsInfo;
23
import in.shop2020.logistics.LogisticsServiceException;
26
import in.shop2020.logistics.LogisticsServiceException;
24
import in.shop2020.logistics.PickUpType;
27
import in.shop2020.logistics.PickUpType;
25
 
28
 
26
import org.apache.commons.io.FileUtils;
29
import org.apache.commons.io.FileUtils;
27
import org.apache.commons.lang.xwork.StringUtils;
30
import org.apache.commons.lang.xwork.StringUtils;
-
 
31
import org.apache.struts2.convention.annotation.InterceptorRef;
-
 
32
import org.apache.struts2.convention.annotation.InterceptorRefs;
28
import org.apache.struts2.convention.annotation.Result;
33
import org.apache.struts2.convention.annotation.Result;
29
import org.apache.struts2.convention.annotation.Results;
34
import org.apache.struts2.convention.annotation.Results;
30
import org.apache.struts2.interceptor.ServletRequestAware;
35
import org.apache.struts2.interceptor.ServletRequestAware;
31
import org.apache.thrift.TException;
36
import org.apache.thrift.TException;
32
import org.slf4j.Logger;
37
import org.slf4j.Logger;
33
import org.slf4j.LoggerFactory;
38
import org.slf4j.LoggerFactory;
34
 
39
 
35
import com.opensymphony.xwork2.ValidationAwareSupport;
40
import com.opensymphony.xwork2.ValidationAwareSupport;
36
 
41
 
37
@SuppressWarnings("serial")
42
@SuppressWarnings("serial")
-
 
43
@InterceptorRefs({
-
 
44
	@InterceptorRef("defaultStack"),
-
 
45
	@InterceptorRef("login")
-
 
46
})
38
@Results({
47
@Results({
39
	@Result(name = "redirect", location = "${url}", type = "redirect"),
48
	@Result(name = "redirect", location = "${url}", type = "redirect"),
40
	@Result(name="authsuccess", type="redirectAction", params = {"actionName" , "reports"})
49
	@Result(name="authsuccess", type="redirectAction", params = {"actionName" , "reports"})
41
})
50
})
42
public class AmazonListController extends ValidationAwareSupport implements ServletRequestAware {
51
public class AmazonListController extends ValidationAwareSupport implements ServletRequestAware {
43
 
52
 
44
	private static Logger logger = LoggerFactory.getLogger(AmazonListController.class);
53
	private static Logger logger = LoggerFactory.getLogger(AmazonListController.class);
45
 
54
 
46
	private ServletRequest request;
55
	private HttpServletRequest request;
-
 
56
	private HttpSession session;
-
 
57
	private ServletContext context;
47
	private String url;
58
	private String url;
48
	private String id;
59
	private String id;
49
	private String itemId;
60
	private String itemId;
50
	private String isFba;
61
	private String isFba;
51
	private String isNonFba;
62
	private String isNonFba;
Line 61... Line 72...
61
	private String fileUploadFileName;
72
	private String fileUploadFileName;
62
	private String fileUploadContentType;
73
	private String fileUploadContentType;
63
	private File file;
74
	private File file;
64
 
75
 
65
	public String index() {
76
	public String index() {
-
 
77
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getServletPath())) {
-
 
78
			return "authfail";
-
 
79
		}
66
		return "index";
80
		return "index";
67
	}
81
	}
68
 
82
 
69
 
-
 
70
	public List<Amazonlisted> fetchItems() throws TException {
83
	public List<Amazonlisted> fetchItems() throws TException {
71
		Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
84
		Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
72
		return CatalogClient.getAllAmazonListedItems();
85
		return CatalogClient.getAllAmazonListedItems();
73
	}
86
	}
74
 
87
 
Line 89... Line 102...
89
		if ( Double.valueOf(fbaPrice) > Double.valueOf(saholicPrice) || Double.valueOf(sellingPrice) > Double.valueOf(saholicPrice) ) {
102
		if ( Double.valueOf(fbaPrice) > Double.valueOf(saholicPrice) || Double.valueOf(sellingPrice) > Double.valueOf(saholicPrice) ) {
90
			addActionError("Failed To Do Changes");
103
			addActionError("Failed To Do Changes");
91
		}
104
		}
92
		else {
105
		else {
93
			boolean flag=false;
106
			boolean flag=false;
94
			long delay = Long.valueOf(handlingTime);
107
			long delay = Long.valueOf(customHandlingTime);
95
			if ( Boolean.valueOf(isTime)) {
108
			if ( Boolean.valueOf(isTime)) {
96
				flag = true;
109
				flag = true;
97
				delay = Long.valueOf(customHandlingTime);
-
 
98
			}
110
			}
99
			changeItemInventory();
111
			changeItemInventory();
100
			CatalogClient.updateAmazonItemDetails(Long.valueOf(itemId),Double.valueOf(fbaPrice),Double.valueOf(sellingPrice),Boolean.valueOf(isFba),Boolean.valueOf(isNonFba),Boolean.valueOf(isInventoryOverride),delay,flag);
112
			CatalogClient.updateAmazonItemDetails(Long.valueOf(itemId),Double.valueOf(fbaPrice),Double.valueOf(sellingPrice),Boolean.valueOf(isFba),Boolean.valueOf(isNonFba),Boolean.valueOf(isInventoryOverride),delay,flag);
101
		}
113
		}
102
		setUrl("/amazon-list/");
114
		//setUrl("/amazon-list/");
103
		return "redirect";
115
		return "index";
104
 
116
 
105
	}
117
	}
106
 
118
 
107
	public String upload() throws IOException {
119
	public String upload() throws IOException {
108
		File fileToCreate = new File("/tmp/", "Amazon-shipping.xls");
120
		File fileToCreate = new File("/tmp/", "Amazon-shipping.xls");
Line 170... Line 182...
170
		}
182
		}
171
		return itemMap;
183
		return itemMap;
172
	}
184
	}
173
 
185
 
174
	public String edit() {
186
	public String edit() {
-
 
187
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1])) {
-
 
188
			return "authfail";
-
 
189
		}
175
		return "edit";
190
		return "edit";
176
	}
191
	}
177
 
192
 
178
	public String show() {
193
	public String show() {
179
		return "show";
194
		return "show";
Line 317... Line 332...
317
 
332
 
318
	public void setFileUploadFileName(String fileUploadFileName) {
333
	public void setFileUploadFileName(String fileUploadFileName) {
319
		this.fileUploadFileName = fileUploadFileName;
334
		this.fileUploadFileName = fileUploadFileName;
320
	}
335
	}
321
 
336
 
322
	@Override
-
 
323
	public void setServletRequest(HttpServletRequest request) {
337
	public void setServletRequest(HttpServletRequest req) {
324
		this.request = request;
338
		this.request = req;
325
 
-
 
-
 
339
		this.session = req.getSession();        
326
	}
340
	}
327
 
341
 
328
	public static void main(String[] args) throws NumberFormatException, InventoryServiceException, TException {
342
	public static void main(String[] args) throws NumberFormatException, InventoryServiceException, TException {
329
		AmazonListController call = new AmazonListController();
343
		AmazonListController call = new AmazonListController();
330
		System.out.println(call.getInventoryForAmazonItem("5"));
344
		System.out.println(call.getInventoryForAmazonItem("5"));