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:guru.qas.martini.scope.ScenarioScope.java

@Override
public Object remove(@Nonnull String name) {
    Map<String, Object> scope = SCOPE_REF.get();
    return scope.remove(name);
}

From source file:no.imr.common.security.jwt.DefaultAccessTokenConverter.java

public OAuth2AccessToken extractAccessToken(String value, Map<String, ?> map) {
    DefaultOAuth2AccessToken token = new DefaultOAuth2AccessToken(value);
    Map<String, Object> info = new HashMap<String, Object>(map);
    info.remove(EXP);
    info.remove(AUD);//from w w w. j  a v a2  s .  co m
    info.remove(CLIENT_ID);
    info.remove(SCOPE);
    if (map.containsKey(EXP)) {
        token.setExpiration(new Date((Long) map.get(EXP) * 1000L));
    }
    if (map.containsKey(JTI)) {
        info.put(JTI, map.get(JTI));
    }
    @SuppressWarnings("unchecked")
    Collection<String> scope = (Collection<String>) map.get(SCOPE);
    if (scope != null) {
        token.setScope(new HashSet<String>(scope));
    }
    token.setAdditionalInformation(info);
    return token;
}

From source file:com.liferay.portal.util.PortalUtil.java

public static void destroyPortletConfig(Portlet portlet) {
    String scpId = PortalUtil.class.getName() + "." + PortletConfig.class.getName();
    if (!portlet.isWARFile()) {
        scpId += "." + portlet.getCompanyId();
    }/*from   ww w .ja  v  a 2s .co  m*/

    Map map = (Map) SimpleCachePool.get(scpId);

    if (map == null) {
        return;
    }

    map.remove(portlet.getPortletId());
}

From source file:com.liferay.portal.util.PortalUtil.java

public static void destroyPortletContext(Portlet portlet) {
    String scpId = PortalUtil.class.getName() + "." + PortletContext.class.getName();
    if (!portlet.isWARFile()) {
        scpId += "." + portlet.getCompanyId();
    }//from w w  w. j ava  2  s.  c  o  m

    Map map = (Map) SimpleCachePool.get(scpId);

    if (map == null) {
        return;
    }

    map.remove(portlet.getPortletId());
}

From source file:com.bstek.dorado.idesupport.parse.ChildTemplateParser.java

@Override
protected Object doParse(Node node, ParseContext context) throws Exception {
    Element element = (Element) node;
    ConfigRuleParseContext parserContext = (ConfigRuleParseContext) context;

    Map<String, Object> properties = this.parseProperties(element, context);
    String name = (String) properties.remove("name");

    RuleTemplate ruleTemplate;//w  ww.j  a v a  2 s .c o m
    String ruleName = (String) properties.remove("rule");
    if (StringUtils.isNotEmpty(ruleName)) {
        ruleTemplate = globalRuleTemplateParser.getRuleTemplate(ruleName, parserContext);
        if (ruleTemplate == null) {
            throw new XmlParseException("Unknown Rule [" + ruleName + "].", node, context);
        }
    } else {
        List<Element> childElements = DomUtils.getChildElements(element);
        if (childElements.size() == 1) {
            ruleTemplate = (RuleTemplate) ruleTemplateParser.parse(childElements.get(0), parserContext);
            ruleName = ruleTemplate.getNodeName();
            if (StringUtils.isEmpty(ruleName)) {
                ruleName = ruleTemplate.getName();
            }
        } else {
            throw new XmlParseException("Rule undefined.", element, context);
        }
    }
    properties.put("ruleTemplate", ruleTemplate);

    if (StringUtils.isEmpty(name)) {
        name = ruleName;
    }

    ChildTemplate child = new ChildTemplate(name);

    String clientTypesText = (String) properties.remove("clientTypes");
    int clientTypes = ClientType.parseClientTypes(clientTypesText);
    if (clientTypes > 0) {
        child.setClientTypes(clientTypes);
    }

    BeanUtils.copyProperties(child, properties);
    return child;
}

From source file:com.asakusafw.runtime.directio.hadoop.HadoopDataSourceUtil.java

