Subversion Repositories SmartDukaan

Rev

Rev 8362 | Rev 8620 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7283 kshitij.so 1
package in.shop2020.support.controllers;
2
 
8362 kshitij.so 3
import java.io.BufferedInputStream;
7524 kshitij.so 4
import java.io.File;
7741 kshitij.so 5
import java.io.FileInputStream;
8362 kshitij.so 6
import java.io.FileWriter;
7524 kshitij.so 7
import java.io.IOException;
8362 kshitij.so 8
import java.io.InputStream;
7365 kshitij.so 9
import java.util.HashMap;
7283 kshitij.so 10
import java.util.List;
11
import java.util.Map;
12
 
7591 kshitij.so 13
import javax.servlet.ServletContext;
8362 kshitij.so 14
import javax.servlet.ServletOutputStream;
7283 kshitij.so 15
import javax.servlet.ServletRequest;
16
import javax.servlet.http.HttpServletRequest;
8168 kshitij.so 17
import javax.servlet.http.HttpServletResponse;
7591 kshitij.so 18
import javax.servlet.http.HttpSession;
7283 kshitij.so 19
 
20
import in.shop2020.model.v1.catalog.Amazonlisted;
21
import in.shop2020.model.v1.catalog.CatalogServiceException;
22
import in.shop2020.model.v1.catalog.Item;
23
import in.shop2020.model.v1.inventory.AmazonInventorySnapshot;
24
import in.shop2020.model.v1.catalog.CatalogService.Client;
25
import in.shop2020.model.v1.inventory.InventoryServiceException;
7741 kshitij.so 26
import in.shop2020.model.v1.order.AmazonOrder;
7591 kshitij.so 27
import in.shop2020.support.utils.ReportsUtils;
7283 kshitij.so 28
import in.shop2020.thrift.clients.CatalogClient;
29
import in.shop2020.thrift.clients.InventoryClient;
7365 kshitij.so 30
import in.shop2020.thrift.clients.LogisticsClient;
7741 kshitij.so 31
import in.shop2020.thrift.clients.TransactionClient;
7365 kshitij.so 32
import in.shop2020.logistics.DeliveryType;
33
import in.shop2020.logistics.LogisticsInfo;
34
import in.shop2020.logistics.LogisticsServiceException;
35
import in.shop2020.logistics.PickUpType;
7283 kshitij.so 36
 
7524 kshitij.so 37
import org.apache.commons.io.FileUtils;
7365 kshitij.so 38
import org.apache.commons.lang.xwork.StringUtils;
7741 kshitij.so 39
import org.apache.poi.hssf.usermodel.HSSFSheet;
40
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
8168 kshitij.so 41
import org.apache.poi.ss.usermodel.Cell;
7591 kshitij.so 42
import org.apache.struts2.convention.annotation.InterceptorRef;
43
import org.apache.struts2.convention.annotation.InterceptorRefs;
7283 kshitij.so 44
import org.apache.struts2.convention.annotation.Result;
45
import org.apache.struts2.convention.annotation.Results;
46
import org.apache.struts2.interceptor.ServletRequestAware;
8168 kshitij.so 47
import org.apache.struts2.interceptor.ServletResponseAware;
48
import org.apache.struts2.util.ServletContextAware;
7283 kshitij.so 49
import org.apache.thrift.TException;
7741 kshitij.so 50
import org.apache.thrift.transport.TTransportException;
7283 kshitij.so 51
import org.slf4j.Logger;
52
import org.slf4j.LoggerFactory;
53
 
54
import com.opensymphony.xwork2.ValidationAwareSupport;
55
 
