@PreAuthorize("hasRole('AUTH')") @RequestMapping( value = "/admin/configuration/saveConfiguration.html", method = RequestMethod.POST) public String saveConfigurations( @ModelAttribute("configuration") ConfigListWrapper configWrapper, BindingResult result, Model model, HttpServletRequest request, Locale locale) throws Exception { setConfigurationMenu(model, request); List<MerchantConfiguration> configs = configWrapper.getMerchantConfigs(); MerchantStore store = (MerchantStore) request.getAttribute(Constants.ADMIN_STORE); for (MerchantConfiguration mConfigs : configs) { mConfigs.setMerchantStore(store); if (!StringUtils.isBlank(mConfigs.getValue())) { mConfigs.setMerchantConfigurationType(MerchantConfigurationType.CONFIG); merchantConfigurationService.saveOrUpdate(mConfigs); } else { // remove if submited blank and exists MerchantConfiguration config = merchantConfigurationService.getMerchantConfiguration(mConfigs.getKey(), store); if (config != null) { merchantConfigurationService.delete(config); } } } model.addAttribute("success", "success"); model.addAttribute("configuration", configWrapper); return com.salesmanager.web.admin.controller.ControllerConstants.Tiles.Configuration.accounts; }
@PreAuthorize("hasRole('AUTH')") @RequestMapping(value = "/admin/configuration/accounts.html", method = RequestMethod.GET) public String displayAccountsConfguration( Model model, HttpServletRequest request, HttpServletResponse response) throws Exception { setConfigurationMenu(model, request); List<MerchantConfiguration> configs = new ArrayList<MerchantConfiguration>(); MerchantStore store = (MerchantStore) request.getAttribute(Constants.ADMIN_STORE); MerchantConfiguration merchantFBConfiguration = merchantConfigurationService.getMerchantConfiguration( Constants.KEY_FACEBOOK_PAGE_URL, store); if (null == merchantFBConfiguration) { merchantFBConfiguration = new MerchantConfiguration(); merchantFBConfiguration.setKey(Constants.KEY_FACEBOOK_PAGE_URL); merchantFBConfiguration.setMerchantConfigurationType(MerchantConfigurationType.CONFIG); } configs.add(merchantFBConfiguration); MerchantConfiguration merchantGoogleAnalyticsConfiguration = merchantConfigurationService.getMerchantConfiguration( Constants.KEY_GOOGLE_ANALYTICS_URL, store); if (null == merchantGoogleAnalyticsConfiguration) { merchantGoogleAnalyticsConfiguration = new MerchantConfiguration(); merchantGoogleAnalyticsConfiguration.setKey(Constants.KEY_GOOGLE_ANALYTICS_URL); merchantGoogleAnalyticsConfiguration.setMerchantConfigurationType( MerchantConfigurationType.CONFIG); } configs.add(merchantGoogleAnalyticsConfiguration); MerchantConfiguration merchantInstagramConfiguration = merchantConfigurationService.getMerchantConfiguration(Constants.KEY_INSTAGRAM_URL, store); if (null == merchantInstagramConfiguration) { merchantInstagramConfiguration = new MerchantConfiguration(); merchantInstagramConfiguration.setKey(Constants.KEY_INSTAGRAM_URL); merchantInstagramConfiguration.setMerchantConfigurationType(MerchantConfigurationType.CONFIG); } configs.add(merchantInstagramConfiguration); MerchantConfiguration merchantPinterestConfiguration = merchantConfigurationService.getMerchantConfiguration( Constants.KEY_PINTEREST_PAGE_URL, store); if (null == merchantPinterestConfiguration) { merchantPinterestConfiguration = new MerchantConfiguration(); merchantPinterestConfiguration.setKey(Constants.KEY_PINTEREST_PAGE_URL); merchantPinterestConfiguration.setMerchantConfigurationType(MerchantConfigurationType.CONFIG); } configs.add(merchantPinterestConfiguration); /** * MerchantConfiguration merchantGoogleApiConfiguration = * merchantConfigurationService.getMerchantConfiguration(Constants.KEY_GOOGLE_API_KEY,store); * if(null == merchantGoogleApiConfiguration) { merchantGoogleApiConfiguration = new * MerchantConfiguration(); merchantGoogleApiConfiguration.setKey(Constants.KEY_GOOGLE_API_KEY); * merchantGoogleApiConfiguration.setMerchantConfigurationType(MerchantConfigurationType.CONFIG); * } configs.add(merchantGoogleApiConfiguration); */ MerchantConfiguration twitterConfiguration = merchantConfigurationService.getMerchantConfiguration(Constants.KEY_TWITTER_HANDLE, store); if (null == twitterConfiguration) { twitterConfiguration = new MerchantConfiguration(); twitterConfiguration.setKey(Constants.KEY_TWITTER_HANDLE); twitterConfiguration.setMerchantConfigurationType(MerchantConfigurationType.CONFIG); } configs.add(twitterConfiguration); ConfigListWrapper configWrapper = new ConfigListWrapper(); configWrapper.setMerchantConfigs(configs); model.addAttribute("configuration", configWrapper); return com.salesmanager.web.admin.controller.ControllerConstants.Tiles.Configuration.accounts; }