/**
 * Loads a profile list from the configuration.
 * @param conf target configuration/*  w  w  w .j av a  2s  .  c o  m*/
 * @return the restored profile list
 * @throws IllegalArgumentException if some parameters were {@code null}
 */
public static List<DirectDataSourceProfile> loadProfiles(Configuration conf) {
    if (conf == null) {
        throw new IllegalArgumentException("conf must not be null"); //$NON-NLS-1$
    }
    Map<String, String> pathToKey = new HashMap<>();
    Map<String, String> map = getConfigMap(conf);
    Set<String> keys = getChildKeys(map, "."); //$NON-NLS-1$
    try {
        List<DirectDataSourceProfile> results = new ArrayList<>();
        for (String key : keys) {
            String className = map.get(key);
            Map<String, String> config = createPrefixMap(map, key + "."); //$NON-NLS-1$
            String path = config.remove(KEY_PATH);
            if (path == null) {
                throw new IllegalStateException(
                        MessageFormat.format("Missing I/O configuration: {0}", PREFIX + key + '.' + KEY_PATH));
            }
            path = normalizePath(path);
            if (pathToKey.containsKey(path)) {
                throw new IllegalStateException(MessageFormat.format(
                        "Path mapping is duplicated: {0} ({1} <=> {2})", path.isEmpty() ? "/" : path, //$NON-NLS-2$
                        PREFIX + key + '.' + KEY_PATH, PREFIX + pathToKey.get(key) + '.' + KEY_PATH));
            } else {
                pathToKey.put(path, key);
            }
            Class<? extends AbstractDirectDataSource> aClass = conf.getClassByName(className)
                    .asSubclass(AbstractDirectDataSource.class);
            results.add(new DirectDataSourceProfile(key, aClass, path, config));
        }
        return results;
    } catch (ClassNotFoundException e) {
        throw new IllegalStateException(e);
    }
}

From source file:com.glaf.core.util.RequestUtils.java

public static String getRequestParameters(HttpServletRequest request) {
    Map<String, Object> m = getParameterMap(request);
    m.remove("x");
    m.remove("y");
    m.remove("redirectUrl");
    return createQueryStringFromMap(m, "&").toString();
}

From source file:de.hybris.platform.addonsupport.setup.impl.DefaultSetupImpexAddOnService.java

@Override
public boolean importImpexFile(final String file, final ImpexMacroParameterData macroParameters,
        final boolean errorIfMissing, final boolean legacyMode) {

    final Map val;
    try {//  w w  w.  jav a2s.  c o  m
        val = BeanUtils.describe(macroParameters);
        val.remove("additionalParameterMap");
    } catch (final Exception e) {
        throw new IllegalArgumentException("failed to introspect macroparameters", e);
    }
    final Map mergedMap = new HashMap<String, String>();
    mergedMap.putAll(val);
    if (macroParameters.getAdditionalParameterMap() != null) {
        mergedMap.putAll(macroParameters.getAdditionalParameterMap());
    }
    return importImpexFile(file, mergedMap, errorIfMissing, legacyMode);

}

From source file:au.com.jwatmuff.genericdb.cache.CachingDatabase.java

@Override
@SuppressWarnings("unchecked")
public <T> void delete(T item) {
    clearQueryCaches();//from w  ww.j a va  2s . c o m
    database.update(item);
    if (item instanceof Distributable) {
        Distributable d = (Distributable) item;
        Map<Object, T> cache = (Map<Object, T>) getCache(item.getClass());
        cache.remove(d.getID());
    }
}

From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration.java

public static void clearEditConfigurationInSession(HttpSession session, EditConfiguration editConfig) {
    if (session == null || editConfig == null)
        return;/*from w w  w  .  jav a2s  .c o  m*/
    Map<String, EditConfiguration> configs = (Map<String, EditConfiguration>) session
            .getAttribute("EditConfigurations");
    if (configs == null)
        return;
    if (configs.containsKey(editConfig.editKey))
        configs.remove(editConfig.editKey);
}