List of usage examples for java.util Map containsKey
boolean containsKey(Object key);
From source file:gate.termraider.util.Utilities.java
public static Set<String> getStringSetFromMap(Map<Term, Set<String>> map, Term key) { if (map.containsKey(key)) { return map.get(key); }/*from w w w. j a v a2s . c o m*/ //implied else Set<String> valueSet = new HashSet<String>(); map.put(key, valueSet); return valueSet; }
From source file:org.ebayopensource.twin.TwinConnection.java
/** Convert the given response object into a java exception */ @SuppressWarnings("unchecked") static TwinException deserializeException(Map<String, Object> exception) { TwinError responseCode = exception.containsKey("status") ? TwinError.get(((Number) exception.get("status")).intValue()) : TwinError.UnknownError; return deserializeException(responseCode, (Map<String, Object>) exception.get("value")); }
From source file:com.enablens.dfa.datastructures.Node.java
/** * Gets the type.// w w w . java 2 s . c om * * @param identity * the identity * @return the type */ public static NodeType getType(final Map<String, String> identity) { NodeType type = null; if (identity.containsKey("segmentId") || identity.containsKey("mobilityDomainId")) { type = NodeType.NETWORK; } else if (identity.containsKey("partitionName")) { type = NodeType.PARTITION; } else if (identity.containsKey("organizationName")) { type = NodeType.ORGANIZATION; } else { type = NodeType.TOPOLOGY; } return type; }
From source file:fr.esiea.windmeal.fill.database.OwnerAndProviderImportationTest.java
private static Meal[] getMealsFromMap(Map<String, String> dataMap) { int acc = 1;/*from w ww . jav a 2 s. c o m*/ Set<Meal> menu = new HashSet<Meal>(); while (dataMap.containsKey("mealname" + acc)) { Meal meal = createMeal(dataMap.get("mealname" + acc), dataMap.get("mealdescription" + acc), Double.valueOf(dataMap.get("mealprice" + acc))); menu.add(meal); acc++; } Meal[] mealArray = new Meal[menu.size()]; acc = 0; for (Meal meal : menu) { mealArray[acc] = meal; acc++; } return mealArray; }
From source file:net.maritimecloud.endorsement.utils.AccessControlUtil.java
public static boolean hasPermission(String permission) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if (auth instanceof KeycloakAuthenticationToken) { logger.debug("OIDC permission lookup"); // Keycloak authentication KeycloakAuthenticationToken kat = (KeycloakAuthenticationToken) auth; KeycloakSecurityContext ksc = (KeycloakSecurityContext) kat.getCredentials(); Map<String, Object> otherClaims = ksc.getToken().getOtherClaims(); if (otherClaims.containsKey(AccessControlUtil.PERMISSIONS_PROPERTY_NAME)) { String usersPermissions = (String) otherClaims.get(AccessControlUtil.PERMISSIONS_PROPERTY_NAME); String[] permissionList = usersPermissions.split(","); for (String per : permissionList) { if (per.equalsIgnoreCase(permission)) { return true; }/*from w w w .j av a 2s . c om*/ } } /*} else if (auth instanceof PreAuthenticatedAuthenticationToken) { logger.debug("Certificate permission lookup"); // Certificate authentication PreAuthenticatedAuthenticationToken token = (PreAuthenticatedAuthenticationToken) auth; // Check that the permission is granted to this user InetOrgPerson person = ((InetOrgPerson) token.getPrincipal()); Collection<GrantedAuthority> authorities = person.getAuthorities(); for (GrantedAuthority authority : authorities) { String usersPermissions = authority.getAuthority(); String[] permissionList = usersPermissions.split(","); for (String per : permissionList) { if (per.equalsIgnoreCase(permission)) { return true; } } }*/ } else { if (auth != null) { logger.debug("Unknown authentication method: " + auth.getClass()); } } return false; }
From source file:org.hdiv.web.servlet.tags.form.SelectedValueComparatorHDIV.java
private static boolean mapCompare(Map boundMap, Object candidateValue, BindStatus bindStatus) { try {/* w w w .ja va 2s .c o m*/ if (boundMap.containsKey(candidateValue)) { return true; } } catch (ClassCastException ex) { // Probably from a TreeMap - ignore. } return exhaustiveCollectionCompare(boundMap.keySet(), candidateValue, bindStatus); }
From source file:net.doubledoordev.backend.webserver_old.methods.Post.java
/** * Handle post requests from the login page *//*from w w w . j a va 2s .c o m*/ private static void handleLogin(HashMap<String, Object> dataObject, NanoHTTPD.HTTPSession session, Map<String, String> map) { if (map.containsKey("username") && map.containsKey("password")) { User user = Settings.getUserByName(map.get("username")); if (user != null && user.verify(map.get("password"))) { session.getCookies().set(COOKIE_KEY, user.getUsername() + "|" + user.getPasshash(), 30); dataObject.put("user", user); } else dataObject.put("message", "Login failed."); } else if (map.containsKey("logout")) { session.getCookies().delete(COOKIE_KEY); dataObject.remove("user"); } else if (dataObject.containsKey("user") && map.containsKey("oldPassword") && map.containsKey("newPassword")) { User user = (User) dataObject.get("user"); if (user.updatePassword(map.get("oldPassword"), map.get("newPassword"))) { session.getCookies().set(COOKIE_KEY, user.getUsername() + "|" + user.getPasshash(), 30); } else dataObject.put("message", "Old password was wrong."); } else dataObject.put("message", "Form error."); }
From source file:io.cloudslang.content.amazon.utils.OutputsUtil.java
public static void putResponseIn(Map<String, String> queryMapResult, String outputName, String xPathQuery) { XpathQuery xpathQueryAction = new XpathQuery(); String xmlString = queryMapResult.get(RETURN_RESULT); //We make this workaround because the xml has an xmlns property in the tag and our operation can not parse the xml //this should be removed when the xml operation will be enhanced if (!isBlank(xmlString)) { xmlString = xmlString.replace(XMLNS, WORKAROUND); Map<String, String> result = xpathQueryAction.execute(xmlString, XML_DOCUMENT_SOURCE, xPathQuery, VALUE, DELIMITER, valueOf(true)); if (result.containsKey(RETURN_CODE) && SUCCESS.equals(result.get(RETURN_CODE))) { queryMapResult.put(outputName, result.get(SELECTED_VALUE)); } else {//from w w w.j a v a 2s.co m queryMapResult.put(RETURN_CODE, FAILURE); queryMapResult.put(EXCEPTION, result.get(ERROR_MESSAGE)); } } else { queryMapResult.put(RETURN_RESULT, "Empty response."); queryMapResult.put(RETURN_CODE, FAILURE); } }
From source file:Main.java
public static String getFilterSuffix(Map<String, List<String>> filters) { if (filters == null) return ""; String filterstr = ""; if (filters.containsKey("type") == true) { filterstr += "("; for (String filter : filters.get("type")) { if (filter.toLowerCase().equals("html")) { filterstr += "Content-Type:*html* OR "; } else if (filter.toLowerCase().equals("image")) { filterstr += "Content-Type:image* OR "; } else if (filter.toLowerCase().equals("video")) { filterstr += "Content-Type:video* OR "; } else if (filter.toLowerCase().equals("audio")) { filterstr += "Content-Type:audio* OR "; } else if (filter.toLowerCase().equals("text")) { filterstr += "Content-Type:text* OR "; }/* ww w.j av a 2 s . c o m*/ } // remove the last " OR " and close the search string for this part filterstr = filterstr.substring(0, filterstr.length() - 4); filterstr += ") AND "; } // TODO if "ProfileName" includes special chars like (,", ... we will have a problem with the search? if (filters.containsKey("source") == true) { filterstr += "("; // something like this will come "org.backmeup.source (ProfileName)" for (String filter : filters.get("source")) { // get out the source plugin, result will be "org.backmeup.source" String source = filter.substring(0, filter.indexOf(" ")); // get out the profile "(Profilename)" String profile = filter.substring(filter.indexOf(" ") + 1, filter.length()); // remove the brackets at begin and end, result will be "ProfileName" profile = profile.substring(1, profile.length() - 1); filterstr += "(" + FIELD_BACKUP_SOURCE_PLUGIN_NAME + ":" + source + " AND " + FIELD_BACKUP_SOURCE_IDENTIFICATION + ":" + profile + ") OR "; } // remove the last " OR " and close the search string for this part filterstr = filterstr.substring(0, filterstr.length() - 4); filterstr += ") AND "; } // TODO if job contains special chars ... if (filters.containsKey("job") == true) { filterstr += "("; // something like this will come "JobName (Timestamp)" (java timestamp -> 13 chars) for (String filter : filters.get("job")) { // get out the timestamp (also remove the "()"). String timestamp = filter.substring(filter.length() - 14, filter.length() - 1); // get out the job name String jobname = filter.substring(0, filter.length() - 16); filterstr += "(" + FIELD_BACKUP_AT + ":" + timestamp + " AND " + FIELD_JOB_NAME + ":" + jobname + ") OR "; } // remove the last " OR " and close the search string for this part filterstr = filterstr.substring(0, filterstr.length() - 4); filterstr += ") AND "; } return filterstr; }
From source file:com.nci.tkb.busi.serviceimpl.ResponseHandlerUtils.java
public static final Map<String, String> getResponseValue(String requestCode, Map<String, String> response) throws UseException { // TODO?/*from w w w .jav a2 s .c om*/ if (!response.containsKey(ShareFieldUtils.REQ_CODE)) { response.put(ShareFieldUtils.REQ_CODE, "1"); } if (!response.containsKey(ShareFieldUtils.RESP_CODE)) { response.put(ShareFieldUtils.RESP_CODE, requestCode); } response.put(ShareFieldUtils.APP_VER, "1.0"); response.put(ShareFieldUtils.SYS_PARAM, "1.0"); Map<String, String> retMap = new HashMap<String, String>(); Map<String, String> _maps = dispache(requestCode); for (Map.Entry<String, String> entry : _maps.entrySet()) { String _key = entry.getKey(); String _value = entry.getValue(); String value = response.get(_key); if (MUST.equals(_value) && StringUtils.isBlank(value)) { log.info(StaticMethod.getTraceInfo()); log.error("****************MISSING MUST CODE:" + _key); throw new UseException(RetCode.RETCODE_MISSING, "MISSING MUST CODE" + _key); } if (StringUtils.isNotBlank(value)) { retMap.put(_key, value); } } return retMap; }