@Test public void saveInvalidSitePreference() throws Exception { request.addParameter("site_preference", "invalid"); assertNull(sitePreferenceHandler.handleSitePreference(request, response)); assertNull(sitePreferenceRepository.getSitePreference()); assertNull(SitePreferenceUtils.getCurrentSitePreference(request)); }
public SitePreference handleSitePreference(HttpServletRequest request, HttpServletResponse response) { SitePreference preference = getSitePreferenceQueryParameter(request); if (preference != null) { sitePreferenceRepository.saveSitePreference(preference, request, response); } else { preference = sitePreferenceRepository.loadSitePreference(request); } if (preference == null) { preference = getDefaultSitePreferenceForDevice(DeviceUtils.getCurrentDevice(request)); } if (preference != null) { request.setAttribute(CURRENT_SITE_PREFERENCE_ATTRIBUTE, preference); } return preference; }
StandardSitePreferenceHandler implements SitePreferenceHandler { public SitePreference handleSitePreference(HttpServletRequest request, HttpServletResponse response) { SitePreference preference = getSitePreferenceQueryParameter(request); if (preference != null) { sitePreferenceRepository.saveSitePreference(preference, request, response); } else { preference = sitePreferenceRepository.loadSitePreference(request); } if (preference == null) { preference = getDefaultSitePreferenceForDevice(DeviceUtils.getCurrentDevice(request)); } if (preference != null) { request.setAttribute(CURRENT_SITE_PREFERENCE_ATTRIBUTE, preference); } return preference; } }
StandardSitePreferenceHandler implements SitePreferenceHandler { public SitePreference handleSitePreference(HttpServletRequest request, HttpServletResponse response) { SitePreference preference = getSitePreferenceQueryParameter(request); if (preference != null) { sitePreferenceRepository.saveSitePreference(preference, request, response); } else { preference = sitePreferenceRepository.loadSitePreference(request); } if (preference == null) { preference = getDefaultSitePreferenceForDevice(DeviceUtils.getCurrentDevice(request)); } if (preference != null) { request.setAttribute(CURRENT_SITE_PREFERENCE_ATTRIBUTE, preference); } return preference; } StandardSitePreferenceHandler(SitePreferenceRepository sitePreferenceRepository); }
StandardSitePreferenceHandler implements SitePreferenceHandler { public SitePreference handleSitePreference(HttpServletRequest request, HttpServletResponse response) { SitePreference preference = getSitePreferenceQueryParameter(request); if (preference != null) { sitePreferenceRepository.saveSitePreference(preference, request, response); } else { preference = sitePreferenceRepository.loadSitePreference(request); } if (preference == null) { preference = getDefaultSitePreferenceForDevice(DeviceUtils.getCurrentDevice(request)); } if (preference != null) { request.setAttribute(CURRENT_SITE_PREFERENCE_ATTRIBUTE, preference); } return preference; } StandardSitePreferenceHandler(SitePreferenceRepository sitePreferenceRepository); SitePreference handleSitePreference(HttpServletRequest request, HttpServletResponse response); }
StandardSitePreferenceHandler implements SitePreferenceHandler { public SitePreference handleSitePreference(HttpServletRequest request, HttpServletResponse response) { SitePreference preference = getSitePreferenceQueryParameter(request); if (preference != null) { sitePreferenceRepository.saveSitePreference(preference, request, response); } else { preference = sitePreferenceRepository.loadSitePreference(request); } if (preference == null) { preference = getDefaultSitePreferenceForDevice(DeviceUtils.getCurrentDevice(request)); } if (preference != null) { request.setAttribute(CURRENT_SITE_PREFERENCE_ATTRIBUTE, preference); } return preference; } StandardSitePreferenceHandler(SitePreferenceRepository sitePreferenceRepository); SitePreference handleSitePreference(HttpServletRequest request, HttpServletResponse response);  }