List of usage examples for java.util Map remove
V remove(Object key);
From source file:com.bdaum.juploadr.uploadapi.locrrest.LocrMethod.java
public String getQueryString(boolean signed) { StringBuffer queryString = new StringBuffer(); Map<String, String> params = getParams(); if (isAuthorized()) { authorize(params);/*from w w w.j a v a 2s .co m*/ } String method = params.remove("method"); //$NON-NLS-1$ if (method != null) queryString.append(method); for (Map.Entry<String, String> entry : params.entrySet()) { appendNVP(queryString, entry.getKey(), entry.getValue()); } return queryString.toString(); }
From source file:elaborate.publication.solr.SearchService.java
public List<String> getAllSearchResultIds(long searchId) { try {/*from www . j av a 2s . c om*/ SearchData searchData = searchDataIndex.get(searchId); if (searchData != null) { Map<String, Object> resultsMap = searchData.getResults(); List<String> list = (List<String>) resultsMap.remove("ids"); return list; } } catch (Exception e) { throw new RuntimeException(e); } return ImmutableList.of(); }
From source file:com.zia.freshdocs.preference.CMISPreferencesManager.java
public void deletePreferences(Context ctx, String id) { Map<String, CMISHost> prefs = readPreferences(ctx); if (id == null || prefs == null) { return;/*from w w w. j a v a 2s . c o m*/ } if (prefs.containsKey(id)) { prefs.remove(id); storePreferences(ctx, prefs); } }
From source file:org.elasticsearch.test.rest.yaml.ClientYamlTestClient.java
/** * Calls an api with the provided parameters and body *//*ww w.j a v a2s . co m*/ public ClientYamlTestResponse callApi(String apiName, Map<String, String> params, HttpEntity entity, Map<String, String> headers) throws IOException { if ("raw".equals(apiName)) { // Raw requests are bit simpler.... Map<String, String> queryStringParams = new HashMap<>(params); String method = Objects.requireNonNull(queryStringParams.remove("method"), "Method must be set to use raw request"); String path = "/" + Objects.requireNonNull(queryStringParams.remove("path"), "Path must be set to use raw request"); // And everything else is a url parameter! try { Response response = restClient.performRequest(method, path, queryStringParams, entity); return new ClientYamlTestResponse(response); } catch (ResponseException e) { throw new ClientYamlTestResponseException(e); } } ClientYamlSuiteRestApi restApi = restApi(apiName); //divide params between ones that go within query string and ones that go within path Map<String, String> pathParts = new HashMap<>(); Map<String, String> queryStringParams = new HashMap<>(); for (Map.Entry<String, String> entry : params.entrySet()) { if (restApi.getPathParts().contains(entry.getKey())) { pathParts.put(entry.getKey(), entry.getValue()); } else { if (restApi.getParams().contains(entry.getKey()) || restSpec.isGlobalParameter(entry.getKey()) || restSpec.isClientParameter(entry.getKey())) { queryStringParams.put(entry.getKey(), entry.getValue()); } else { throw new IllegalArgumentException( "param [" + entry.getKey() + "] not supported in [" + restApi.getName() + "] " + "api"); } } } List<String> supportedMethods = restApi.getSupportedMethods(pathParts.keySet()); String requestMethod; if (entity != null) { if (!restApi.isBodySupported()) { throw new IllegalArgumentException("body is not supported by [" + restApi.getName() + "] api"); } String contentType = entity.getContentType().getValue(); //randomly test the GET with source param instead of GET/POST with body if (sendBodyAsSourceParam(supportedMethods, contentType)) { logger.debug("sending the request body as source param with GET method"); queryStringParams.put("source", EntityUtils.toString(entity)); queryStringParams.put("source_content_type", contentType); requestMethod = HttpGet.METHOD_NAME; entity = null; } else { requestMethod = RandomizedTest.randomFrom(supportedMethods); } } else { if (restApi.isBodyRequired()) { throw new IllegalArgumentException("body is required by [" + restApi.getName() + "] api"); } requestMethod = RandomizedTest.randomFrom(supportedMethods); } //the rest path to use is randomized out of the matching ones (if more than one) ClientYamlSuiteRestPath restPath = RandomizedTest.randomFrom(restApi.getFinalPaths(pathParts)); //Encode rules for path and query string parameters are different. We use URI to encode the path. //We need to encode each path part separately, as each one might contain slashes that need to be escaped, which needs to //be done manually. String requestPath; if (restPath.getPathParts().length == 0) { requestPath = "/"; } else { StringBuilder finalPath = new StringBuilder(); for (String pathPart : restPath.getPathParts()) { try { finalPath.append('/'); // We append "/" to the path part to handle parts that start with - or other invalid characters URI uri = new URI(null, null, null, -1, "/" + pathPart, null, null); //manually escape any slash that each part may contain finalPath.append(uri.getRawPath().substring(1).replaceAll("/", "%2F")); } catch (URISyntaxException e) { throw new RuntimeException("unable to build uri", e); } } requestPath = finalPath.toString(); } Header[] requestHeaders = new Header[headers.size()]; int index = 0; for (Map.Entry<String, String> header : headers.entrySet()) { logger.info("Adding header {}\n with value {}", header.getKey(), header.getValue()); requestHeaders[index++] = new BasicHeader(header.getKey(), header.getValue()); } logger.debug("calling api [{}]", apiName); try { Response response = restClient.performRequest(requestMethod, requestPath, queryStringParams, entity, requestHeaders); return new ClientYamlTestResponse(response); } catch (ResponseException e) { throw new ClientYamlTestResponseException(e); } }
From source file:esg.common.shell.ESGFEnv.java
License:asdf
@SuppressWarnings("unchecked") public Object removeContext(String contextKey, String key) { Map<String, Object> contextSubMap = null; if (null == (contextSubMap = (Map<String, Object>) context.get(contextKey))) { contextSubMap = new HashMap<String, Object>(); }/*from w w w .java 2 s .com*/ return contextSubMap.remove(key); }
From source file:com.networknt.light.rule.validation.AbstractValidationRule.java
protected void addValidation(Map<String, Object> data) throws Exception { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try {//from w w w . j a v a 2 s .c om graph.begin(); String createUserId = (String) data.remove("createUserId"); OrientVertex validation = graph.addVertex("class:Validation", data); Vertex user = graph.getVertexByKey("User.userId", createUserId); user.addEdge("Create", validation); graph.commit(); } catch (Exception e) { graph.rollback(); logger.error("Exception:", e); throw e; } finally { graph.shutdown(); ; } // remove the cached list if in order to reload it Map<String, Object> ruleMap = ServiceLocator.getInstance().getMemoryImage("ruleMap"); ConcurrentMap<Object, Object> cache = (ConcurrentMap<Object, Object>) ruleMap.get("cache"); if (cache != null) { cache.remove(data.get("ruleClass")); } }
From source file:com.glaf.oa.paymentplan.web.springmvc.PaymentplanController.java
@RequestMapping("/update") public ModelAndView update(HttpServletRequest request, ModelMap modelMap) { Map<String, Object> params = RequestUtils.getParameterMap(request); params.remove("status"); params.remove("wfStatus"); Paymentplan paymentplan = paymentplanService.getPaymentplan(RequestUtils.getLong(request, "planid")); paymentplan.setBudgetid(RequestUtils.getLong(request, "budgetid")); paymentplan.setPaymemtsum(RequestUtils.getDouble(request, "paymemtsum")); paymentplan.setPaymentdate(RequestUtils.getDate(request, "paymentdate")); paymentplan.setSequence(RequestUtils.getInt(request, "sequence")); paymentplanService.save(paymentplan); return this.list(request, modelMap); }
From source file:com.networknt.light.rule.role.AbstractRoleRule.java
protected void addRole(Map<String, Object> data) throws Exception { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try {//from w w w. j a va2s . c o m graph.begin(); Vertex createUser = graph.getVertexByKey("User.userId", data.remove("createUserId")); OrientVertex role = graph.addVertex("class:Role", data); createUser.addEdge("Create", role); graph.commit(); } catch (Exception e) { logger.error("Exception:", e); graph.rollback(); throw e; } finally { graph.shutdown(); } }
From source file:hydrograph.ui.graph.debugconverter.SchemaHelper.java
private void removeDuplicateKeys(List<String> oldKeys, Map<String, SubjobDetails> componentNameAndLink) { if (componentNameAndLink.size() > 1) { oldKeys.forEach(field -> componentNameAndLink.remove(field)); }/* w w w .ja va 2 s . c o m*/ }
From source file:de.metas.procurement.webui.sync.SyncUserImportService.java
public void importUsers(final BPartner bpartner, final List<SyncUser> syncUsers) { final Map<String, User> users = mapByUuid(usersRepo.findByBpartner(bpartner)); final List<User> usersToSave = new ArrayList<>(); for (final SyncUser syncUser : syncUsers) { if (syncUser.isDeleted()) { continue; }/*from ww w.java2 s .co m*/ User user = users.remove(syncUser.getUuid()); user = importUserNoSave(bpartner, syncUser, user); if (user != null) { usersToSave.add(user); } } // // Delete remaining users for (final User user : users.values()) { deleteUser(user); } // // Save users usersRepo.save(usersToSave); }