List of usage examples for org.springframework.util CollectionUtils contains
public static boolean contains(@Nullable Enumeration<?> enumeration, Object element)
From source file:com.acc.storefront.interceptors.beforeview.SeoRobotsFollowBeforeViewHandler.java
@Override public void beforeView(final HttpServletRequest request, final HttpServletResponse response, final ModelAndView modelAndView) { // Check to see if the controller has specified a Index/Follow directive for robots if (modelAndView != null && !modelAndView.getModel().containsKey("metaRobots")) { // Build a default directive String robotsValue = "no-index,no-follow"; if (RequestMethod.GET.name().equalsIgnoreCase(request.getMethod())) { if (request.isSecure()) { robotsValue = "no-index,follow"; }/* www . jav a 2 s . co m*/ //Since no model attribute metaRobots can be set for JSON response, then configure that servlet path in the xml. //If its a regular response and this setting has to be overriden then set model attribute metaRobots else if (CollectionUtils.contains(getRobotIndexForJSONMapping().keySet().iterator(), request.getServletPath())) { robotsValue = getRobotIndexForJSONMapping().get(request.getServletPath()); } else { robotsValue = "index,follow"; } } else if (RequestMethod.POST.name().equalsIgnoreCase(request.getMethod())) { robotsValue = "no-index,no-follow"; } modelAndView.addObject("metaRobots", robotsValue); } if (modelAndView != null && modelAndView.getModel().containsKey("metatags")) { final MetaElementData metaElement = new MetaElementData(); metaElement.setName("robots"); metaElement.setContent((String) modelAndView.getModel().get("metaRobots")); ((List<MetaElementData>) modelAndView.getModel().get("metatags")).add(metaElement); } }
From source file:com.exxonmobile.ace.hybris.storefront.interceptors.beforeview.SeoRobotsFollowBeforeViewHandler.java
@Override public void beforeView(final HttpServletRequest request, final HttpServletResponse response, final ModelAndView modelAndView) { // Check to see if the controller has specified a Index/Follow directive for robots if (modelAndView != null && !modelAndView.getModel().containsKey("metaRobots")) { // Build a default directive String robotsValue = "no-index,no-follow"; if (RequestMethod.GET.name().equalsIgnoreCase(request.getMethod())) { if (request.isSecure()) { robotsValue = "no-index,follow"; }// www .j a v a 2 s .c om //Since no model attribute metaRobots can be set for JSON response, then configure that servlet path in the xml. //If its a regular response and this setting has to be overriden then set model attribute metaRobots else if (CollectionUtils.contains(getRobotIndexForJSONMapping().keySet().iterator(), request.getServletPath())) { robotsValue = getRobotIndexForJSONMapping().get(request.getServletPath()); } else { robotsValue = "index,follow"; } } else if (RequestMethod.POST.name().equalsIgnoreCase(request.getMethod())) { robotsValue = "no-index,no-follow"; } modelAndView.addObject("metaRobots", robotsValue); } if (modelAndView != null && modelAndView.getModel().containsKey("metatags")) { final MetaElementData metaElement = new MetaElementData(); metaElement.setName("robots"); metaElement.setContent((String) modelAndView.getModel().get("metaRobots")); ((List<MetaElementData>) modelAndView.getModel().get("metatags")).add(metaElement); } }
From source file:com.lc.storefront.interceptors.beforeview.SeoRobotsFollowBeforeViewHandler.java
@Override public void beforeView(final HttpServletRequest request, final HttpServletResponse response, final ModelAndView modelAndView) { // Check to see if the controller has specified a Index/Follow directive for robots if (modelAndView != null && !modelAndView.getModel().containsKey(ThirdPartyConstants.SeoRobots.META_ROBOTS)) { // Build a default directive String robotsValue = ThirdPartyConstants.SeoRobots.NOINDEX_NOFOLLOW; if (RequestMethod.GET.name().equalsIgnoreCase(request.getMethod())) { if (request.isSecure()) { robotsValue = ThirdPartyConstants.SeoRobots.NOINDEX_FOLLOW; }/*from w ww .ja va2 s. com*/ //Since no model attribute metaRobots can be set for JSON response, then configure that servlet path in the xml. //If its a regular response and this setting has to be overriden then set model attribute metaRobots else if (CollectionUtils.contains(getRobotIndexForJSONMapping().keySet().iterator(), request.getServletPath())) { robotsValue = getRobotIndexForJSONMapping().get(request.getServletPath()); } else { robotsValue = ThirdPartyConstants.SeoRobots.INDEX_FOLLOW; } } else if (RequestMethod.POST.name().equalsIgnoreCase(request.getMethod())) { robotsValue = ThirdPartyConstants.SeoRobots.NOINDEX_NOFOLLOW; } modelAndView.addObject(ThirdPartyConstants.SeoRobots.META_ROBOTS, robotsValue); } if (modelAndView != null && modelAndView.getModel().containsKey("metatags")) { final MetaElementData metaElement = new MetaElementData(); metaElement.setName("robots"); metaElement.setContent((String) modelAndView.getModel().get(ThirdPartyConstants.SeoRobots.META_ROBOTS)); ((List<MetaElementData>) modelAndView.getModel().get("metatags")).add(metaElement); } }
From source file:de.dlopes.stocks.facilitator.services.YahooFinanceComIndexHTMLExtractorTest.java
@Test public void testGetYahooSymbols() { List<String> isins = _classUnderTest.getFinanceData(URL); assertEquals("unexpected number of stocks", DAX_TEST_YSYM.size(), isins.size()); String strArr = "[" + StringUtils.collectionToCommaDelimitedString(isins) + "]"; for (String isin : DAX_TEST_YSYM) { // assert all expected values are found in the result assertTrue("ISIN " + isin + " is not included in " + strArr, CollectionUtils.contains(isins.iterator(), isin)); }//from w w w .j a va 2 s . c o m }
From source file:de.dlopes.stocks.facilitator.services.FinanzenNetIndexHTMLExtractorTest.java
@Test public void testGetISINs() { List<String> isins = _classUnderTest.getFinanceData(URL); assertEquals("unexpected number of stocks", DAX_TEST_ISINS.size(), isins.size()); String strArr = "[" + StringUtils.collectionToCommaDelimitedString(isins) + "]"; for (String isin : DAX_TEST_ISINS) { // assert all expected values are found in the result assertTrue("ISIN " + isin + " is not included in " + strArr, CollectionUtils.contains(isins.iterator(), isin)); }//from w w w. j a v a 2 s . co m }
From source file:uk.gov.nationalarchives.discovery.taxonomy.common.service.impl.TSetBasedCategoriserServiceImpl.java
public List<TSetBasedCategorisationResult> testCategoriseSingle(InformationAssetView iaView) { logger.info(".testCategoriseSingle: catdocref:{}, docreference:{} ", iaView.getCATDOCREF(), iaView.getDOCREFERENCE());//from w w w.j av a 2 s. co m Document doc = new Document(); try { for (Field field : iaView.getClass().getDeclaredFields()) { field.setAccessible(true); String fieldName = field.getName(); if (CollectionUtils.contains(Arrays.asList(fieldsToAnalyse.split(",")).iterator(), fieldName)) { String value = String.valueOf(field.get(iaView)); if (value != null && !"null".equals(value)) { doc.add(new TextField(fieldName, value, Store.YES)); } } } } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } return runMlt(doc); }