Example usage for com.google.common.collect Multimap containsKey

List of usage examples for com.google.common.collect Multimap containsKey

Introduction

In this page you can find the example usage for com.google.common.collect Multimap containsKey.

Prototype

boolean containsKey(@Nullable Object key);

Source Link

Document

Returns true if this multimap contains at least one key-value pair with the key key .

Usage

From source file:org.sonar.server.qualityprofile.ws.InheritanceAction.java

private Long getActiveRuleCount(Multimap<String, FacetValue> profileStats) {
    Long result = null;//  w  ww.ja  va 2  s .c om
    if (profileStats.containsKey(COUNT_ACTIVE_RULES)) {
        result = profileStats.get(COUNT_ACTIVE_RULES).iterator().next().getValue();
    }
    return result;
}

From source file:org.opencms.ui.dialogs.embedded.CmsDataViewParams.java

/**
 * Creates a new instance by parsing the query string of the given URI.<p>
 *
 * @param uri the URI from which to read the configuration
 *//*from ww w.  j  av  a  2  s.  c  o  m*/
public CmsDataViewParams(URI uri) {
    Multimap<String, String> params = CmsRequestUtil.getParameters(uri);
    if (params.containsKey(CmsDataViewConstants.PARAM_CONFIG)) {
        String encodedConfig = params.get(CmsDataViewConstants.PARAM_CONFIG).iterator().next();
        try {
            JSONObject json = new JSONObject(CmsDataViewParamEncoder.decodeString(encodedConfig));

            m_callback = json.optString(CmsDataViewConstants.PARAM_CALLBACK);
            m_callbackArg = json.optString(CmsDataViewConstants.PARAM_CALLBACK_ARG);
            m_viewClass = json.optString(CmsDataViewConstants.CONFIG_VIEW_CLASS);
            m_viewArg = json.optString(CmsDataViewConstants.CONFIG_VIEW_ARG);
            m_multiSelect = json.optString(CmsDataViewConstants.CONFIG_MULTI_SELECT);
        } catch (JSONException e) {
            LOG.error(e.getLocalizedMessage(), e);
        }
    }
}

From source file:org.sonar.server.qualityprofile.ws.InheritanceAction.java

private Long getOverridingRuleCount(Multimap<String, FacetValue> profileStats) {
    Long result = null;//from w  w w  .j a v  a 2  s .c  om
    if (profileStats.containsKey(RuleIndexDefinition.FIELD_ACTIVE_RULE_INHERITANCE)) {
        for (FacetValue value : profileStats.get(RuleIndexDefinition.FIELD_ACTIVE_RULE_INHERITANCE)) {
            if ("OVERRIDES".equals(value.getKey())) {
                result = value.getValue();
            }
        }
    }
    return result;
}

From source file:org.sonar.server.qualityprofile.ws.QProfileInheritanceAction.java

private Long getActiveRuleCount(Multimap<String, FacetValue> profileStats) {
    Long result = null;/*from   w ww. j  ava2 s  . com*/
    if (profileStats.containsKey("countActiveRules")) {
        result = profileStats.get("countActiveRules").iterator().next().getValue();
    }
    return result;
}

From source file:org.sonar.server.qualityprofile.ws.QProfileInheritanceAction.java

private Long getOverridingRuleCount(Multimap<String, FacetValue> profileStats) {
    Long result = null;//from w  w  w  .  j a v a 2  s.  co m
    if (profileStats.containsKey("inheritance")) {
        for (FacetValue value : profileStats.get("inheritance")) {
            if ("OVERRIDES".equals(value.getKey())) {
                result = value.getValue();
            }
        }
    }
    return result;
}

From source file:org.eclipse.xtext.util.formallang.CfgUtil.java

protected <E, T> void getCallers(Cfg<E, T> cfg, E root, Multimap<E, E> callers) {
    for (E call : new ProductionUtil().getAllChildren(cfg, root)) {
        E called = cfg.getCall(call);//from w  ww .  jav a  2  s  . c om
        if (called != null) {
            boolean contained = callers.containsKey(called) || called == cfg.getRoot();
            callers.put(called, call);
            if (!contained)
                getCallers(cfg, called, callers);
        }
    }
}

From source file:org.jclouds.openstack.keystone.auth.handlers.RetryOnRenew.java

