Subversion Repositories SmartDukaan

Rev

Rev 34815 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
21561 ashik.ali 1
package com.spice.profitmandi.web.controller;
21555 kshitij.so 2
 
25008 amit.gupta 3
import com.google.gson.Gson;
4
import com.google.gson.reflect.TypeToken;
21561 ashik.ali 5
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
24016 amit.gupta 6
import com.spice.profitmandi.common.model.Location;
21561 ashik.ali 7
import com.spice.profitmandi.common.model.ProfitMandiConstants;
25011 amit.gupta 8
import com.spice.profitmandi.common.model.ProfitMandiResponse;
25008 amit.gupta 9
import com.spice.profitmandi.common.web.client.RestClient;
24383 amit.gupta 10
import com.spice.profitmandi.dao.entity.auth.AuthUser;
30299 amit.gupta 11
import com.spice.profitmandi.dao.entity.dtr.*;
24016 amit.gupta 12
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
25303 amit.gupta 13
import com.spice.profitmandi.dao.entity.user.Device;
22111 ashik.ali 14
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
15
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
24383 amit.gupta 16
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
25303 amit.gupta 17
import com.spice.profitmandi.dao.repository.catalog.DeviceRepository;
30299 amit.gupta 18
import com.spice.profitmandi.dao.repository.dtr.*;
24383 amit.gupta 19
import com.spice.profitmandi.service.AuthService;
24976 amit.gupta 20
import com.spice.profitmandi.service.authentication.RoleManager;
21
import com.spice.profitmandi.service.user.RetailerService;
34785 vikas.jang 22
import com.spice.profitmandi.service.user.UserService;
22139 amit.gupta 23
import com.spice.profitmandi.web.model.LoginDetails;
22069 ashik.ali 24
import com.spice.profitmandi.web.util.CookiesProcessor;
22111 ashik.ali 25
import com.spice.profitmandi.web.util.GoogleTokenUtil;
21574 ashik.ali 26
import com.spice.profitmandi.web.util.MVCResponseSender;
32570 amit.gupta 27
import org.apache.commons.lang.StringUtils;
30299 amit.gupta 28
import org.apache.http.NameValuePair;
29
import org.apache.http.client.utils.URLEncodedUtils;
30
import org.apache.http.message.BasicNameValuePair;
31
import org.apache.logging.log4j.LogManager;
32
import org.apache.logging.log4j.Logger;
33
import org.springframework.beans.factory.annotation.Autowired;
34
import org.springframework.beans.factory.annotation.Value;
35
import org.springframework.stereotype.Controller;
36
import org.springframework.ui.Model;
37
import org.springframework.ui.ModelMap;
38
import org.springframework.web.bind.annotation.*;
21561 ashik.ali 39
 
30299 amit.gupta 40
import javax.servlet.http.Cookie;
41
import javax.servlet.http.HttpServletRequest;
42
import javax.servlet.http.HttpServletResponse;
35458 amit 43
import org.springframework.transaction.annotation.Transactional;
30299 amit.gupta 44
import java.lang.reflect.Type;
45
import java.time.LocalDateTime;
46
import java.util.*;
47
import java.util.stream.Collectors;
48
 