56
@SuppressWarnings("serial")
7591 kshitij.so 57
@InterceptorRefs({
58
	@InterceptorRef("defaultStack"),
59
	@InterceptorRef("login")
60
})
7283 kshitij.so 61
@Results({
7524 kshitij.so 62
	@Result(name = "redirect", location = "${url}", type = "redirect"),
63
	@Result(name="authsuccess", type="redirectAction", params = {"actionName" , "reports"})
64
})
8168 kshitij.so 65
public class AmazonListController extends ValidationAwareSupport implements ServletRequestAware ,ServletResponseAware, ServletContextAware{
7283 kshitij.so 66
 
67
	private static Logger logger = LoggerFactory.getLogger(AmazonListController.class);
68
 
7591 kshitij.so 69
	private HttpServletRequest request;
70
	private HttpSession session;
71
	private ServletContext context;
8362 kshitij.so 72
	private HttpServletResponse response;
7283 kshitij.so 73
	private String url;
74
	private String id;
75
	private String itemId;
76
	private String isFba;
77
	private String isNonFba;
78
	private String isInventoryOverride;
79
	private String fbaPrice;
80
	private String sellingPrice;
81
	private String saholicPrice;
7365 kshitij.so 82
	private String isTime;
83
	private String handlingTime;
84
	private String customHandlingTime;
7461 kshitij.so 85
	private String holdInventory;
86
	private String defaultInventory;
7524 kshitij.so 87
	private String fileUploadFileName;
88
	private String fileUploadContentType;
8168 kshitij.so 89
	private String suppressMfnPriceUpdate;
90
	private String suppressFbaPriceUpdate;
7524 kshitij.so 91
	private File file;
8362 kshitij.so 92
	private String errMsg;
7283 kshitij.so 93
 
94
	public String index() {
7591 kshitij.so 95
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getServletPath())) {
96
			return "authfail";
97
		}
7283 kshitij.so 98
		return "index";
99
	}
100
 
101
	public List<Amazonlisted> fetchItems() throws TException {
7408 kshitij.so 102
		Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
7283 kshitij.so 103
		return CatalogClient.getAllAmazonListedItems();
104
	}
105
 
7408 kshitij.so 106
	public Amazonlisted fetchItemDetail() throws NumberFormatException, TException {
107
		Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
7283 kshitij.so 108
		return CatalogClient.getAmazonItemDetails(Long.valueOf(id));
109
	}
110
 
7408 kshitij.so 111
	public Item getSaholicItem(String id) throws NumberFormatException, CatalogServiceException, TException {
112
		Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
7283 kshitij.so 113
		return CatalogClient.getItem(Long.valueOf(id));
114
	}
7365 kshitij.so 115
 
116
 
117
 
7283 kshitij.so 118
	public String update() throws NumberFormatException, TException{
7408 kshitij.so 119
		Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
8168 kshitij.so 120
		boolean flag=false;
121
		boolean commit=false;
122
		long delay = Long.valueOf(customHandlingTime);
123
		if ( Boolean.valueOf(isTime)) {
124
			flag = true;
125
		}
126
		changeItemInventory();
127
		Amazonlisted amazonlisted = CatalogClient.getAmazonItemDetails(Long.valueOf(itemId));
128
		if (amazonlisted.getSellingPrice()!=Double.valueOf(sellingPrice)){
129
			amazonlisted.setSellingPrice(Double.valueOf(sellingPrice));
130
			commit=true;
131
		}
132
		if (amazonlisted.getFbaPrice()!=Double.valueOf(fbaPrice)){
133
			amazonlisted.setFbaPrice(Double.valueOf(fbaPrice));
134
			commit=true;
135
		}
136
		if (amazonlisted.isIsFba()!=Boolean.valueOf(isFba)){
137
			amazonlisted.setIsFba(Boolean.valueOf(isFba));
138
			commit=true;
139
		}
140
		if (amazonlisted.isIsNonFba()!=Boolean.valueOf(isNonFba)){
141
			amazonlisted.setIsNonFba(Boolean.valueOf(isNonFba));
142
			commit=true;
143
		}
144
		if (amazonlisted.isIsCustomTime()!=flag){
145
			amazonlisted.setIsCustomTime(flag);
146
			commit=true;
147
		}
148
		if (amazonlisted.getHandlingTime()!=delay){
149
			amazonlisted.setHandlingTime(delay);
150
			commit=true;
151
		}
152
		if(amazonlisted.isIsInventoryOverride()!=Boolean.valueOf(isInventoryOverride)){
153
			amazonlisted.setIsInventoryOverride(Boolean.valueOf(isInventoryOverride));
154
			commit=true;
155
		}
156
		if(amazonlisted.isSuppressMfnPriceUpdate()!=Boolean.valueOf(suppressMfnPriceUpdate)){
157
			amazonlisted.setSuppressMfnPriceUpdate(Boolean.valueOf(suppressMfnPriceUpdate));
158
			commit=true;
159
		}
160
		if(amazonlisted.isSuppressFbaPriceUpdate()!=Boolean.valueOf(suppressFbaPriceUpdate)){
161
			amazonlisted.setSuppressFbaPriceUpdate(Boolean.valueOf(suppressFbaPriceUpdate));
162
			commit=true;
163
		}
164
		if(commit){
165
			CatalogClient.updateAmazonItemDetails(amazonlisted);
166
		}
167
		else{
168
			logger.info("Nothing new to commit");
169
		}
7591 kshitij.so 170
		//setUrl("/amazon-list/");
171
		return "index";
7283 kshitij.so 172
 
173
	}