@Override
public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) {
    boolean retry = false; // default
    switch (response.getStatusCode()) {
    case 401:/*  w  ww.j  a va2s  .  co m*/
        // Do not retry on 401 from authentication request
        Multimap<String, String> headers = command.getCurrentRequest().getHeaders();
        if (headers != null && headers.containsKey(AuthHeaders.AUTH_USER)
                && headers.containsKey(AuthHeaders.AUTH_KEY) && !headers.containsKey(AuthHeaders.AUTH_TOKEN)) {
            retry = false;
        } else {
            // This is not an authentication request returning 401
            // Check if we already had seen this request
            Integer count = retryCountMap.getIfPresent(command);

            if (count == null) {
                // First time this non-authentication request failed
                logger.debug("invalidating authentication token - first time for %s", command);
                retryCountMap.put(command, 1);
                authenticationResponseCache.invalidateAll();
                retry = true;
            } else {
                // This request has failed before
                if (count + 1 >= NUM_RETRIES) {
                    logger.debug("too many 401s - giving up after: %s for %s", count, command);
                    retry = false;
                } else {
                    // Retry just in case
                    logger.debug("invalidating authentication token - retry %s for %s", count, command);
                    retryCountMap.put(command, count + 1);
                    // Wait between retries
                    authenticationResponseCache.invalidateAll();
                    Uninterruptibles.sleepUninterruptibly(5, TimeUnit.SECONDS);
                    retry = true;
                }
            }
        }
        break;
    case 408:
        return backoffHandler.shouldRetryRequest(command, response);
    }
    return retry;
}

From source file:org.apache.flex.compiler.internal.as.codegen.LabelScopeControlFlowContext.java

@Override
boolean hasGotoLabel(String label, boolean allowDuplicates) {
    Multimap<String, LabeledStatementNode> labelMap = getLabelMap();
    if (allowDuplicates)
        return labelMap.containsKey(label);
    else/*from  www .  ja v a  2  s. c  o m*/
        return labelMap.get(label).size() == 1;
}

From source file:brooklyn.location.jclouds.config.AlwaysRetryOnRenew.java

@Override
public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) {
    boolean retry = false; // default
    try {//from   w  w  w . ja va  2  s. c o m
        switch (response.getStatusCode()) {
        case 401:
            // Do not retry on 401 from authentication request
            Multimap<String, String> headers = command.getCurrentRequest().getHeaders();
            if (headers != null && headers.containsKey(AuthHeaders.AUTH_USER)
                    && headers.containsKey(AuthHeaders.AUTH_KEY)
                    && !headers.containsKey(AuthHeaders.AUTH_TOKEN)) {
                retry = false;
            } else {
                closeClientButKeepContentStream(response);
                authenticationResponseCache.invalidateAll();
                retry = true;

                // always retry. not all swift servers say 'lease renew', e.g. softlayer

                //                  byte[] content = closeClientButKeepContentStream(response);
                //                  if (content != null && new String(content).contains("lease renew")) {
                //                     logger.debug("invalidating authentication token");
                //                     authenticationResponseCache.invalidateAll();
                //                     retry = true;
                //                  } else {
                //                     retry = false;
                //                  }
            }
            break;
        }
        return retry;

    } finally {
        releasePayload(response);
    }
}

From source file:org.opencms.ui.actions.CmsUserInfoDialogAction.java

/**
 * @see org.opencms.ui.actions.I_CmsWorkplaceAction#executeAction(org.opencms.ui.I_CmsDialogContext)
 *//*  ww  w.  ja v  a2 s.c  o  m*/
public void executeAction(final I_CmsDialogContext context) {

    CmsUserInfo dialog = new CmsUserInfo(new I_UploadListener() {

        public void onUploadFinished(List<String> uploadedFiles) {

            handleUpload(uploadedFiles, context);
        }
    }, context);
    Multimap<String, String> params = A_CmsUI.get().getParameters();
    int top = 55;
    int left = 0;
    if (params.containsKey("left")) {
        String buttonLeft = params.get("left").iterator().next();
        left = Integer.parseInt(buttonLeft) - 290;
    }
    final Window window = new Window();
    window.setModal(false);
    window.setClosable(true);
    window.setResizable(false);
    window.setContent(dialog);
    context.setWindow(window);
    window.addStyleName(OpenCmsTheme.DROPDOWN);
    UI.getCurrent().addWindow(window);
    window.setPosition(left, top);
}