Example usage for java.util Map remove

List of usage examples for java.util Map remove

Introduction

In this page you can find the example usage for java.util Map remove.

Prototype

V remove(Object key);

Source Link

Document

Removes the mapping for a key from this map if it is present (optional operation).

Usage

From source file:com.surfs.storage.web.controller.storage.GlobleController.java

@RequestMapping(value = "/switchDataCenter.do")
public ModelAndView switchDataCenter(String dataCenterKey, HttpSession session) {

    Map<String, String> dataCenterMap = getDataCenterMap();
    String dataCenterName = dataCenterMap.get(dataCenterKey);
    session.setAttribute("dataCenterKey", dataCenterKey);
    session.setAttribute("dataCenterName", dataCenterName);
    dataCenterMap.remove(dataCenterKey);
    if (dataCenterMap.size() > 0)
        session.setAttribute("dataCenterMap", dataCenterMap);

    return new ModelAndView("redirect:/storage/showGlobleProperties.do");
}

From source file:com.arpnetworking.metrics.impl.StenoLogSink.java

/**
 * {@inheritDoc}//from  w ww . j a va2s.c  om
 */
@Override
public void record(final Event event) {

    // CHECKSTYLE.OFF: IllegalInstantiation - No Guava dependency here.
    final Map<String, String> filteredAnnotations = new HashMap<>(event.getAnnotations());
    // CHECKSTYLE.ON: IllegalInstantiation
    filteredAnnotations.remove("_host");
    filteredAnnotations.remove("_id");

    try {
        getMetricsLogger().info(StenoMarker.OBJECT_JSON_MARKER, "aint.metrics",
                _objectMapper.writeValueAsString(new TsdEvent(filteredAnnotations, event.getTimerSamples(),
                        event.getCounterSamples(), event.getGaugeSamples())));
    } catch (final IOException e) {
        _logger.warn("Exception recording event", e);
    }
}

From source file:net.solarnetwork.util.DynamicServiceTracker.java

@Override
public Object removePropertyFilter(String key) {
    Object result = null;/*from   w w  w  . j  av a  2  s .  co  m*/
    Map<String, Object> filters = propertyFilters;
    if (filters != null) {
        result = filters.remove(key);
    }
    return result;
}

From source file:org.parancoe.web.tag.FlashTag.java

@Override
protected final int doStartTagInternal() throws JspException, IOException {
    try {/* www. j av a2s .co m*/
        Map<String, String> flash = new HashMap<String, String>();
        Map<String, String> flashRequest = (Map<String, String>) pageContext.getRequest().getAttribute("flash");
        if (flashRequest != null) {
            flash.putAll(flashRequest);
        }
        Map<String, String> flashSession = (Map<String, String>) pageContext.getSession().getAttribute("flash");
        if (flashSession != null) {
            flash.putAll(flashSession);
            // And clean the session
            flashSession.remove(type);
        }
        if (flash.get(type) != null) {
            // Resolve the message.
            MessageSource messageSource = getMessageSource();
            if (messageSource == null) {
                throw new JspTagException("No corresponding MessageSource found");
            }
            String msg;
            try {
                Object[] argumentsArray = {};
                msg = messageSource.getMessage(flash.get(type), argumentsArray,
                        getRequestContext().getLocale());
            } catch (Exception ex) {
                // If the message is unresolved, use the key as message
                msg = flash.get(type);
            }

            // Write the message
            writeMessage(msg);

        }
        return EVAL_BODY_INCLUDE;
    } catch (NoSuchMessageException ex) {
        throw new JspTagException(getNoSuchMessageExceptionDescription(ex));
    }
}

From source file:com.glaf.core.web.springmvc.MxSystemParamController.java

@RequestMapping("/save")
public ModelAndView save(HttpServletRequest request, ModelMap modelMap) {
    LoginContext loginContext = RequestUtils.getLoginContext(request);
    String actorId = loginContext.getActorId();
    Map<String, Object> params = RequestUtils.getParameterMap(request);
    params.put("actorId", actorId);
    params.put("createBy", actorId);
    params.remove("status");
    params.remove("wfStatus");
    SystemParam systemParam = new SystemParam();
    Tools.populate(systemParam, params);
    // systemParam.setCreateBy(actorId);

    systemParamService.save(systemParam);

    return this.list(request, modelMap);
}

From source file:some.test.controller.TokeninfoEndpoint.java

