Example usage for org.springframework.util MultiValueMap get

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

Introduction

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

Prototype

V get(Object key);

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:org.kuali.rice.kew.doctype.service.impl.DocumentSecurityServiceImpl.java

protected void processDocumentRequiringExtensionProcessing(List<Document> documentsRequiringExtensionProcessing,
        SecuritySession securitySession, Set<String> authorizations) {
    if (CollectionUtils.isNotEmpty(documentsRequiringExtensionProcessing)) {
        LOG.info("Beginning processing of documents requiring extension processing (total: "
                + documentsRequiringExtensionProcessing.size() + " documents)");
        long start = System.currentTimeMillis();
        MultiValueMap<PartitionKey, Document> partitions = partitionDocumentsForSecurity(
                documentsRequiringExtensionProcessing, securitySession);
        MultiValueMap<String, DocumentSecurityDirective> applicationSecurityDirectives = new LinkedMultiValueMap<String, DocumentSecurityDirective>();
        for (PartitionKey partitionKey : partitions.keySet()) {
            DocumentSecurityDirective directive = DocumentSecurityDirective
                    .create(partitionKey.getDocumentSecurityAttributeNameList(), partitions.get(partitionKey));
            applicationSecurityDirectives.add(partitionKey.applicationId, directive);
        }//w  w w .  j  a  v  a2 s .co m
        for (String applicationId : applicationSecurityDirectives.keySet()) {
            List<DocumentSecurityDirective> documentSecurityDirectives = applicationSecurityDirectives
                    .get(applicationId);
            DocumentSecurityHandlerService securityHandler = loadSecurityHandler(applicationId);
            List<String> authorizedDocumentIds = securityHandler
                    .getAuthorizedDocumentIds(securitySession.getPrincipalId(), documentSecurityDirectives);
            if (CollectionUtils.isNotEmpty(authorizedDocumentIds)) {
                authorizations.addAll(authorizedDocumentIds);
            }
        }
        long end = System.currentTimeMillis();
        LOG.info("Finished processing of documents requiring extension processing (total time: " + (start - end)
                + ")");
    }
}

From source file:org.kuali.rice.kew.doctype.service.impl.DocumentSecurityServiceImpl.java

protected MultiValueMap<PartitionKey, Document> partitionDocumentsForSecurity(List<Document> documents,
        SecuritySession securitySession) {
    MultiValueMap<PartitionKey, Document> partitions = new LinkedMultiValueMap<PartitionKey, Document>();
    for (Document document : documents) {
        DocumentTypeSecurity security = getDocumentTypeSecurity(document.getDocumentTypeName(),
                securitySession);// w ww .  j a va 2 s. com
        MultiValueMap<String, ExtensionDefinition> securityAttributeExtensionDefinitions = loadExtensionDefinitions(
                security, securitySession);
        for (String applicationId : securityAttributeExtensionDefinitions.keySet()) {
            List<ExtensionDefinition> extensionDefinitions = securityAttributeExtensionDefinitions
                    .get(applicationId);
            PartitionKey key = new PartitionKey(applicationId, extensionDefinitions);
            partitions.add(key, document);
        }
    }
    return partitions;
}

From source file:org.kuali.rice.kim.impl.role.RoleServiceImpl.java

/**
 * Checks each of the result records to determine if there are potentially applicable delegation members for that
 * role membership.  If there are, applicable delegations and members will be linked to the RoleMemberships in the
 * given list.  An updated list will be returned from this method which includes the appropriate linked delegations.
 *//*from   ww  w . j  a v a  2s.  c  o m*/
