Example usage for org.springframework.util MultiValueMap keySet

List of usage examples for org.springframework.util MultiValueMap keySet

Introduction

In this page you can find the example usage for org.springframework.util MultiValueMap keySet.

Prototype

Set<K> keySet();

Source Link

Document

Returns a Set view of the keys contained in this map.

Usage

From source file:com.svds.resttest.operator.BuildWhereClause.java

/**
 * Create a WHERE clause given parameters from GET request
 * /*from w ww .  jav  a 2  s  . co m*/
 * @param requestParams query parameters form GET request
 * @return SQL WHERE clause
 * @throws BuildWhereException 
 */
public static String buildWhereClause(MultiValueMap<String, String> requestParams) throws BuildWhereException {

    Set<String> columnNames = new HashSet<>();
    for (String key : requestParams.keySet()) {
        for (String value : requestParams.get(key)) {
            LOG.info("key:" + key + "  :  value:" + value);
        }
        if (key.startsWith(COLUMN_TAG)) {
            LOG.info("key - substr: " + key.substring(8));

            columnNames.add(key.substring(8));
        }
    }

    StringBuilder whereClause = new StringBuilder();

    for (String value : columnNames) {
        LOG.info("Column Name: " + value);
        LOG.info("Got this operator: " + requestParams.containsKey(OPERATOR_TAG + value));
        LOG.info("Got this operator - value: " + requestParams.getFirst(OPERATOR_TAG + value));
        LOG.info("Got this column: " + requestParams.containsKey(COLUMN_TAG + value));
        LOG.info("Got this column - value: " + requestParams.get(COLUMN_TAG + value));

        try {
            String operatorValue = requestParams.getFirst(OPERATOR_TAG + value);
            Operator operator = OperatorFactory.getOperatorClass(operatorValue);
            String operatorProcessValue;
            operatorProcessValue = operator.process(value, requestParams.get(COLUMN_TAG + value));
            whereClause.append(operatorProcessValue).append(AND);
        } catch (OperatorsException ex) {
            LOG.error("OperatorException: " + ex.getMessage(), ex);
            throw new BuildWhereException(ex);
        }

    }

    LOG.info("Value whereClause: " + whereClause);

    String returnValue = whereClause.substring(0, whereClause.lastIndexOf(AND));
    LOG.info("WhereClause: " + returnValue);
    return returnValue;
}

From source file:de.zib.gndms.common.rest.GNDMSResponseHeader.java

public static Map<String, MyProxyToken> extractTokenFromMap(final MultiValueMap<String, String> context) {

    Map<String, MyProxyToken> result = new HashMap<String, MyProxyToken>(1);
    for (String key : context.keySet()) {
        if (isMyProxyLoginEntryKey(key)) {
            String purpose = extractPurposeFromLoginKey(key);
            MyProxyToken token = new MyProxyToken(extractLoginName(context, key));
            if (hasPasswordKeyForPurpose(context, purpose))
                token.setPassword(extractPasswordForPurpose(context, purpose));
            if (hasFetchMethodKeyForPurpose(context, purpose))
                token.setFetchMethod(extractFetchMethodForPurpose(context, purpose));

            // TODO: build uppercase purpose here? problem with tomcat 6: changes case of headers to lowercase
            result.put(purpose, token);//  ww w .j  a v a  2 s . c  om
        }
    }
    return Collections.unmodifiableMap(result);
}

From source file:com.expedia.seiso.web.hateoas.link.RepoSearchLinks.java

private String toQueryString(MultiValueMap<String, String> params) {
    val paramNames = new ArrayList<String>(params.keySet());
    Collections.sort(paramNames);

    val builder = new StringBuilder();
    boolean first = true;
    for (val paramName : paramNames) {
        if (!first) {
            builder.append("&");
        }/*w ww . j  ava  2s .c  o  m*/
        builder.append(paramName);
        builder.append("=");

        // FIXME The responsibility for formatting template variables belongs here, not with the clients. [WLW]
        builder.append(params.getFirst(paramName));

        first = false;
    }

    return builder.toString();
}

From source file:ch.rasc.wampspring.config.WebMvcWampEndpointRegistry.java

/**
 * Return a handler mapping with the mapped ViewControllers; or {@code null} in case
 * of no registrations./*w ww  .j  a va 2s  .  c o  m*/
 */
public AbstractHandlerMapping getHandlerMapping() {
    Map<String, Object> urlMap = new LinkedHashMap<>();
    for (WebMvcWampWebSocketEndpointRegistration registration : this.registrations) {
        MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
        for (HttpRequestHandler httpHandler : mappings.keySet()) {
            for (String pattern : mappings.get(httpHandler)) {
                urlMap.put(pattern, httpHandler);
            }
        }
    }
    SimpleUrlHandlerMapping hm = new SimpleUrlHandlerMapping();
    hm.setUrlMap(urlMap);
    hm.setOrder(this.order);
    if (this.urlPathHelper != null) {
        hm.setUrlPathHelper(this.urlPathHelper);
    }
    return hm;
}