174
 
8168 kshitij.so 175
	public void upload() throws IOException, TException {
7524 kshitij.so 176
		File fileToCreate = new File("/tmp/", "Amazon-shipping.xls");
177
		FileUtils.copyFile(this.file, fileToCreate);
7741 kshitij.so 178
		FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
179
		HSSFWorkbook workbook = new HSSFWorkbook(iFile);
180
		HSSFSheet sheet = workbook.getSheetAt(0);
7762 kshitij.so 181
		Map<Long,Map<String,String>> amazonOrderMap = new HashMap<Long,Map<String,String>>();
7741 kshitij.so 182
		for (int iterator=sheet.getFirstRowNum();iterator<=sheet.getLastRowNum();iterator++){
183
			TransactionClient tcl = new TransactionClient();
184
			List<AmazonOrder> orders = tcl.getClient().getAmazonOrderByAmazonOrderId(sheet.getRow(iterator).getCell(0).getStringCellValue());
185
			for (AmazonOrder order : orders){
7753 kshitij.so 186
				if (StringUtils.equals(order.getStatus(), "Order-Payment-Success")){
7762 kshitij.so 187
					Map<String,String> dateMap = new HashMap<String,String>();
188
					dateMap.put(sheet.getRow(iterator).getCell(1).getStringCellValue(), sheet.getRow(iterator).getCell(2).getStringCellValue());
189
					amazonOrderMap.put(order.getOrderId(), dateMap);
7741 kshitij.so 190
				}
191
			}
192
		}
193
		TransactionClient tcl = new TransactionClient();
194
		tcl.getClient().updateTimestampForAmazonOrder(amazonOrderMap);
7524 kshitij.so 195
	}
196
 
7461 kshitij.so 197
	private void changeItemInventory() throws NumberFormatException, TException {
198
		Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
7524 kshitij.so 199
 
7461 kshitij.so 200
		if (StringUtils.isEmpty(holdInventory)) {
201
			holdInventory = "0";
202
		}
203
		if (StringUtils.isEmpty(defaultInventory)) {
204
			defaultInventory = "0";
205
		}
206
		CatalogClient.updateItemInventory(Long.valueOf(itemId),Long.valueOf(holdInventory),Long.valueOf(defaultInventory));
207
	}
208
 
209
 
7283 kshitij.so 210
	public Map<Long, Long> getAvailableItemInventory(String itemId) throws NumberFormatException, InventoryServiceException, TException{
211
		InventoryClient inventoryServiceClient = new InventoryClient();
212
		in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
213
		in.shop2020.model.v1.inventory.ItemInventory thriftItemInventory = inventoryClient.getItemInventoryByItemId(Long.valueOf(itemId));
214
		return thriftItemInventory.getAvailability();
215
 
216
	}
217
 
218
	public Map<Long, Long> getReservedItemInventory(String itemId) throws NumberFormatException, InventoryServiceException, TException{
219
		InventoryClient inventoryServiceClient = new InventoryClient();
220
		in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
221
		in.shop2020.model.v1.inventory.ItemInventory thriftItemInventory = inventoryClient.getItemInventoryByItemId(Long.valueOf(itemId));
222
		return thriftItemInventory.getReserved();
223
 
224
	}
225
 
226
	public String getWarehouseName(String warehouseId) throws NumberFormatException, TException { 
227
		InventoryClient inventoryServiceClient = new InventoryClient();
228
		return inventoryServiceClient.getClient().getWarehouseName(Long.valueOf(warehouseId));
229
	}
230
 