21555 kshitij.so 49
@Controller
35458 amit 50
@Transactional(rollbackFor = Throwable.class)
21555 kshitij.so 51
public class LoginController {
52
 
32570 amit.gupta 53
    private static final Logger LOGGER = LogManager.getLogger(LoginController.class);
24016 amit.gupta 54
 
32570 amit.gupta 55
    @Autowired
56
    private GoogleTokenUtil googleTokenUtil;
24016 amit.gupta 57
 
32570 amit.gupta 58
    @Autowired
59
    private RoleManager roleManager;
26449 amit.gupta 60
 
32570 amit.gupta 61
    @Autowired
62
    private DeviceRepository deviceRepository;
24984 amit.gupta 63
 
32570 amit.gupta 64
    @Autowired
65
    private RetailerRepository retailerRepository;
24016 amit.gupta 66
 
32570 amit.gupta 67
    @Autowired
68
    private RetailerService retailerService;
24984 amit.gupta 69
 
32570 amit.gupta 70
    @Autowired
71
    private UserRepository userRepository;
24016 amit.gupta 72
 
32570 amit.gupta 73
    @Autowired
74
    private UserAccountRepository userAccountRepository;
24016 amit.gupta 75
 
32570 amit.gupta 76
    @Autowired
77
    private UserRoleRepository userRoleRepository;
24016 amit.gupta 78
 
32570 amit.gupta 79
    @Autowired
80
    private RoleRepository roleRepository;
24016 amit.gupta 81
 
32570 amit.gupta 82
    @Autowired
83
    private FofoStoreRepository fofoStoreRepository;
24016 amit.gupta 84
 
32570 amit.gupta 85
    @Autowired
86
    private MVCResponseSender mvcResponseSender;
25243 amit.gupta 87
 
32570 amit.gupta 88
    @Autowired
89
    private RestClient restClient;
24016 amit.gupta 90
 
32570 amit.gupta 91
    @Autowired
92
    private CookiesProcessor cookiesProcessor;
22079 amit.gupta 93
 
32570 amit.gupta 94
    @Value("${google.api.key}")
95
    private String googleApiKey;
24016 amit.gupta 96
 
32570 amit.gupta 97
    @Value("${app.token.url}")
98
    private String appTokenUrl;
24383 amit.gupta 99
 
32570 amit.gupta 100
    @Value("${angular.app.url}")
101
    private String appUrl;
24383 amit.gupta 102
 
32570 amit.gupta 103
    @Value("${admin.token}")
104
    private String adminToken;
24016 amit.gupta 105
 
32570 amit.gupta 106
    @Autowired
107
    private AuthService authService;
26449 amit.gupta 108
 
32570 amit.gupta 109
    @Autowired
34785 vikas.jang 110
    private UserService userService;
111
 
112
    @Autowired
32570 amit.gupta 113
    private AuthRepository authRepository;
24016 amit.gupta 114
 
32570 amit.gupta 115
    @RequestMapping(value = "/login", method = RequestMethod.GET)
116
    public String loginPage(HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
117
        LOGGER.info("Context Path is {}", request.getContextPath());
118
        try {
119
            LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
120
            LOGGER.info("Request session is already exist, should be redirect to as per roles assigned");
121
            String redirectUrl = null;
25243 amit.gupta 122
 
32570 amit.gupta 123
            Role roleRetailer = roleRepository.selectByName(RoleType.RETAILER.toString());
124
            Role roleFofo = roleRepository.selectByName(RoleType.FOFO.toString());
125
            Role roleFofoAdmin = roleRepository.selectByName(RoleType.FOFO_ADMIN.toString());
126
            if (fofoDetails.getRoleIds().contains(roleFofoAdmin.getId())) {
127
                redirectUrl = "/dashboard";
128
            } else if (fofoDetails.getRoleIds().contains(roleRetailer.getId())
129
                    && fofoDetails.getRoleIds().contains(roleFofo.getId())) {
130
                FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoDetails.getFofoId());
131
                if (!fofoStore.isActive()) {
132
                    cookiesProcessor.removeCookies(request, response);
133
                    throw new ProfitMandiBusinessException("", "", "");
134
                }
135
                redirectUrl = "/dashboard";
24016 amit.gupta 136
 
32570 amit.gupta 137
            } else {
138
                redirectUrl = "/login";
139
            }
140
            return "redirect:" + redirectUrl;
141
        } catch (ProfitMandiBusinessException profitMandiBusinessException) {
142
            model.addAttribute("googleApiKey", googleApiKey);
143
            model.addAttribute("appContextPath", request.getContextPath());
144
            return "login";
145
        }
146
    }
25303 amit.gupta 147
 
32570 amit.gupta 148
    @RequestMapping(value = "/", method = RequestMethod.GET)
149
    public String home() {
150
        return "redirect:/login";
151
    }
25243 amit.gupta 152
 
32570 amit.gupta 153
    @RequestMapping(value = "/mobileapp", method = RequestMethod.GET)
154
    public String mobileApp(HttpServletRequest request, Model model, @RequestParam(defaultValue = "") String emailId)