protected List<RoleMembership.Builder> applyDelegationsToRoleMembers(List<RoleMembership> roleMemberships,
        Collection<DelegateTypeBo> delegations, Map<String, String> qualification) {
    MultiValueMap<String, String> roleIdToRoleMembershipIds = new LinkedMultiValueMap<String, String>();
    Map<String, RoleMembership.Builder> roleMembershipIdToBuilder = new HashMap<String, RoleMembership.Builder>();
    List<RoleMembership.Builder> roleMembershipBuilders = new ArrayList<RoleMembership.Builder>();
    // to make our algorithm less painful, let's do some indexing and load the given list of RoleMemberships into
    // builders
    for (RoleMembership roleMembership : roleMemberships) {
        roleIdToRoleMembershipIds.add(roleMembership.getRoleId(), roleMembership.getId());
        RoleMembership.Builder builder = RoleMembership.Builder.create(roleMembership);
        roleMembershipBuilders.add(builder);
        roleMembershipIdToBuilder.put(roleMembership.getId(), builder);
    }
    for (DelegateTypeBo delegation : delegations) {
        // determine the candidate role memberships where this delegation can be mapped
        List<String> candidateRoleMembershipIds = roleIdToRoleMembershipIds.get(delegation.getRoleId());
        if (CollectionUtils.isNotEmpty(candidateRoleMembershipIds)) {
            DelegationTypeService delegationTypeService = getDelegationTypeService(
                    delegation.getDelegationId());
            for (DelegateMemberBo delegationMember : delegation.getMembers()) {
                // Make sure that the delegation member is active
                if (delegationMember.isActive(DateTime.now()) && (delegationTypeService == null
                        || delegationTypeService.doesDelegationQualifierMatchQualification(qualification,
                                delegationMember.getQualifier()))) {
                    DelegateMember.Builder delegateMemberBuilder = DelegateMember.Builder
                            .create(delegationMember);
                    // if the member has no role member id, check qualifications and apply to all matching role memberships on the role
                    if (StringUtils.isBlank(delegationMember.getRoleMemberId())) {
                        RoleTypeService roleTypeService = getRoleTypeService(delegation.getRoleId());
                        for (String roleMembershipId : candidateRoleMembershipIds) {
                            RoleMembership.Builder roleMembershipBuilder = roleMembershipIdToBuilder
                                    .get(roleMembershipId);
                            if (roleTypeService == null || roleTypeService.doesRoleQualifierMatchQualification(
                                    roleMembershipBuilder.getQualifier(), delegationMember.getQualifier())) {
                                linkDelegateToRoleMembership(delegation, delegateMemberBuilder,
                                        roleMembershipBuilder);
                            }
                        }
                    } else if (candidateRoleMembershipIds.contains(delegationMember.getRoleMemberId())) {
                        RoleMembership.Builder roleMembershipBuilder = roleMembershipIdToBuilder
                                .get(delegationMember.getRoleMemberId());
                        linkDelegateToRoleMembership(delegation, delegateMemberBuilder, roleMembershipBuilder);
                    }
                }
            }
        }
    }
    return roleMembershipBuilders;
}

From source file:org.mule.modules.wechat.WechatConnector.java

/**
 * Verify validity of the URL/* w  w  w  . j  a v  a 2  s .co m*/
 * <br><a href="http://admin.wechat.com/wiki/index.php?title=Getting_Started#Step_2._Verify_validity_of_the_URL">http://admin.wechat.com/wiki/index.php?title=Getting_Started#Step_2._Verify_validity_of_the_URL</a>
 * 
 * @param uri URI sent by WeChat Official Account Admin System
 * @return The developer's backend system should return the echostr parameter value indicating that the request has been successfully received
 * @throws Exception If anything fails
 */
@Processor
public Object verifyUrl(@Default("#[message.inboundProperties.'http.request.uri']") String uri)
        throws Exception {
    String result = "";
    MultiValueMap<String, String> parameters = UriComponentsBuilder.fromUri(new URI(uri)).build()
            .getQueryParams();

    if (parameters.containsKey("timestamp") && parameters.containsKey("nonce")
            && parameters.containsKey("signature")) {
        String[] arr = { config.getToken(), parameters.get("timestamp").get(0),
                parameters.get("nonce").get(0) };
        Arrays.sort(arr);
        String tmpStr = String.join("", arr);
        tmpStr = DigestUtils.sha1Hex(tmpStr);
        if (tmpStr.equals(parameters.get("signature").get(0))) {
            if (parameters.containsKey("echostr")) {
                result = parameters.get("echostr").get(0);
            }
        }
    }

    return result;
}