231
	public AmazonInventorySnapshot getInventoryForAmazonItem(String itemId) throws NumberFormatException, TException {
232
		InventoryClient inventoryServiceClient = new InventoryClient();
7365 kshitij.so 233
		try { 
234
			return inventoryServiceClient.getClient().getAmazonInventoryForItem(Long.valueOf(itemId));
235
		}
236
		catch (Exception e){
237
			return null;
238
		}
7283 kshitij.so 239
	}
240
 
7365 kshitij.so 241
	public Long getTimetoShip(String itemId) throws LogisticsServiceException, TException{
242
		LogisticsClient logisticsClient = new LogisticsClient();
243
		return logisticsClient.getClient().getLogisticsInfo("110001", Long.valueOf(itemId), DeliveryType.COD, PickUpType.COURIER).getShippingTime();
244
 
245
	}
246
 
7762 kshitij.so 247
	public  Map<Long, Item> getAliveItemMap() throws TTransportException, InterruptedException{
7753 kshitij.so 248
		List<Item> itemList = null;
249
		int retry=0;
250
		while(true){
7762 kshitij.so 251
			try {
252
				if (retry==3)
253
					break;
254
				Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
255
				itemList = CatalogClient.getAllAliveItems();
7753 kshitij.so 256
				break;
7762 kshitij.so 257
			} catch ( NullPointerException e) {
258
				retry++;
259
				System.out.println("Unable to fetch alive items.Retrying");
260
				Thread.sleep(3000);
261
				e.printStackTrace();
262
			} catch (TException e) {
263
				retry++;
264
				System.out.println("Unable to fetch alive items.Retrying");
265
				Thread.sleep(3000);
266
				e.printStackTrace();
267
			}
7753 kshitij.so 268
		}
7603 kshitij.so 269
		Map<Long, Item> itemMap = new HashMap<Long, Item>();
7365 kshitij.so 270
		for (Item o : itemList) {
7603 kshitij.so 271
			itemMap.put((Long) o.getId(), o);
7365 kshitij.so 272
		}
273
		return itemMap;
274
	}
275
 
8168 kshitij.so 276
	public String runAsinJob() throws IOException, InterruptedException {
277
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
278
			logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
279
			return "authfail";
280
		}
281
		ProcessBuilder testProcess = new ProcessBuilder("/bin/bash");
8396 kshitij.so 282
		String[] command = {"/bin/bash", "-c", "sudo /root/code/trunk/AmazonFeeds/RunAsinJob.sh"};
8168 kshitij.so 283
		testProcess.command(command);
284
		logger.info(testProcess.command().toString());
285
		Process process = testProcess.start();
286
		process.waitFor();
287
		logger.info(String.valueOf(process.exitValue()));
288
		return "asinjob";
8070 kshitij.so 289
 
8168 kshitij.so 290
	}
8396 kshitij.so 291
 
292
	public String runFbaListingJob() throws IOException, InterruptedException {
293
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
294
			logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
295
			return "authfail";
296
		}
297
		ProcessBuilder testProcess = new ProcessBuilder("/bin/bash");
298
		String[] command = {"/bin/bash", "-c", "sudo /root/code/trunk/AmazonFeeds/RunFbaListingJob.sh"};
299
		testProcess.command(command);
300
		logger.info(testProcess.command().toString());
301
		Process process = testProcess.start();
302
		process.waitFor();
303
		logger.info(String.valueOf(process.exitValue()));
304
		return "asinjob";
305
	}
306
 
307
	public String runNonFbaListingJob() throws IOException, InterruptedException {
308
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
309
			logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
310
			return "authfail";
311
		}
312
		ProcessBuilder testProcess = new ProcessBuilder("/bin/bash");
313
		String[] command = {"/bin/bash", "-c", "sudo /root/code/trunk/AmazonFeeds/RunNonFbaListingJob.sh"};
314
		testProcess.command(command);
315
		logger.info(testProcess.command().toString());
316
		Process process = testProcess.start();
317
		process.waitFor();
318
		logger.info(String.valueOf(process.exitValue()));
319
		return "asinjob";
320
	}
8073 kshitij.so 321
 