155
            throws Exception {
156
        LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
157
        if (roleManager.isAdmin(fofoDetails.getRoleIds())) {
32574 amit.gupta 158
            if (StringUtils.isEmpty(emailId)) {
32570 amit.gupta 159
                AuthUser authUser = authRepository.selectByEmailOrMobile(fofoDetails.getEmailId());
160
                model.addAttribute("authToken", getToken(authUser.getGmailId()));
161
            } else {
162
                model.addAttribute("authToken", getToken(emailId));
163
                model.addAttribute("androidId", getAndroidId(emailId));
164
            }
165
        } else {
166
            emailId = fofoDetails.getEmailId();
167
            model.addAttribute("authToken", getToken(emailId));
168
            model.addAttribute("androidId", getAndroidId(emailId));
169
        }
34300 ranu 170
        model.addAttribute("internal", true);
32570 amit.gupta 171
        model.addAttribute("appUrl", appUrl);
172
        return "mobileapp";
173
    }
25243 amit.gupta 174
 
32570 amit.gupta 175
    private String getAndroidId(String emailId) throws Exception {
176
        User user = userRepository.selectByEmailId(emailId);
177
        List<Device> devices = deviceRepository.selectByUserIdAndModifiedTimestamp(Arrays.asList(user.getId()),
178
                LocalDateTime.now().minusYears(2), LocalDateTime.now());
179
        if (devices.size() > 0) {
180
            Device device = devices.get(0);
181
            return device.getAndroidId();
182
        } else {
183
            return "";
184
        }
185
    }
24976 amit.gupta 186
 
32570 amit.gupta 187
    private String getToken(String emailId) throws Exception {
188
        List<NameValuePair> nameValuePairs = new ArrayList<>();
189
        nameValuePairs.add(new BasicNameValuePair("adminToken", this.adminToken));
190
        nameValuePairs.add(new BasicNameValuePair("emailId", emailId));
191
        String queryString = URLEncodedUtils.format(nameValuePairs, "UTF-8");
192
        String response = restClient.post(this.appTokenUrl + queryString,
193
                new HashMap<>(), new HashMap<>());
194
        Type t = new TypeToken<ProfitMandiResponse<Map<String, Object>>>() {
195
        }.getType();
196
        ProfitMandiResponse<Map<String, Object>> apiResponse = new Gson().fromJson(response, t);
197
        if (apiResponse.getStatusCode().equals("200")) {
198
            return (new StringBuilder((String) apiResponse.getResponse().get("token")).reverse().toString());
199
        } else {
200
            throw new Exception("Unauthorised access");
201
        }
24383 amit.gupta 202
 
32570 amit.gupta 203
    }
24383 amit.gupta 204
 
32570 amit.gupta 205
    @RequestMapping(value = "/login-as-partner", method = RequestMethod.GET)
206
    public String adminLogin(HttpServletRequest request, Model model, HttpServletResponse response,
207
                             @RequestParam int fofoId) throws Exception {
208
        LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
209
        if (roleManager.isAdmin(fofoDetails.getRoleIds())) {
210
            int userId = userAccountRepository.selectUserIdByRetailerId(fofoId);
211
            User user = userRepository.selectById(userId);
212
            Set<Integer> roleIds = userRoleRepository.selectByUserId(userId).stream().map(x -> x.getRoleId())
213
                    .collect(Collectors.toSet());
214
            LoginDetails newFofoDetails = new LoginDetails();
215
            newFofoDetails.setFofoId(fofoId);
216
            newFofoDetails.setRoleIds(roleIds);
217
            newFofoDetails.setEmailId(user.getEmailId());
218
            model.addAttribute("response1", true);
219
            this.addCookiesToResponse(newFofoDetails, request, response);
220
        } else {
221
            throw new ProfitMandiBusinessException("", "", "");
222
        }
223
        return "response";
224
    }
24016 amit.gupta 225
 
32570 amit.gupta 226
    @RequestMapping(value = "/login-as-partner-readonly", method = RequestMethod.GET)