From source file:io.kahu.hawaii.util.logger.RequestLogBuilder.java

public RequestLogBuilder formParams(MultiValueMap<String, String> map) {
    Assert.notNull(map);//from w  ww .j a  v a2  s.c  om
    try {
        for (String name : map.keySet()) {
            List<String> values = map.get(name);
            if (values.size() != 0) {
                this.params.put(name, new JSONArray(values));
            }
        }
    } catch (JSONException cant_happen) {
        //
    }
    return this;
}

From source file:io.neba.core.mvc.MultipartSlingHttpServletRequestTest.java

private void assertMultiFileMapHasEntries(Object... fileNames) {
    MultiValueMap<String, MultipartFile> multiFileMap = this.testee.getMultiFileMap();
    assertThat(multiFileMap).isNotNull();
    assertThat(multiFileMap.keySet()).containsOnly(fileNames);
    assertThat((Object) null).isNotIn(multiFileMap.values());
}

From source file:org.unidle.social.ConnectionRepositoryImpl.java

@Override
@Transactional(readOnly = true)/* w w  w  .j  av  a 2s . c  om*/
public MultiValueMap<String, Connection<?>> findConnectionsToUsers(
        final MultiValueMap<String, String> providerUserIds) {

    final MultiValueMap<String, Connection<?>> connections = new LinkedMultiValueMap<>();

    for (final String providerId : providerUserIds.keySet()) {

        final List<String> singleProviderUserIds = providerUserIds.get(providerId);
        final List<UserConnection> userConnections = userConnectionRepository.findAll(user, providerId,
                singleProviderUserIds);

        for (final String providerUserId : singleProviderUserIds) {

            UserConnection userConnection = null;
            for (UserConnection candidateUserConnection : userConnections) {
                if (providerUserId.equals(candidateUserConnection.getProviderUserId())) {
                    userConnection = candidateUserConnection;
                    break;
                }
            }

            connections.add(providerId,
                    Functions.toConnection(connectionFactoryLocator, textEncryptor).apply(userConnection));
        }

    }

    return connections;
}

From source file:de.codecentric.boot.admin.zuul.filters.route.SimpleHostRoutingFilter.java

private Header[] convertHeaders(MultiValueMap<String, String> headers) {
    List<Header> list = new ArrayList<>();
    for (String name : headers.keySet()) {
        for (String value : headers.get(name)) {
            list.add(new BasicHeader(name, value));
        }/*from  w  w  w. j a va  2  s . com*/
    }
    return list.toArray(new BasicHeader[0]);
}

From source file:net.acesinc.convergentui.content.ContentFetchCommand.java

@Override
protected ContentResponse run() throws Exception {
    log.debug("Getting live content from [ " + location + " ]");
    try {/* w w  w. j  a  va2  s.c o m*/
        HttpServletRequest request = requestContext.getRequest();
        MultiValueMap<String, String> headers = this.helper.buildZuulRequestHeaders(request);

        if (request.getQueryString() != null && !request.getQueryString().isEmpty()) {
            MultiValueMap<String, String> params = this.helper.buildZuulRequestQueryParams(request);
        }

        HttpHeaders requestHeaders = new HttpHeaders();
        for (String key : headers.keySet()) {
            for (String s : headers.get(key)) {
                requestHeaders.add(key, s);
            }
        }
        HttpEntity requestEntity = new HttpEntity(null, requestHeaders);

        ResponseEntity<Object> exchange = this.restTemplate.exchange(location, HttpMethod.GET, requestEntity,
                Object.class);

        ContentResponse response = new ContentResponse();
        response.setContent(exchange.getBody());
        response.setContentType(exchange.getHeaders().getContentType());
        response.setError(false);

        return response;
    } catch (Exception e) {
        log.debug("Error fetching live content from [ " + location + " ]", e);
        throw e;
    }
}

From source file:jails.http.converter.FormHttpMessageConverter.java

private boolean isMultipart(MultiValueMap<String, ?> map, MediaType contentType) {
    if (contentType != null) {
        return MediaType.MULTIPART_FORM_DATA.equals(contentType);
    }/*from   w ww  .j a  v a 2 s  .co m*/
    for (String name : map.keySet()) {
        for (Object value : map.get(name)) {
            if (value != null && !(value instanceof String)) {
                return true;
            }
        }
    }
    return false;
}