8168 kshitij.so 322
	public void uploadBulkFile() throws IOException, TException{
323
		File fileToCreate = new File("/tmp/", "Amazon-bulk-upload.xls");
324
		FileUtils.copyFile(this.file, fileToCreate);
325
		FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
326
		HSSFWorkbook workbook = new HSSFWorkbook(iFile);
327
		HSSFSheet sheet = workbook.getSheetAt(0);
328
		Map<Long,Amazonlisted> amazonBulkUpdate = new HashMap<Long,Amazonlisted>();
329
		Client CatalogClient=null;
8362 kshitij.so 330
		StringBuilder sb = new StringBuilder();
8168 kshitij.so 331
		try {
332
			CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
333
		} catch (TTransportException e) {
334
			// TODO Auto-generated catch block
335
			e.printStackTrace();
336
		}
337
		for (int iterator=(sheet.getFirstRowNum()+1);iterator<=sheet.getLastRowNum();iterator++){
338
			Amazonlisted amazonlisted =null;
339
			Long sku;
340
			if (checkEmptyString(sheet.getRow(iterator).getCell(0))){
341
				continue;
342
			}
343
			else {
344
				sku=(long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
8362 kshitij.so 345
				try {
346
					amazonlisted = CatalogClient.getAmazonItemDetails(sku);
347
				} catch (TException e) {
348
					logger.info("Unable to fetch item details ID= "+sku);
349
					sb.append("Service exception ItemId not updated Id= "+sku+"\n");
350
					continue;
351
				}
8168 kshitij.so 352
			}
8362 kshitij.so 353
 
354
			if(amazonlisted.getItemid() == 0){
355
				logger.info("Item Id doesn't exist in amazonlisted Id= "+sku);
356
				sb.append("Item Id doesn't exist in amazonlisted Id= "+sku+"\n");
357
				continue;
358
			}
8168 kshitij.so 359
 
360
			if (!checkEmptyString(sheet.getRow(iterator).getCell(1))){
361
				double mfnPrice = sheet.getRow(iterator).getCell(1).getNumericCellValue();
362
				amazonlisted.setSellingPrice(mfnPrice);
363
			}
364
 
365
			if (!checkEmptyString(sheet.getRow(iterator).getCell(2))){
366
				double fbaSellingPrice = sheet.getRow(iterator).getCell(2).getNumericCellValue();
367
				amazonlisted.setFbaPrice(fbaSellingPrice);
368
			}
369
 
370
			if (!checkEmptyString(sheet.getRow(iterator).getCell(3))){
371
				if ((long)sheet.getRow(iterator).getCell(3).getNumericCellValue()==1){
372
					amazonlisted.setIsNonFba(true);
373
				}
374
				if ((long)sheet.getRow(iterator).getCell(3).getNumericCellValue()==0){
375
					amazonlisted.setIsNonFba(false);
376
				}
377
			}
378
 
379
			if (!checkEmptyString(sheet.getRow(iterator).getCell(4))){
380
				if ((long)sheet.getRow(iterator).getCell(4).getNumericCellValue()==1){
381
					amazonlisted.setIsFba(true);
382
				}
383
				if ((long)sheet.getRow(iterator).getCell(4).getNumericCellValue()==0){
384
					amazonlisted.setIsFba(false);
385
				}
386
			}
387
			if (!checkEmptyString(sheet.getRow(iterator).getCell(5))){
388
				if ((long)sheet.getRow(iterator).getCell(5).getNumericCellValue()==1){
389
					amazonlisted.setIsInventoryOverride(true);
390
				}
391
				if ((long)sheet.getRow(iterator).getCell(5).getNumericCellValue()==0){
392
					amazonlisted.setIsInventoryOverride(false);
393
				}
394
			}
395
			if (!checkEmptyString(sheet.getRow(iterator).getCell(6))){
396
				if ((long)sheet.getRow(iterator).getCell(6).getNumericCellValue()==1){
397
					amazonlisted.setSuppressMfnPriceUpdate(true);
398
				}
399
				if ((long)sheet.getRow(iterator).getCell(6).getNumericCellValue()==0){
400
					amazonlisted.setSuppressMfnPriceUpdate(false);
401
				}
402
			}
403
 
404
			if (!checkEmptyString(sheet.getRow(iterator).getCell(7))){
405
				if ((long)sheet.getRow(iterator).getCell(7).getNumericCellValue()==1){
406
					amazonlisted.setSuppressFbaPriceUpdate(true);
407
				}
408
				if ((long)sheet.getRow(iterator).getCell(7).getNumericCellValue()==0){
409
					amazonlisted.setSuppressFbaPriceUpdate(false);
410
				}
411
			}
412
			amazonBulkUpdate.put(sku, amazonlisted);
413
		}
414
		logger.info("Amazon Bulk Map "+amazonBulkUpdate.toString());
415
		CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
416
		CatalogClient.updateAmazonAttributesInBulk(amazonBulkUpdate);
8362 kshitij.so 417
		File file = new File("/tmp/temp");
418
		FileWriter writer = new FileWriter(file);
419
		writer.append(sb.toString());
420
		writer.close();
421
		byte[] buffer = new byte[(int)file.length()];
422
		InputStream input = null;
423
		try {
424
			int totalBytesRead = 0;
425
			input = new BufferedInputStream(new FileInputStream(file));
426
			while(totalBytesRead < buffer.length){
427
				int bytesRemaining = buffer.length - totalBytesRead;
428
				int bytesRead = input.read(buffer, totalBytesRead, bytesRemaining); 
429
				if (bytesRead > 0){
430
					totalBytesRead = totalBytesRead + bytesRead;
431
				}
432
			}
433
		}
434
		finally {
435
			input.close();
436
			file.delete();
437
		}
438
 
439
		response.setHeader("Content-Type", "text/javascript");
440
 
441
		ServletOutputStream sos;
442
		try {
443
			sos = response.getOutputStream();
444
			sos.write(buffer);
445
			sos.flush();
446
		} catch (IOException e) {
447
			System.out.println("Unable to stream the manifest file");
448
		}   
8168 kshitij.so 449
	}
450
 
451
 
452
	public boolean checkEmptyString(Cell cell){
453
		if (cell==null){
454
			return true;
455
		}
456
		return false;
457
	}
458
 
459
	public String uploadSheet(){
460
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
461
			logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
462
			return "authfail";
463
		}
464
		return "amazon-shipping-upload";
465
	}