227
    public String readonlyLogin(HttpServletRequest request, Model model, HttpServletResponse response,
228
                                @RequestParam int fofoId) throws Exception {
229
        LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
230
        if (roleManager.isAdmin(fofoDetails.getRoleIds())) {
231
            int userId = userAccountRepository.selectUserIdByRetailerId(fofoId);
232
            User user = userRepository.selectById(userId);
233
            Set<Integer> roleIds = userRoleRepository.selectByUserId(userId).stream().map(x -> x.getRoleId())
234
                    .collect(Collectors.toSet());
235
            LoginDetails newFofoDetails = new LoginDetails();
236
            newFofoDetails.setFofoId(fofoId);
237
            newFofoDetails.setRoleIds(roleIds);
238
            newFofoDetails.setEmailId(user.getEmailId());
239
            newFofoDetails.setReadOnly(true);
240
            model.addAttribute("response1", true);
241
            this.addCookiesToResponse(newFofoDetails, request, response);
242
        } else {
243
            throw new ProfitMandiBusinessException("", "", "");
244
        }
245
        return "response";
246
    }
24016 amit.gupta 247
 
32570 amit.gupta 248
    @RequestMapping(value = "/login", method = RequestMethod.POST)
249
    public String login(HttpServletRequest request, HttpServletResponse response,
250
                        @RequestParam(name = ProfitMandiConstants.TOKEN) String token,
251
                        @RequestParam(name = ProfitMandiConstants.EMAIL_ID_OR_MOBILE_NUMBER, defaultValue = "") String emailIdOrMobileNumber,
252
                        @RequestParam(name = "password", defaultValue = "") String password, Model model) throws Exception {
25275 amit.gupta 253
 
32570 amit.gupta 254
        LoginDetails fofoDetails = new LoginDetails();
255
        Set<Integer> roleIds = new HashSet<>();
256
        fofoDetails.setRoleIds(roleIds);
257
        String emailId = null;
258
        String name = null;
34785 vikas.jang 259
        User user = null;
32570 amit.gupta 260
        try {
261
            // if role is retailer then FOFO_ID is retailerId else it is userid as normal
262
            // user's wont have retailer id.
32571 amit.gupta 263
            if (StringUtils.isEmpty(token)) {
32570 amit.gupta 264
                if (authService.authenticate(emailIdOrMobileNumber, password)) {
265
                    AuthUser authUser = authRepository.selectByEmailOrMobile(emailIdOrMobileNumber);
266
                    if (authUser == null) {
34785 vikas.jang 267
                        throw new ProfitMandiBusinessException("Authentication", "Email or Mobile", "Invalid Email Or Mobile");
32570 amit.gupta 268
                    }
269
                    emailId = authUser.getEmailId();
270
                    name = authUser.getFirstName() + " " + authUser.getLastName();
271
                    authUser.setLastLoginTimestamp(LocalDateTime.now());
34785 vikas.jang 272
                } else {
273
                    // TODO: Add login with email and password
274
                    user = userService.authenticate(emailIdOrMobileNumber, password);
275
                    if (user != null) {
276
                        emailId = user.getEmailId();
277
                    } else {
278
                        LOGGER.error("User not found with given emailIdOrMobileNumber [{}]", emailIdOrMobileNumber);
279
                        model.addAttribute("response1", mvcResponseSender.createResponseString("RTLR_OK_1002", true,
280
                                request.getContextPath() + "/login", "Email"));
281
                        return "response";
282
                    }
32570 amit.gupta 283
                }
284
            } else {
285
                try {
286
                    emailId = googleTokenUtil.getEmailId(token);
287
                } catch (Exception e) {
288
                    // in case we cannot connect to google server.
289
                    emailId = emailIdOrMobileNumber;
290
                }
291
            }
292
            fofoDetails.setEmailId(emailId);
293
            fofoDetails.setFofoId(-1);
34785 vikas.jang 294
 
32570 amit.gupta 295
            if (user == null) {
296
                try {
34785 vikas.jang 297
                    user = userRepository.selectByEmailId(emailId);
32570 amit.gupta 298
                } catch (ProfitMandiBusinessException profitMandiBusinessException) {
34785 vikas.jang 299
                    LOGGER.error("User not found with given emailId [{}]", emailId);
300
                    try {
301
                        user = userRepository.selectBySecondryEmailId(emailId);
302
                    } catch (ProfitMandiBusinessException exception) {
303
                        LOGGER.error("User not found with given emailId", exception);
304
                        model.addAttribute("response1", mvcResponseSender.createResponseString("RTLR_OK_1002", true,
305
                                request.getContextPath() + "/login", "Email"));
306
                        return "response";
307
                    }
32570 amit.gupta 308
                }
309
            }
34785 vikas.jang 310
 
32570 amit.gupta 311
            if (user != null) {
312
                fofoDetails.setFofoId(user.getId());
313
                try {
314
                    List<UserRole> userRoles = userRoleRepository.selectByUserId(user.getId());
34785 vikas.jang 315
                    for (UserRole userRole : userRoles) {
316
                        roleIds.add(userRole.getRoleId());
32570 amit.gupta 317
                    }
318
                    List<Role> roles = roleRepository.selectByIds(roleIds);
319
                    for (Role role : roles) {
320
                        if (role.getName().equals(RoleType.RETAILER.toString())) {
34785 vikas.jang 321
                            UserAccount userAccounts = userAccountRepository.selectByUserIdType(user.getId(), AccountType.saholic);
32570 amit.gupta 322
                            Retailer retailer = retailerRepository.selectById(userAccounts.getAccountKey());
323
                            fofoDetails.setFofoId(retailer.getId());
324
                        }
325
                    }
326
                } catch (ProfitMandiBusinessException pmbe) {
327
                    LOGGER.error("Data Inconsistent", pmbe);
328
                }
329
            }
330
            String redirectUrl = null;
24976 amit.gupta 331
 
32570 amit.gupta 332
            Role roleFofo = roleRepository.selectByName(RoleType.FOFO.toString());
333
            Role roleFofoAdmin = roleRepository.selectByName(RoleType.FOFO_ADMIN.toString());
24016 amit.gupta 334
 
32570 amit.gupta 335
            if (fofoDetails.getRoleIds().contains(roleFofo.getId())) {
336
                redirectUrl = "/dashboard";
337
            } else {
338
                redirectUrl = "/login";
339
            }
24016 amit.gupta 340
 
32570 amit.gupta 341
            if (redirectUrl.equals("/dashboard")) {
342
                user.setLoginTimestamp(LocalDateTime.now());
343
                this.addCookiesToResponse(fofoDetails, request, response);
34785 vikas.jang 344
                LOGGER.info("Requested token email_id is valid, user login to system, shoud be redirect to {}", redirectUrl);
32570 amit.gupta 345
                model.addAttribute("response1", mvcResponseSender.createResponseString("RTLR_OK_1002", true,
346
                        request.getContextPath() + redirectUrl, name));
347
            } else {
348
                LOGGER.error("Requested token email_id is not valid, please try to login");
349
                /**
350
                 * TODO:Amit This redirect should be handle.
351
                 */
34785 vikas.jang 352
                throw new ProfitMandiBusinessException(ProfitMandiConstants.EMAIL_ID, fofoDetails.getEmailId(), "RTLR_1000");
32570 amit.gupta 353
            }
354
            return "response";
355
        } catch (ProfitMandiBusinessException profitMandiBusinessException) {
356
            LOGGER.error("Error : ", profitMandiBusinessException);
357
            model.addAttribute("response1",
358
                    mvcResponseSender.createResponseString(profitMandiBusinessException.getCode(), false, "/error"));
359
            return "response";
360
        } catch (Exception e) {
361
            e.printStackTrace();
362
            model.addAttribute("response1",
363
                    mvcResponseSender.createResponseString(
364
                            "You are not authorised! " + "Please contact the team if you feel this is incorrect", false,
365
                            "/error"));
366
            return "response";
367
        }
368
    }