From source file:org.sparkcommerce.openadmin.web.controller.entity.AdminBasicEntityController.java

/**
 * Renders the main entity listing for the specified class, which is based on the current sectionKey with some optional
 * criteria./*  w w w  .  j  a  va 2  s  . c  om*/
 * 
 * @param request
 * @param response
 * @param model
 * @param pathVars
 * @param criteria a Map of property name -> list critiera values
 * @return the return view path
 * @throws Exception
 */
@RequestMapping(value = "", method = RequestMethod.GET)
public String viewEntityList(HttpServletRequest request, HttpServletResponse response, Model model,
        @PathVariable Map<String, String> pathVars, @RequestParam MultiValueMap<String, String> requestParams)
        throws Exception {
    String sectionKey = getSectionKey(pathVars);
    String sectionClassName = getClassNameForSection(sectionKey);
    List<SectionCrumb> crumbs = getSectionCrumbs(request, null, null);
    PersistencePackageRequest ppr = getSectionPersistencePackageRequest(sectionClassName, requestParams, crumbs,
            pathVars);

    ClassMetadata cmd = service.getClassMetadata(ppr).getDynamicResultSet().getClassMetaData();
    DynamicResultSet drs = service.getRecords(ppr).getDynamicResultSet();

    ListGrid listGrid = formService.buildMainListGrid(drs, cmd, sectionKey, crumbs);
    List<EntityFormAction> mainActions = new ArrayList<EntityFormAction>();
    addAddActionIfAllowed(sectionClassName, cmd, mainActions);

    Field firstField = listGrid.getHeaderFields().iterator().next();
    if (requestParams.containsKey(firstField.getName())) {
        model.addAttribute("mainSearchTerm", requestParams.get(firstField.getName()).get(0));
    }

    extensionManager.getProxy().addAdditionalMainActions(sectionClassName, mainActions);

    model.addAttribute("entityFriendlyName", cmd.getPolymorphicEntities().getFriendlyName());
    model.addAttribute("currentUrl", request.getRequestURL().toString());
    model.addAttribute("listGrid", listGrid);
    model.addAttribute("mainActions", mainActions);
    model.addAttribute("viewType", "entityList");

    setModelAttributes(model, sectionKey);
    return "modules/defaultContainer";
}

From source file:org.springframework.boot.autoconfigure.condition.AbstractOnBeanCondition.java

@SuppressWarnings({ "unchecked", "rawtypes" })
private List<String> collect(MultiValueMap<String, Object> attributes, String key) {
    List<String> collected = new ArrayList<String>();
    List<String[]> valueList = (List) attributes.get(key);
    for (String[] valueArray : valueList) {
        for (String value : valueArray) {
            collected.add(value);//from  ww  w. j a v  a 2 s. c om
        }
    }
    return collected;
}

From source file:org.springframework.boot.autoconfigure.condition.OnClassCondition.java

@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {

    String checking = ConditionLogUtils.getPrefix(logger, metadata);

    MultiValueMap<String, Object> attributes = metadata
            .getAllAnnotationAttributes(ConditionalOnClass.class.getName(), true);
    if (attributes != null) {
        List<String> classNames = new ArrayList<String>();
        collectClassNames(classNames, attributes.get("value"));
        collectClassNames(classNames, attributes.get("name"));
        Assert.isTrue(classNames.size() > 0,
                "@ConditionalOnClass annotations must specify at least one class value");
        for (String className : classNames) {
            if (logger.isDebugEnabled()) {
                logger.debug(checking + "Looking for class: " + className);
            }//from   www. j  av  a 2  s . c o m
            if (!ClassUtils.isPresent(className, context.getClassLoader())) {
                if (logger.isDebugEnabled()) {
                    logger.debug(checking + "Class not found: " + className
                            + " (search terminated with matches=false)");
                }
                return false;
            }
        }
    }
    if (logger.isDebugEnabled()) {
        logger.debug(checking + "Match result is: true");
    }
    return true;
}

