List of usage examples for java.util Map containsKey
boolean containsKey(Object key);
From source file:com.adguard.android.contentblocker.ServiceApiClient.java
/** * Downloads filter versions.// w w w . jav a 2 s.co m * * @param filters list * @return filters list with downloaded versions */ public static List<FilterList> downloadFilterVersions(Context context, List<FilterList> filters) throws IOException, JSONException { String downloadUrl = RawResources.getCheckFilterVersionsUrl(context); LOG.info("Sending request to {}", downloadUrl); String response = downloadString(downloadUrl); if (StringUtils.isBlank(response)) { return null; } Set<Integer> filterIds = new HashSet<>(filters.size()); for (FilterList filter : filters) { filterIds.add(filter.getFilterId()); } Map map = readValue(response, Map.class); if (map == null || !map.containsKey("filters")) { LOG.error("Filters parse error! Response:\n{}", response); return null; } ArrayList filterList = (ArrayList) map.get("filters"); List<FilterList> result = new ArrayList<>(filters.size()); String[] parsePatterns = { "yyyy-MM-dd'T'HH:mm:ssZ" }; for (Object filterObj : filterList) { Map filter = (Map) filterObj; int filterId = (int) filter.get("filterId"); if (!filterIds.contains(filterId)) { continue; } FilterList list = new FilterList(); list.setName((String) filter.get("name")); list.setDescription((String) filter.get("description")); list.setFilterId(filterId); list.setVersion((String) filter.get("version")); try { String timeUpdated = (String) filter.get("timeUpdated"); list.setTimeUpdated(DateUtils.parseDate(timeUpdated, parsePatterns)); } catch (ParseException e) { LOG.error("Unable to parse date from filters:\n", e); } result.add(list); } return result; }
From source file:io.gravitee.common.util.EnvironmentUtils.java
private static void addAll(Map<String, Object> aBase, Map<String, Object> aToBeAdded) { for (Map.Entry<String, Object> entry : aToBeAdded.entrySet()) { if (aBase.containsKey(entry.getKey())) { continue; }/*from w w w . j a va2 s . c o m*/ aBase.put(entry.getKey(), entry.getValue()); } }
From source file:lite.flow.runtime.kiss.ComponentUtil.java
private static Object getConsParamvalue(Parameter consParam, Map<String, Object> resources, Map<String, Object> parameters) { String name = consParam.getName(); if (resources.containsKey(name)) return resources.get(name); if (parameters.containsKey(name)) return parameters.get(name); throw new IllegalArgumentException("No resource or parameter is available by name: " + name); }
From source file:org.shareok.data.sagedata.SageJournalDataProcessorFactory.java
public static SageJournalDataProcessor getSageJournalDataProcessorByName(Map journalMap, String journalName) { SageJournalDataProcessor sjdp = null; if (null == journalMap) { journalMap = SageDataUtil.getJournalListWithBeans(); }//from w w w. j ava 2s . co m if (journalMap.containsKey(journalName)) { String bean = (String) journalMap.get(journalName); ApplicationContext context = new ClassPathXmlApplicationContext("sageDataContext.xml"); sjdp = (SageJournalDataProcessor) context.getBean(bean); } return sjdp; }
From source file:com.app.framework.web.mvc.ActionMap.java
public static ActionMap Init(ServletRequest request, ServletResponse response) throws IOException { ActionMap actMap = null;//from w w w.j a va 2 s . com HttpServletRequest req = ((HttpServletRequest) request); String s1 = req.getContextPath(); String s2 = req.getRequestURI(); String s3 = req.getRequestURL().toString(); String fullUrl = getFullURL(req).toLowerCase(); if (fullUrl.contains(".css") || fullUrl.contains(".js") || fullUrl.contains(".html") || fullUrl.contains(".jpg") || fullUrl.contains(".png") || fullUrl.contains(".gif") || fullUrl.contains(".icon")) { return null; } Gson g = new Gson(); String requestedResource = s2.replace(s1 + "/", ""); String[] urlParts = requestedResource.split("/"); if (urlParts != null && urlParts.length >= 2) { String controller = urlParts[0]; String action = urlParts[1]; String jsonFilePath = req.getServletContext().getRealPath("/WEB-INF/action-map.json"); String json = FileUtils.readFileToString(new File(jsonFilePath), "utf-8"); Type listType = new TypeToken<Map<String, ControllerInfo>>() { }.getType(); Map<String, ControllerInfo> map = g.fromJson(json, listType); String method = req.getMethod(); if (map.containsKey(controller)) { actMap = new ActionMap(); ControllerInfo cInfo = map.get(controller); ActionInfo mInfo = cInfo.getActions().get(action).get(method); actMap.setController(cInfo.getControllerClassName()); actMap.setAction(mInfo.getMethodName()); actMap.setModel(mInfo.getModelClassName()); } } return actMap; }
From source file:com.wavemaker.tools.apidocs.tools.parser.util.MethodUtils.java
public static Method getMethodForUniqueIdentifier(String uniqueId, Class<?> type) { Map<String, Method> identifierMap = getMethodUniqueIdentifierIdMap(type); if (identifierMap.containsKey(uniqueId)) { return identifierMap.get(uniqueId); }/* ww w . j a v a 2 s. c o m*/ throw new IllegalArgumentException("There is no method associated with given unique key:" + uniqueId); }
From source file:fm.pattern.spin.config.SpinConfiguration.java
private static StartupConfiguration resolveStartupConfiguration(Map<String, Map<String, Object>> model) { for (Map.Entry<String, Map<String, Object>> entry : model.entrySet()) { String key = entry.getKey(); if (key.equals("startup")) { Map<String, Object> map = entry.getValue(); Integer pollingInterval = map.containsKey("polling_interval") ? (Integer) map.get("polling_interval") : DEFAULT_POLLING_INTERVAL_MILLIS; Integer retryCount = map.containsKey("retry_count") ? (Integer) map.get("retry_count") : DEFAULT_RETRY_COUNT; Boolean concurrentStartup = map.containsKey("concurrent") ? (Boolean) map.get("concurrent") : DEFAULT_CONCURRENT; return new StartupConfiguration(pollingInterval, retryCount, concurrentStartup); }/* w w w . j a v a2 s. co m*/ } return new StartupConfiguration(DEFAULT_POLLING_INTERVAL_MILLIS, DEFAULT_RETRY_COUNT, DEFAULT_CONCURRENT); }
From source file:org.hawkular.alerts.actions.webhook.WebHooks.java
public static synchronized void addWebHook(String tenantId, String filter, String url) throws IOException { if (!instance.webhooks.containsKey(tenantId)) { instance.webhooks.put(tenantId, new ArrayList<>()); }/* ww w . jav a2 s .c o m*/ List<Map<String, String>> tenantWebHooks = instance.webhooks.get(tenantId); Map<String, String> webhook = null; for (int i = 0; i < tenantWebHooks.size(); i++) { Map<String, String> item = tenantWebHooks.get(i); if (item.containsKey("url") && item.get("url").equals(url)) { webhook = item; break; } } if (webhook == null) { webhook = new HashMap<>(); tenantWebHooks.add(webhook); } webhook.put("url", url); webhook.put("filter", filter); if (instance.supportsFile) { File f = new File(instance.webhooksFile); instance.mapper.writeValue(f, instance.webhooks); } }
From source file:com.microsoft.azuretools.adauth.ResponseUtils.java
public static AuthorizationResult parseAuthorizeResponse(String webAuthenticationResult, CallState callState) throws URISyntaxException, UnsupportedEncodingException { AuthorizationResult result = null;/*w w w . j av a 2 s .com*/ URI resultUri = new URI(webAuthenticationResult); // NOTE: The Fragment property actually contains the leading '#' character and that must be dropped String resultData = resultUri.getQuery(); if (resultData != null && !resultData.isEmpty()) { // Remove the leading '?' first Map<String, String> map = UriUtils.formQueryStirng(resultData); if (map.containsKey(OAuthHeader.CorrelationId)) { String correlationIdHeader = (map.get(OAuthHeader.CorrelationId)).trim(); try { UUID correlationId = UUID.fromString(correlationIdHeader); if (!correlationId.equals(callState.correlationId)) { log.log(Level.WARNING, "Returned correlation id '" + correlationId + "' does not match the sent correlation id '" + callState.correlationId + "'"); } } catch (IllegalArgumentException ex) { log.log(Level.WARNING, "Returned correlation id '" + correlationIdHeader + "' is not in GUID format."); } } if (map.containsKey(OAuthReservedClaim.Code)) { result = new AuthorizationResult(map.get(OAuthReservedClaim.Code)); } else if (map.containsKey(OAuthReservedClaim.Error)) { result = new AuthorizationResult(map.get(OAuthReservedClaim.Error), map.get(OAuthReservedClaim.ErrorDescription), map.get(OAuthReservedClaim.ErrorSubcode)); } else { result = new AuthorizationResult(AuthError.AuthenticationFailed, AuthErrorMessage.AuthorizationServerInvalidResponse); } } return result; }
From source file:com.thoughtworks.go.agent.launcher.ServerBinaryDownloader.java
private static void checkHeaders(Map<String, String> headers, String url) { if (!headers.containsKey(MD5_HEADER) || !headers.containsKey(SSL_PORT_HEADER)) { LOG.error("Contacted server at URL " + url + " but it didn't give me the information I wanted. Please check the hostname and port."); }//from w ww . j ava 2 s.c o m }