466
 
467
	public String uploadBulkSheet(){
468
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
469
			logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
470
			return "authfail";
471
		}
472
		return "amazon-bulk-upload";
473
	}
474
 
475
 
7283 kshitij.so 476
	public String edit() {
7591 kshitij.so 477
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1])) {
478
			return "authfail";
479
		}
7283 kshitij.so 480
		return "edit";
481
	}
482
 
483
	public String show() {
8168 kshitij.so 484
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1])) {
485
			logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1]);
486
			return "authfail";
487
		}
488
 
489
		if (StringUtils.equals(id, "options")){
490
			return "options";
491
		}
492
		return "id";
7283 kshitij.so 493
	}
494
 
495
	public String editNew() {
496
		return "editNew";
8168 kshitij.so 497
	}	
7283 kshitij.so 498
 
499
	public void setId(String id) {
8168 kshitij.so 500
		logger.info(id);
7283 kshitij.so 501
		this.id = id;
502
	}
503
 
504
	public void setUrl(String url) {
505
		this.url = url;
506
	}
507
 
508
	public String getUrl() {
509
		return url;
510
	}
511
 
512
	public String getId() {
513
		return id;
514
	}
515
 
516
	public void setItemId(String itemId) {
517
		this.itemId = itemId;
518
	}
519
 
520
	public String getItemId() {
521
		return itemId;
522
	}
523
 
524
	public void setIsFba(String isFba) {
525
		this.isFba = isFba;
526
	}
527
 
528
	public String getIsFba() {
529
		return isFba;
530
	}
531
 
532
	public void setIsNonFba(String isNonFba) {
533
		this.isNonFba = isNonFba;
534
	}
535
 
536
	public String getIsNonFba() {
537
		return isNonFba;
538
	}
539
 
540
	public void setIsInventoryOverride(String isInventoryOverride) {
541
		this.isInventoryOverride = isInventoryOverride;
542
	}
543
 
544
	public String getIsInventoryOverride() {
545
		return isInventoryOverride;
546
	}
547
 
548
	public void setSellingPrice(String sellingPrice) {
549
		this.sellingPrice = sellingPrice;
550
	}
551
 
552
	public String getSellingPrice() {
553
		return sellingPrice;
554
	}
555
 
556
	public void setFbaPrice(String fbaPrice) {
557
		this.fbaPrice = fbaPrice;
558
	}