From source file:org.springframework.boot.autoconfigure.condition.OnMissingClassCondition.java

@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {

    String checking = ConditionLogUtils.getPrefix(logger, metadata);

    MultiValueMap<String, Object> attributes = metadata
            .getAllAnnotationAttributes(ConditionalOnMissingClass.class.getName(), true);
    if (attributes != null) {
        List<String> classNames = new ArrayList<String>();
        collectClassNames(classNames, attributes.get("value"));
        Assert.isTrue(classNames.size() > 0,
                "@ConditionalOnMissingClass annotations must specify at least one class value");
        for (String className : classNames) {
            if (logger.isDebugEnabled()) {
                logger.debug(checking + "Looking for class: " + className);
            }//w  w  w  . j a va2 s .co  m
            if (ClassUtils.isPresent(className, context.getClassLoader())) {
                if (logger.isDebugEnabled()) {
                    logger.debug(
                            checking + "Found class: " + className + " (search terminated with matches=false)");
                }
                return false;
            }
        }
    }
    if (logger.isDebugEnabled()) {
        logger.debug(checking + "Match result is: true");
    }
    return true;
}

From source file:org.springframework.boot.autoconfigure.condition.OnResourceCondition.java

@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {

    String checking = ConditionLogUtils.getPrefix(logger, metadata);

    MultiValueMap<String, Object> attributes = metadata
            .getAllAnnotationAttributes(ConditionalOnResource.class.getName(), true);
    ResourceLoader loader = context.getResourceLoader() == null ? this.defaultResourceLoader
            : context.getResourceLoader();
    if (attributes != null) {
        List<String> locations = new ArrayList<String>();
        collectValues(locations, attributes.get("resources"));
        Assert.isTrue(locations.size() > 0,
                "@ConditionalOnResource annotations must specify at least one resource location");
        for (String location : locations) {
            if (logger.isDebugEnabled()) {
                logger.debug(checking + "Checking for resource: " + location);
            }/*  w  w w.ja  va  2  s.  c  om*/
            if (!loader.getResource(location).exists()) {
                if (logger.isDebugEnabled()) {
                    logger.debug(checking + "Resource not found: " + location
                            + " (search terminated with matches=false)");
                }
                return false;
            }
        }
    }
    if (logger.isDebugEnabled()) {
        logger.debug(checking + "Match result is: true");
    }
    return true;
}

From source file:org.springframework.cloud.netflix.zuul.filters.ProxyRequestHelper.java

public void setResponse(int status, InputStream entity, MultiValueMap<String, String> headers)
        throws IOException {
    RequestContext context = RequestContext.getCurrentContext();

    RequestContext.getCurrentContext().setResponseStatusCode(status);
    if (entity != null) {
        RequestContext.getCurrentContext().setResponseDataStream(entity);
    }// w w  w  . jav a2 s  .  c o m

    boolean isOriginResponseGzipped = false;

    if (headers.containsKey(CONTENT_ENCODING)) {
        Collection<String> collection = headers.get(CONTENT_ENCODING);
        for (String header : collection) {
            if (HTTPRequestUtils.getInstance().isGzipped(header)) {
                isOriginResponseGzipped = true;
                break;
            }
        }
    }
    context.setResponseGZipped(isOriginResponseGzipped);

    for (Entry<String, List<String>> header : headers.entrySet()) {
        RequestContext ctx = RequestContext.getCurrentContext();
        String name = header.getKey();
        for (String value : header.getValue()) {
            ctx.addOriginResponseHeader(name, value);

            if (name.equalsIgnoreCase("content-length"))
                ctx.setOriginContentLength(value);

            if (isIncludedHeader(name)) {
                ctx.addZuulResponseHeader(name, value);
            }
        }
    }

}