@SuppressWarnings("unchecked")
@RequestMapping(value = "/tokeninfo", params = { "access_token" })
@ResponseBody/*from   w  w w.  ja va  2  s .c  om*/
public Map<String, Object> fakeTheResponse(@RequestParam("access_token") final String accessTokenParameter) {
    logger.warn("------- FAKE_TOKENINFO -------");
    logger.warn("access_token : {}", accessTokenParameter);

    Map<String, Object> result = null;
    if (accessTokenParameter.contains("error")) {
        result = buildErrorResult();
    } else if (accessTokenParameter.contains("no-uid")) {
        result = buildAccessToken(accessTokenParameter);
        result.remove("uid");
        ((List<String>) result.get("scope")).remove("uid");
    } else if (accessTokenParameter.contains("empty-uid")) {
        result = buildAccessToken(accessTokenParameter);
        result.put("uid", "");
    } else if (accessTokenParameter.contains("no-scope")) {
        result = buildAccessToken(accessTokenParameter);
        result.remove("scope");
    } else if (accessTokenParameter.contains("lax")) {
        result = buildAccessToken(accessTokenParameter);
        result.remove("testscope");
        result.remove("simpleScope");
    } else if (accessTokenParameter.contains("lax-with-false")) {
        result = buildAccessToken(accessTokenParameter);
        result.put("testscope", Boolean.FALSE);
        result.put("simpleScope", Boolean.FALSE);
    } else {
        result = buildAccessToken(accessTokenParameter);
    }

    return result;
}

From source file:com.glaf.report.web.springmvc.MxReportFileController.java

@RequestMapping("/save")
public ModelAndView save(HttpServletRequest request, ModelMap modelMap) {
    LoginContext loginContext = RequestUtils.getLoginContext(request);
    String actorId = loginContext.getActorId();
    Map<String, Object> params = RequestUtils.getParameterMap(request);
    params.put("actorId", actorId);
    params.put("createBy", actorId);
    params.remove("status");
    params.remove("wfStatus");
    ReportFile reportFile = new ReportFile();
    Tools.populate(reportFile, params);//from   w w  w. j  a va2s. com
    // reportFile.setCreateBy(actorId);

    reportFileService.save(reportFile);

    return this.list(request, modelMap);
}

From source file:com.baomidou.mybatisplus.spring.MybatisMapperRefresh.java

/**
 * mapper//from  www  .  j  a v a  2  s. co  m
 * 
 * @throws Exception
 */
@SuppressWarnings("rawtypes")
private void refresh(Resource resource) throws Exception {
    this.configuration = sqlSessionFactory.getConfiguration();
    boolean isSupper = configuration.getClass().getSuperclass() == Configuration.class;
    try {
        Field loadedResourcesField = isSupper
                ? configuration.getClass().getSuperclass().getDeclaredField("loadedResources")
                : configuration.getClass().getDeclaredField("loadedResources");
        loadedResourcesField.setAccessible(true);
        Set loadedResourcesSet = ((Set) loadedResourcesField.get(configuration));
        XPathParser xPathParser = new XPathParser(resource.getInputStream(), true, configuration.getVariables(),
                new XMLMapperEntityResolver());
        XNode context = xPathParser.evalNode("/mapper");
        String namespace = context.getStringAttribute("namespace");
        Field field = MapperRegistry.class.getDeclaredField("knownMappers");
        field.setAccessible(true);
        Map mapConfig = (Map) field.get(configuration.getMapperRegistry());
        mapConfig.remove(Resources.classForName(namespace));
        loadedResourcesSet.remove(resource.toString());
        configuration.getCacheNames().remove(namespace);
        cleanParameterMap(context.evalNodes("/mapper/parameterMap"), namespace);
        cleanResultMap(context.evalNodes("/mapper/resultMap"), namespace);
        cleanKeyGenerators(context.evalNodes("insert|update"), namespace);
        cleanSqlElement(context.evalNodes("/mapper/sql"), namespace);
        XMLMapperBuilder xmlMapperBuilder = new XMLMapperBuilder(resource.getInputStream(),
                sqlSessionFactory.getConfiguration(), // sql??
                resource.toString(), sqlSessionFactory.getConfiguration().getSqlFragments());
        xmlMapperBuilder.parse();
        logger.debug("refresh:" + resource + ",success!");
    } catch (Exception e) {
        throw new NestedIOException("Failed to parse mapping resource: '" + resource + "'", e);
    } finally {
        ErrorContext.instance().reset();
    }
}

From source file:monasca.api.infrastructure.persistence.influxdb.InfluxV9Utils.java

Map<String, String> filterPrivateTags(Map<String, String> tagMap) {

    Map<String, String> filteredMap = new HashMap<>(tagMap);

    filteredMap.remove("_tenant_id");
    filteredMap.remove("_region");

    return filteredMap;
}