559
 
560
	public String getFbaPrice() {
561
		return fbaPrice;
562
	}
7365 kshitij.so 563
 
7283 kshitij.so 564
	public void setSaholicPrice(String saholicPrice) {
565
		this.saholicPrice = saholicPrice;
566
	}
567
 
568
	public String getSaholicPrice() {
569
		return saholicPrice;
570
	}
571
 
7365 kshitij.so 572
	public void setIsTime(String isTime){
573
		this.isTime = isTime;
574
	}
575
 
7461 kshitij.so 576
	public String getIsTime(){
7365 kshitij.so 577
		return isTime;
578
	}
579
 
580
	public void setHandlingTime(String handlingTime){
581
		this.handlingTime = handlingTime;
582
	}
583
 
7461 kshitij.so 584
	public String getHandlingTime(){
7365 kshitij.so 585
		return handlingTime;
586
	}
8168 kshitij.so 587
 
7365 kshitij.so 588
	public void setCustomHandlingTime(String customHandlingTime){
589
		this.customHandlingTime = customHandlingTime;
590
	}
591
 
7461 kshitij.so 592
	public String getCustomHandlingTime(){
7365 kshitij.so 593
		return customHandlingTime;
594
	}
7524 kshitij.so 595
 
7461 kshitij.so 596
	public void setHoldInventory(String holdInventory){
597
		this.holdInventory = holdInventory;
598
	}
7365 kshitij.so 599
 
7461 kshitij.so 600
	public String getHoldInventory(){
601
		return holdInventory;
602
	}
7524 kshitij.so 603
 
7461 kshitij.so 604
	public void setDefaultInventory(String defaultInventory){
605
		this.defaultInventory = defaultInventory;
606
	}
607
 
608
	public String getDefaultInventory(){
609
		return defaultInventory;
610
	}
611
 
7524 kshitij.so 612
	public File getFile() {
613
		return file;
614
	}
615
 
616
	public void setFile(File file) {
617
		this.file = file;
618
	}
619
 
620
	public String getFileUploadContentType() {
621
		return fileUploadContentType;
622
	}
623
 
624
	public void setFileUploadContentType(String fileUploadContentType) {
625
		this.fileUploadContentType = fileUploadContentType;
626
	}
627
 
628
	public String getFileUploadFileName() {
629
		return fileUploadFileName;
630
	}
631
 
632
	public void setFileUploadFileName(String fileUploadFileName) {
633
		this.fileUploadFileName = fileUploadFileName;
634
	}
635
 
7591 kshitij.so 636
	public void setServletRequest(HttpServletRequest req) {
637
		this.request = req;
638
		this.session = req.getSession();        
7283 kshitij.so 639
	}
640
 
8070 kshitij.so 641
	public static void main(String[] args) throws NumberFormatException, InventoryServiceException, TException, IOException {
7283 kshitij.so 642
		AmazonListController call = new AmazonListController();
8070 kshitij.so 643
		//System.out.println(call.runAsinJob());
7283 kshitij.so 644
	}
8168 kshitij.so 645
 
646
	@Override
647
	public void setServletContext(ServletContext arg0) {
648
		// TODO Auto-generated method stub
649
 
650
	}
651
 
652
 
653
	public void setSuppressMfnPriceUpdate(String suppressMfnPriceUpdate) {
654
		this.suppressMfnPriceUpdate = suppressMfnPriceUpdate;
655
	}
656
 
657
	public String getSuppressMfnPriceUpdate() {
658
		return suppressMfnPriceUpdate;
659
	}
660
 
661
	public void setSuppressFbaPriceUpdate(String suppressFbaPriceUpdate) {
662
		this.suppressFbaPriceUpdate = suppressFbaPriceUpdate;
663
	}
664
 
665
	public String getSuppressFbaPriceUpdate() {
666
		return suppressFbaPriceUpdate;
667
	}
8362 kshitij.so 668
 
669
	public void setErrMsg(String errMsg) {
670
		this.errMsg = errMsg;
671
	}
672
 
673
	public String getErrMsg() {
674
		return errMsg;
675
	}
676
 
677
	public void setServletResponse(HttpServletResponse response) {
678
		this.response = response;
679
	}
680
 
7283 kshitij.so 681
}