Subversion Repositories SmartDukaan

Rev

Rev 22931 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
22473 ashik.ali 1
package com.spice.profitmandi.web.controller;
2
 
3
import javax.servlet.http.HttpServletRequest;
4
 
5
import org.slf4j.Logger;
6
import org.slf4j.LoggerFactory;
7
import org.springframework.beans.factory.annotation.Autowired;
8
import org.springframework.http.ResponseEntity;
9
import org.springframework.stereotype.Controller;
10
import org.springframework.transaction.annotation.Transactional;
11
import org.springframework.web.bind.annotation.RequestMapping;
12
import org.springframework.web.bind.annotation.RequestMethod;
13
 
14
import com.spice.profitmandi.common.ResponseCodeHolder;
15
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
16
import com.spice.profitmandi.common.model.ProfitMandiConstants;
17
import com.spice.profitmandi.common.web.util.ResponseSender;
18
import com.spice.profitmandi.dao.util.MigrationUtil;
19
 
20
import io.swagger.annotations.ApiImplicitParam;
21
import io.swagger.annotations.ApiImplicitParams;
22
 
23
@Controller
24
@Transactional(rollbackFor=Throwable.class)
25
public class MigrationController {
26
 
27
	@Autowired
28
	MigrationUtil migrationUtil;
29
 
30
	@Autowired
31
	ResponseSender<?> responseSender;
32
 
33
	private static final Logger LOGGER=LoggerFactory.getLogger(MigrationController.class);
34
 
35
	@RequestMapping(value = ProfitMandiConstants.URL_ADMIN_MIGRATE_USER_TO_RETAILER, method = RequestMethod.GET)
36
	@ApiImplicitParams({
37
		@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
38
	public ResponseEntity<?> migrateUserToRetailer(HttpServletRequest request) {
39
		LOGGER.info("requested url : " + request.getRequestURL().toString());
40
		migrationUtil.migrateUserToRetailer();
41
		return responseSender.ok(ResponseCodeHolder.getMessage("OK_1000"));
42
	}
43
 
44
	@RequestMapping(value = ProfitMandiConstants.URL_ADMIN_MIGRATE_MONGO_DOC_TO_RETAILER, method = RequestMethod.GET)
45
	@ApiImplicitParams({
46
		@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
47
	public ResponseEntity<?> migrateMongoDocToRetailer(HttpServletRequest request) {
48
		LOGGER.info("requested url : " + request.getRequestURL().toString());
49
		try{
50
			migrationUtil.migrateMongoDocToRetailer();
51
			return responseSender.ok(ResponseCodeHolder.getMessage("OK_1000"));
52
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
53
			LOGGER.error("Unable to migrate mongo doc to retailer", profitMandiBusinessException);
54
			return responseSender.badRequest(profitMandiBusinessException);
55
		}
56
	}
57
 
58
}