24016 amit.gupta 369
 
32570 amit.gupta 370
    @PostMapping(value = "/forgetPassword")
34785 vikas.jang 371
    public String forgetPasswordPage(@RequestParam(name = ProfitMandiConstants.EMAIL_ID, defaultValue = "") String emailId, Model model) throws Exception {
372
        try {
373
            LOGGER.info("Forgetting password of: [{}]",emailId);
374
            authService.resetPassword(emailId);
375
        } catch (Exception exception){
376
            try {
377
                userService.resetPassword(emailId);
378
            } catch (Exception e){
34815 vikas 379
                LOGGER.info("Forgetting password of: [{}] - {}",emailId, e);
34785 vikas.jang 380
                throw new ProfitMandiBusinessException("Password Reset Email", emailId, "Could not send password reset mail. Password Could not be reset");
381
            }
382
        }
32570 amit.gupta 383
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
384
        LOGGER.info("completed");
385
        return "response";
386
    }
24984 amit.gupta 387
 
34785 vikas.jang 388
    private void addCookiesToResponse(LoginDetails fofoDetails, HttpServletRequest request, HttpServletResponse response) {
32570 amit.gupta 389
        List<String> roleIds = new ArrayList<>();
24016 amit.gupta 390
 
32570 amit.gupta 391
        for (int roleId : fofoDetails.getRoleIds()) {
392
            roleIds.add(String.valueOf(roleId));
393
        }
394
        Cookie cookieRoleIds = new Cookie(ProfitMandiConstants.ROLE_IDS, String.join("-", roleIds));
395
        cookieRoleIds.setDomain(request.getServerName());
396
        cookieRoleIds.setPath(request.getContextPath());
24016 amit.gupta 397
 
32570 amit.gupta 398
        Cookie cookieFofoId = new Cookie(ProfitMandiConstants.FOFO_ID, String.valueOf(fofoDetails.getFofoId()));
399
        cookieFofoId.setDomain(request.getServerName());
400
        cookieFofoId.setPath(request.getContextPath());
401
 
402
        Cookie cookieEmailId = new Cookie(ProfitMandiConstants.EMAIL_ID, fofoDetails.getEmailId());
403
        cookieEmailId.setDomain(request.getServerName());
404
        cookieEmailId.setPath(request.getContextPath());
405
 
406
        Cookie cookieReadOnly = new Cookie(ProfitMandiConstants.READONLY_KEY, fofoDetails.isReadOnly() + "");
407
        cookieReadOnly.setDomain(request.getServerName());
408
        cookieReadOnly.setPath(request.getContextPath());
409
 
410
        response.addCookie(cookieFofoId);
411
        response.addCookie(cookieEmailId);
412
        response.addCookie(cookieRoleIds);
413
        response.addCookie(cookieReadOnly);
414
    }
