List of usage examples for org.apache.commons.collections MapUtils EMPTY_MAP
Map EMPTY_MAP
To view the source code for org.apache.commons.collections MapUtils EMPTY_MAP.
Click Source Link
From source file:name.martingeisse.api.i18n.ClassHierarchyLocalizationContext.java
/** * Loads the .properties file for the origin class and the specified locale and returns * either its contents as a map, or an empty map if the file cannot be found. * /*from w ww . ja v a2s .co m*/ * This method is static to emphasize that it does not use or affect the calling instance * in any other way. * * @param origin the origin class * @param locale the locale * @return the properties */ private static Map<String, String> loadProperties(Class<?> origin, Locale locale) { String filename = origin.getSimpleName() + '_' + locale + ".properties"; try (InputStream inputStream = origin.getResourceAsStream(filename)) { if (inputStream == null) { @SuppressWarnings("unchecked") Map<String, String> emptyMap = MapUtils.EMPTY_MAP; return emptyMap; } Properties properties = new Properties(); properties.load(inputStream); @SuppressWarnings("unchecked") Map<String, String> typedProperties = (Map<String, String>) (Map<?, ?>) properties; return typedProperties; } catch (IOException e) { logger.error("could not load i18n property file", e); return null; } }
From source file:extend.logback.access.spi.AccessEvent.java
public void buildRequestHeaderMap() { if (httpRequest == null || httpRequest.headers == null) { requestHeaderMap = MapUtils.EMPTY_MAP; } else {/*from w ww . java2 s. c o m*/ requestHeaderMap = Maps.newTreeMap(); Set<Entry<String, Header>> entry = httpRequest.headers.entrySet(); for (Entry<String, Header> tmp : entry) { requestHeaderMap.put(tmp.getKey(), tmp.getValue() != null ? tmp.getValue().value() : StringUtils.EMPTY); } } }
From source file:eu.europa.ec.fisheries.uvms.rules.service.bean.RulesActivityServiceBean.java
public Map<String, List<FishingActivityWithIdentifiers>> getFishingActivitiesForTrips(Object requestMessage) { GetFishingActivitiesForTripResponse response = null; FLUXFAReportMessage fluxFaRepMessage; if (requestMessage != null && requestMessage instanceof FLUXFAReportMessage) { fluxFaRepMessage = (FLUXFAReportMessage) requestMessage; } else {//from w w w . jav a 2s .co m log.error("Either FLUXFAReportMessage is null or is not of the right type!"); return MapUtils.EMPTY_MAP; } try { String strReq = ActivityModuleRequestMapper .mapToGetFishingActivitiesForTripRequest(collectFaIdsAndTripIdsFromMessage(fluxFaRepMessage)); if (StringUtils.isEmpty(strReq)) { log.warn( "The request resulted empty in method RulesActivityServiceBean.getFishingActivitiesForTrips(..){...}. Empty list will be returned"); return MapUtils.EMPTY_MAP; } String jmsCorrelationId = producer.sendDataSourceMessage(strReq, DataSourceQueue.ACTIVITY); TextMessage message = consumer.getMessage(jmsCorrelationId, TextMessage.class); response = ActivityModuleResponseMapper.mapToGetFishingActivitiesForTripResponse(message, jmsCorrelationId); } catch (MessageException | ActivityModelMapperException e) { log.error( "ERROR when sending/consuming message from ACTIVITY module. Service : RulesActivityServiceBean.getNonUniqueIdsList(Object requestMessage){...}", e); } return transformResponse(response); }
From source file:net.hillsdon.reviki.vc.impl.TestSVNPageStore.java
@SuppressWarnings("unchecked") public void testGetPage() throws PageStoreException { final String content = "Content"; PageReferenceImpl ref = new PageReferenceImpl("Page"); expect(_operations.checkPath(ref.getPath(), -1L)).andReturn(SVNNodeKind.FILE); _operations.getFile(eq(ref.getPath()), eq(-1L), (Map<String, String>) anyObject(), (OutputStream) anyObject()); expectLastCall().andAnswer(new IAnswer<Object>() { public Object answer() throws Throwable { OutputStream out = (OutputStream) getCurrentArguments()[3]; out.write(content.getBytes()); return null; }/*www . java 2 s . c o m*/ }); expect(_operations.getLock(ref.getPath())).andReturn(null); replay(); VersionedPageInfo returnValue = _store.get(ref, -1); assertEquals(ref.getName(), returnValue.getName()); assertEquals(content, returnValue.getContent()); assertEquals(MapUtils.EMPTY_MAP, returnValue.getAttributes()); verify(); }
From source file:com.iyonger.apm.web.service.PerfTestService.java
/** * Check if the given perfTest has too many errors. (20%) * * @param perfTest perftest/* w w w . ja va 2s . c o m*/ * @return true if too many errors. */ @SuppressWarnings("unchecked") public boolean hasTooManyError(PerfTest perfTest) { Map<String, Object> result = getStatistics(perfTest); Map<String, Object> totalStatistics = MapUtils.getMap(result, "totalStatistics", MapUtils.EMPTY_MAP); long tests = MapUtils.getDouble(totalStatistics, "Tests", 0D).longValue(); long errors = MapUtils.getDouble(totalStatistics, "Errors", 0D).longValue(); return ((((double) errors) / (tests + errors)) > 0.3d); }
From source file:com.iyonger.apm.web.service.PerfTestService.java
/** * Update the given {@link PerfTest} properties after test finished. * * @param perfTest perfTest// w w w . j ava2 s .c om */ public void updatePerfTestAfterTestFinish(PerfTest perfTest) { checkNotNull(perfTest); Map<String, Object> result = consoleManager.getConsoleUsingPort(perfTest.getPort()).getStatisticsData(); @SuppressWarnings("unchecked") Map<String, Object> totalStatistics = MapUtils.getMap(result, "totalStatistics", MapUtils.EMPTY_MAP); LOGGER.info("Total Statistics for test {} is {}", perfTest.getId(), totalStatistics); perfTest.setTps(parseDoubleWithSafety(totalStatistics, "TPS", 0D)); perfTest.setMeanTestTime(parseDoubleWithSafety(totalStatistics, "Mean_Test_Time_(ms)", 0D)); perfTest.setPeakTps(parseDoubleWithSafety(totalStatistics, "Peak_TPS", 0D)); perfTest.setTests(MapUtils.getDouble(totalStatistics, "Tests", 0D).longValue()); perfTest.setErrors(MapUtils.getDouble(totalStatistics, "Errors", 0D).longValue()); }
From source file:de.hybris.platform.ytelcoacceleratorstorefront.controllers.pages.AccountPageController.java
@RequestMapping(value = "/setAutorenewalStatus", method = RequestMethod.POST) public String setAutorenewalStatus(@RequestParam(value = "autorenew", required = true) final boolean autorenew, @RequestParam(value = "subscriptionId", required = true) final String subscriptionId, final RedirectAttributes redirectAttributes) { try {/*from ww w . j ava2s. c o m*/ subscriptionFacade.updateSubscriptionAutorenewal(subscriptionId, autorenew, MapUtils.EMPTY_MAP); redirectAttributes.addFlashAttribute(GlobalMessages.CONF_MESSAGES_HOLDER, Collections.singletonList("text.account.subscription.changeAutorenew.success")); } catch (final SubscriptionFacadeException e) { redirectAttributes.addFlashAttribute(GlobalMessages.ERROR_MESSAGES_HOLDER, Collections.singletonList("text.account.subscription.changeAutorenew.unable")); LOG.error(String.format("Unable to change auto-renew status to '%s' for subscription '%s'", String.valueOf(autorenew), subscriptionId), e); } return REDIRECT_MY_ACCOUNT_SUBSCRIPTION + subscriptionId; }
From source file:de.hybris.platform.ytelcoacceleratorstorefront.controllers.pages.AccountPageController.java
@RequestMapping(value = "/changeSubscriptionState", method = RequestMethod.POST) public String changeSubscriptionState(@RequestParam(value = "newState", required = true) final String newState, @RequestParam(value = "subscriptionId", required = true) final String subscriptionId, final RedirectAttributes redirectAttributes) { try {/*from w w w . j a v a 2s .c om*/ subscriptionFacade.changeSubscriptionState(subscriptionId, newState, MapUtils.EMPTY_MAP); redirectAttributes.addFlashAttribute(GlobalMessages.CONF_MESSAGES_HOLDER, Collections.singletonList("text.account.subscription.changeState.success")); } catch (final SubscriptionFacadeException e) { redirectAttributes.addFlashAttribute(GlobalMessages.ERROR_MESSAGES_HOLDER, Collections.singletonList("text.account.subscription.changeState.unable")); LOG.error( String.format("Unable to change state to '%s' for subscription '%s'", newState, subscriptionId), e); } return REDIRECT_MY_ACCOUNT_SUBSCRIPTION + subscriptionId; }
From source file:de.hybris.platform.ytelcoacceleratorstorefront.controllers.pages.AccountPageController.java
@RequestMapping(value = "/extendSubscriptionTermDuration", method = RequestMethod.POST) public String extendSubscriptionTermDuration( @RequestParam(value = "contractDurationExtension", required = true) final Integer contractDurationExtension, @RequestParam(value = "subscriptionId", required = true) final String subscriptionId, final RedirectAttributes redirectAttributes) { try {//from ww w . j av a2 s .co m subscriptionFacade.extendSubscriptionTermDuration(subscriptionId, contractDurationExtension, MapUtils.EMPTY_MAP); redirectAttributes.addFlashAttribute(GlobalMessages.CONF_MESSAGES_HOLDER, Collections.singletonList("text.account.subscription.extendTerm.success")); } catch (final SubscriptionFacadeException e) { redirectAttributes.addFlashAttribute(GlobalMessages.ERROR_MESSAGES_HOLDER, Collections.singletonList("text.account.subscription.extendTerm.unable")); LOG.error(String.format("Unable to extend term duration by '%s' for subscription '%s'", contractDurationExtension, subscriptionId), e); } return REDIRECT_MY_ACCOUNT_SUBSCRIPTION + subscriptionId; }
From source file:de.hybris.platform.ytelcoacceleratorstorefront.controllers.pages.AccountPageController.java
@RequestMapping(value = "/replaceSubscriptionPaymentMethod", method = RequestMethod.POST) public String replaceSubscriptionPaymentMethod( @RequestParam(value = "paymentMethodId", required = true) final String paymentMethodId, @RequestParam(value = "subscriptionId", required = true) final String subscriptionId, @RequestParam(value = "effectiveFrom", required = true) final String effectiveFrom, final RedirectAttributes redirectAttributes) { try {//from w ww . j a v a 2 s .com subscriptionFacade.replacePaymentMethod(subscriptionId, paymentMethodId, effectiveFrom, MapUtils.EMPTY_MAP); redirectAttributes.addFlashAttribute(GlobalMessages.CONF_MESSAGES_HOLDER, Collections.singletonList("text.account.subscription.replacePaymentMethod.success")); } catch (final SubscriptionFacadeException e) { redirectAttributes.addFlashAttribute(GlobalMessages.ERROR_MESSAGES_HOLDER, Collections.singletonList("text.account.subscription.replacePaymentMethod.unable")); LOG.error(String.format("Unable to replace payment method for subscription '%s'", subscriptionId), e); } return REDIRECT_MY_ACCOUNT_SUBSCRIPTION + subscriptionId; }