List of usage examples for java.util Map remove
V remove(Object key);
From source file:cascading.flow.hadoop.util.HadoopUtil.java
public static Map<String, String> getConfig(Configuration defaultConf, Configuration updatedConf) { Map<String, String> configs = new HashMap<String, String>(); for (Map.Entry<String, String> entry : updatedConf) configs.put(entry.getKey(), entry.getValue()); for (Map.Entry<String, String> entry : defaultConf) { if (entry.getValue() == null) continue; String updatedValue = configs.get(entry.getKey()); // if both null, lets purge from map to save space if (updatedValue == null && entry.getValue() == null) configs.remove(entry.getKey()); // if the values are the same, lets also purge from map to save space if (updatedValue != null && updatedValue.equals(entry.getValue())) configs.remove(entry.getKey()); configs.remove("mapred.working.dir"); configs.remove("mapreduce.job.working.dir"); // hadoop2 }/*w w w.ja va 2 s . co m*/ return configs; }
From source file:com.epam.reportportal.auth.OAuthConfigurationEndpoint.java
/** * Deletes oauth integration settings/*w ww. j a v a 2 s. c o m*/ * * @param profileId settings ProfileID * @param oauthProviderName ID of third-party OAuth provider * @return All defined OAuth integration settings */ @RequestMapping(value = "/{authId}", method = { DELETE }) @ResponseBody @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "Deletes ThirdParty OAuth Server Settings", notes = "'default' profile is using till additional UI implementations") public OperationCompletionRS deleteOAuthSetting(@PathVariable String profileId, @PathVariable("authId") String oauthProviderName) { ServerSettings settings = repository.findOne(profileId); BusinessRule.expect(settings, Predicates.notNull()).verify(ErrorType.SERVER_SETTINGS_NOT_FOUND, profileId); Map<String, OAuth2LoginDetails> serverOAuthDetails = Optional.of(settings.getoAuth2LoginDetails()) .orElse(new HashMap<>()); if (null != serverOAuthDetails.remove(oauthProviderName)) { settings.setoAuth2LoginDetails(serverOAuthDetails); repository.save(settings); } else { throw new ReportPortalException(ErrorType.OAUTH_INTEGRATION_NOT_FOUND); } return new OperationCompletionRS("Auth settings '" + oauthProviderName + "' were successfully removed"); }
From source file:com.googlecode.psiprobe.controllers.system.SysInfoController.java
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { SystemInformation systemInformation = new SystemInformation(); systemInformation.setAppBase(getContainerWrapper().getTomcatContainer().getAppBase().getAbsolutePath()); systemInformation.setConfigBase(getContainerWrapper().getTomcatContainer().getConfigBase()); Map sysProps = new Properties(); sysProps.putAll(System.getProperties()); if (!SecurityUtils.hasAttributeValueRole(getServletContext(), request)) { for (Iterator it = filterOutKeys.iterator(); it.hasNext();) { sysProps.remove(it.next()); }// ww w . ja v a2 s . c o m } systemInformation.setSystemProperties(sysProps); return new ModelAndView(getViewName()).addObject("systemInformation", systemInformation) .addObject("runtime", getRuntimeInfoAccessor().getRuntimeInformation()) .addObject("collectionPeriod", new Long(getCollectionPeriod())); }
From source file:edu.artic.geneva.sync.UpdateProcessor.java
public void process(final Exchange exchange) throws IOException { final Message in = exchange.getIn(); try {//from w ww . jav a 2 s .co m final JsonLdOptions opts = new JsonLdOptions("") { { format = "application/nquads"; } }; final Object doc = fromString(in.getHeader(GENEVA_JSON_LD_DOCUMENT, String.class)); final List<Object> expanded = expand(doc); final Map<String, Object> map = (Map<String, Object>) expanded.get(0); final Object res = toRDF(doc, null, opts); final StringBuilder sb = new StringBuilder("DELETE WHERE {"); map.remove("@id"); map.remove("@context"); if (map.containsKey("@type")) { if (map.get("@type") instanceof List) { for (final Object t : (List) map.get("@type")) { sb.append("<> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <" + (String) t + "> . \n"); } } else if (map.get("@type") instanceof String) { sb.append("<> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <" + (String) map.get("@type") + "> .\n"); } } final List<String> preds = map.entrySet().stream().map(e -> e.getKey()).filter(e -> !e.startsWith("@")) .collect(toList()); for (int i = 0; i < preds.size(); i++) { sb.append("<> <" + preds.get(i) + "> ?o" + i + " .\n"); } sb.append("};\n"); sb.append("INSERT DATA {"); sb.append(res); sb.append("}"); in.setBody(sb.toString()); } catch (final JsonLdError ex) { throw new RuntimeCamelException("Error expanding JSON-LD", ex); } catch (final JsonParseException ex) { throw new RuntimeCamelException("Error parsing JSON", ex); } catch (final JsonGenerationException ex) { throw new RuntimeCamelException("Error generating JSON", ex); } }
From source file:android.support.test.espresso.web.model.ModelCodec.java
private static Object decodeObject(JSONObject jsonObject) throws JSONException { List<String> nullKeys = Lists.newArrayList(); Map<String, Object> obj = Maps.newHashMap(); Iterator<String> keys = jsonObject.keys(); while (keys.hasNext()) { String key = keys.next(); if (jsonObject.isNull(key)) { nullKeys.add(key);/*from w w w. ja va2 s . c o m*/ obj.put(key, JSONObject.NULL); } else { Object value = jsonObject.get(key); if (value instanceof JSONObject) { obj.put(key, decodeObject((JSONObject) value)); } else if (value instanceof JSONArray) { obj.put(key, decodeArray((JSONArray) value)); } else { // boolean / string / or number. obj.put(key, value); } } } Object replacement = maybeReplaceMap(obj); if (replacement != null) { return replacement; } else { for (String key : nullKeys) { obj.remove(key); } return obj; } }
From source file:net.sf.eventgraphj.analysis.InverseDistanceCentralityScorer.java
/** * Calculates the score for the specified vertex. Returns {@code null} if * there are missing distances and such are not ignored by this instance. *///from w w w .java2s. co m @Override public Double getVertexScore(V v) { Double value = this.output.get(v); if (value != null) { if (value < 0) { return null; } return value; } Map<V, Number> v_distances = new HashMap<V, Number>(this.distance.getDistanceMap(v)); if (this.ignore_self_distances) { v_distances.remove(v); } // if we don't ignore missing distances and there aren't enough // distances, output null (shortcut) if (!this.ignore_missing) { int num_dests = this.graph.getVertexCount() - (this.ignore_self_distances ? 1 : 0); if (v_distances.size() != num_dests) { this.output.put(v, -1.0); return null; } } Double sum = 0.0; int count = 0; for (V w : this.graph.getVertices()) { if (w.equals(v) && this.ignore_self_distances) { continue; } Number w_distance = v_distances.get(w); if (w_distance == null) { if (this.ignore_missing) { w_distance = Double.POSITIVE_INFINITY;// graph.getVertexCount(); } else { this.output.put(v, -1.0); return null; } } sum += 1 / w_distance.doubleValue(); count++; } value = sum; if (this.averaging && count > 0) { value /= count; } this.output.put(v, value); if (Double.isNaN(value)) { System.err.println(value); } // assert (!Double.isNaN(value)); return value; }
From source file:com.edgenius.wiki.render.handler.MenuMacroHandler.java
public List<RenderPiece> handle(RenderContext renderContext, Map<String, String> values) throws RenderHandlerException { String name = values.remove(NameConstants.MACRO); if (MenuMacro.NAME.equals(name)) { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // MenuMacro handler if (setting == null) { return new ArrayList<RenderPiece>(); //better to hide if any errors as menu may be show on all pages in space //throw new RenderHandlerException("Failed to retrieve the space menu list."); }//from w w w . j a v a 2 s . c o m if (setting.getMenuItems() == null || setting.getMenuItems().size() == 0) { //render to blank return new ArrayList<RenderPiece>(); } return buildMenu(renderContext, setting.getMenuItems()); } else { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // MenuItemMacro handler //get parent title with parent pageUUID String parentTitle = values.get(NameConstants.PARENT); if (parentTitle != null) { //menu item Page parent = null; try { parent = pageService.getCurrentPageByTitleWithoutSecurity(spaceUname, parentTitle, false); if (parent != null) { values.put(NameConstants.PARENT_UUID, parent.getPageUuid()); } } catch (SpaceNotFoundException e) { } if (parent == null) { throw new RenderHandlerException( "The page parent with title [" + parentTitle + "] does not exist."); } } //leave PageService.pageSave() to process. List<RenderPiece> pieces = new ArrayList<RenderPiece>(); MacroModel model = new MacroModel(); model.macroName = MenuItemMacro.NAME; //put all others to value object model.values = new HashMap<String, String>(values); pieces.add(model); return pieces; } }
From source file:jp.co.opentone.bsol.linkbinder.view.ErrorPage.java
public String getStackTrace() { FacesContext context = FacesContext.getCurrentInstance(); Map<String, Object> sessionMap = context.getExternalContext().getSessionMap(); Throwable ex = (Throwable) sessionMap.get("jp.co.opentone.bsol.exception"); sessionMap.remove("jp.co.opentone.bsol.exception"); StringWriter w = new StringWriter(); PrintWriter pw = new PrintWriter(w); fillStackTrace(ex, pw);/*w w w .j a v a 2s . c o m*/ return w.toString(); }
From source file:com.github.p4535992.database.datasource.database.data.Dao.java
private Set<Entry<String, Object>> extractPrimaryKeyValues(Map<String, Object> rowData) { Map<String, Object> idsToMatch = new HashMap<>(); for (String id : getPrimaryKeys()) { Object idValue = rowData.remove(id); idsToMatch.put(id, idValue);/*from w w w .ja va2 s.co m*/ } return idsToMatch.entrySet(); }
From source file:com.alibaba.cobar.manager.web.screen.CobarListScreen.java
@SuppressWarnings({ "unchecked" }) @Override//from w w w. j a va 2s . co m protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { UserDO user = (UserDO) request.getSession().getAttribute("user"); long clusterId = Long.parseLong(request.getParameter("clusterId")); ClusterDO cluster = xmlAccesser.getClusterDAO().getClusterById(clusterId); List<CobarDO> cobarList = xmlAccesser.getCobarDAO().getCobarList(clusterId); ListSortUtil.sortCobarByName(cobarList); int aCount = xmlAccesser.getCobarDAO().getCobarList(clusterId, ConstantDefine.ACTIVE).size(); int iCount = xmlAccesser.getCobarDAO().getCobarList(clusterId, ConstantDefine.IN_ACTIVE).size(); Map<String, Integer> count = new HashMap<String, Integer>(); count.put("aCount", aCount); count.put("iCount", iCount); count.put("tCount", (aCount + iCount)); PropertyUtilsBean util = new PropertyUtilsBean(); Map<String, Object> clusterMap; try { clusterMap = util.describe(cluster); } catch (Exception ex) { throw new RuntimeException(ex); } clusterMap.remove("class"); clusterMap.remove("name"); clusterMap.remove("deployDesc"); clusterMap.put("name", CobarStringUtil.htmlEscapedString(cluster.getName())); clusterMap.put("deployDesc", CobarStringUtil.htmlEscapedString(cluster.getDeployDesc())); List<Map<String, Object>> cobarListMap = new ArrayList<Map<String, Object>>(); for (CobarDO c : cobarList) { Map<String, Object> cobarMap; try { cobarMap = util.describe(c); } catch (Exception e) { throw new RuntimeException(e); } cobarMap.remove("class"); cobarMap.remove("name"); cobarMap.put("name", CobarStringUtil.htmlEscapedString(c.getName())); cobarListMap.add(cobarMap); } return new ModelAndView("v_cobarList", new FluenceHashMap<String, Object>().putKeyValue("cluster", clusterMap) .putKeyValue("cobarList", cobarListMap).putKeyValue("count", count) .putKeyValue("user", user)); }