415
 
416
    @RequestMapping(value = "/logout", method = RequestMethod.GET)
417
    public String logout(HttpServletRequest request, @ModelAttribute("model") ModelMap model,
418
                         HttpServletResponse response) throws Exception {
419
        try {
420
            LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
421
            User user = null;
422
            try {
423
                user = userRepository.selectByEmailId(loginDetails.getEmailId());
424
            } catch (ProfitMandiBusinessException profitMandiBusinessException) {
425
                LOGGER.error("User not found with given emailId", profitMandiBusinessException);
426
            }
427
            if (user == null) {
428
                user = userRepository.selectBySecondryEmailId(loginDetails.getEmailId());
429
            }
430
            user.setLogoutTimestamp(LocalDateTime.now());
431
            cookiesProcessor.removeCookies(request, response);
432
            LOGGER.info("Logout is successfull, should be redirect to /login");
433
            return "redirect:/login";
434
        } catch (ProfitMandiBusinessException profitMandiBusinessException) {
435
            LOGGER.info("Error occured while removing requested cookies, should be redirect to /login");
436
            return "redirect:/login";
437
        }
438
    }
439
 
440
    @RequestMapping(value = "/partner/location", method = RequestMethod.PUT)
441
    public String setLocation(HttpServletRequest request, Model model, @RequestBody Location location)
442
            throws Exception {
443
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
444
        boolean response = true;
445
        try {
446
            FofoStore fs = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
447
            if (fs.getLatitude() == null) {
448
                fs.setLatitude(location.getLatitude());
449
                fs.setLongitude(location.getLongitude());
450
            }
451
            model.addAttribute("response1", response);
452
        } catch (Exception e) {
453
            LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
454
        }
455
        return "response";
456
    }
21555 kshitij.so 457
}