List of usage examples for org.springframework.util MultiValueMap get
V get(Object key);
From source file:eionet.webq.web.controller.cdr.IntegrationWithCDRController.java
/** * Check whether there is no files and only one form available. Adding new files must be allowed. * * @param xmlFiles xml files// w w w .j a va 2 s .c om * @param webForms web forms * @param parameters request parameters * @return true iff only one form, no files and creation of new files allowed. */ private boolean oneWebFormAndNoFilesButNewFileCreationIsAllowed(MultiValueMap<String, XmlFile> xmlFiles, Collection<ProjectFile> webForms, CdrRequest parameters) { if (webForms.size() == 1 && parameters.isNewFormCreationAllowed()) { List<XmlFile> filesForSchema = xmlFiles.get(webForms.iterator().next().getXmlSchema()); if (filesForSchema == null || filesForSchema.size() == 0) { return true; } } return false; }
From source file:fi.helsinki.moodi.integration.moodle.MoodleClient.java
private static String paramsToString(final MultiValueMap<String, String> params) { final StringBuilder sb = new StringBuilder(); for (final String name : params.keySet()) { sb.append(name).append(": ").append(params.get(name)); }/*from w ww .j a va 2 s .c o m*/ return sb.toString(); }
From source file:org.ambraproject.wombat.controller.SearchController.java
/** * Set defaults and performs search for subject area landing page * * @param request HTTP request for browsing subject areas * @param model model that will be passed to the template * @param site site the request originates from * @param params HTTP request params//w w w . java 2 s . com * @param subject the subject area to be search; return all articles if no subject area is provided * @throws IOException */ private void subjectAreaSearch(HttpServletRequest request, Model model, Site site, MultiValueMap<String, String> params, String subject) throws IOException { TaxonomyGraph taxonomyGraph = modelSubjectHierarchy(model, site, subject); String subjectName; if (Strings.isNullOrEmpty(subject)) { params.add("subject", ""); subjectName = "All Subject Areas"; } else { subject = subject.replace("_", " "); params.add("subject", subject); subjectName = taxonomyGraph.getName(subject); } model.addAttribute("subjectName", subjectName); // set defaults for subject area landing page if (isNullOrEmpty(params.get("resultsPerPage"))) { params.add("resultsPerPage", BROWSE_RESULTS_PER_PAGE); } if (isNullOrEmpty(params.get("sortOrder"))) { params.add("sortOrder", "DATE_NEWEST_FIRST"); } if (isNullOrEmpty(params.get("filterJournals"))) { params.add("filterJournals", site.getJournalKey()); } CommonParams commonParams = modelCommonParams(request, model, site, params, false); ArticleSearchQuery.Builder query = ArticleSearchQuery.builder().setQuery("").setSimple(false); commonParams.fill(query); ArticleSearchQuery queryObj = query.build(); Map<String, ?> searchResults = solrSearchApi.search(queryObj, site); model.addAttribute("articles", SolrArticleAdapter.unpackSolrQuery(searchResults)); model.addAttribute("searchResults", solrSearchApi.addArticleLinks(searchResults, request, site, siteSet)); model.addAttribute("page", commonParams.getSingleParam(params, "page", "1")); model.addAttribute("journalKey", site.getKey()); model.addAttribute("isBrowse", true); String authId = request.getRemoteUser(); boolean subscribed = false; if (authId != null) { String subjectParam = Strings.isNullOrEmpty(subject) ? "" : subjectName; subscribed = alertService.isUserSubscribed(authId, site.getJournalKey(), subjectParam); } model.addAttribute("subscribed", subscribed); }
From source file:org.broadleafcommerce.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./*from ww w .j a v a 2s .c o m*/ * * @param request * @param response * @param model * @param pathVars * @param requestParams 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); extensionManager.getProxy().addAdditionalMainActions(sectionClassName, mainActions); extensionManager.getProxy().modifyMainActions(cmd, mainActions); Field firstField = listGrid.getHeaderFields().iterator().next(); if (requestParams.containsKey(firstField.getName())) { model.addAttribute("mainSearchTerm", requestParams.get(firstField.getName()).get(0)); } // If this came from a delete save, we'll have a headerFlash request parameter to take care of if (requestParams.containsKey("headerFlash")) { model.addAttribute("headerFlash", requestParams.get("headerFlash").get(0)); } 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.broadleafcommerce.openadmin.web.controller.entity.AdminBasicEntityController.java
/** * Shows the modal dialog that is used to add an item to a given collection. There are several possible outcomes * of this call depending on the type of the specified collection field. * // ww w .j a v a 2s.c o m * <ul> * <li> * <b>Basic Collection (Persist)</b> - Renders a blank form for the specified target entity so that the user may * enter information and associate the record with this collection. Used by fields such as ProductAttribute. * </li> * <li> * <b>Basic Collection (Lookup)</b> - Renders a list grid that allows the user to click on an entity and select it. * Used by fields such as "allParentCategories". * </li> * <li> * <b>Adorned Collection (without form)</b> - Renders a list grid that allows the user to click on an entity and * select it. The view rendered by this is identical to basic collection (lookup), but will perform the operation * on an adorned field, which may carry extra meta-information about the created relationship, such as order. * </li> * <li> * <b>Adorned Collection (with form)</b> - Renders a list grid that allows the user to click on an entity and * select it. Once the user selects the entity, he will be presented with an empty form based on the specified * "maintainedAdornedTargetFields" for this field. Used by fields such as "crossSellProducts", which in addition * to linking an entity, provide extra fields, such as a promotional message. * </li> * <li> * <b>Map Collection</b> - Renders a form for the target entity that has an additional key field. This field is * populated either from the configured map keys, or as a result of a lookup in the case of a key based on another * entity. Used by fields such as the mediaMap on a Sku. * </li> * * @param request * @param response * @param model * @param pathVars * @param id * @param collectionField * @param requestParams * @return the return view path * @throws Exception */ @RequestMapping(value = "/{id}/{collectionField:.*}/add", method = RequestMethod.GET) public String showAddCollectionItem(HttpServletRequest request, HttpServletResponse response, Model model, @PathVariable Map<String, String> pathVars, @PathVariable(value = "id") String id, @PathVariable(value = "collectionField") String collectionField, @RequestParam MultiValueMap<String, String> requestParams) throws Exception { String sectionKey = getSectionKey(pathVars); String mainClassName = getClassNameForSection(sectionKey); List<SectionCrumb> sectionCrumbs = getSectionCrumbs(request, sectionKey, id); ClassMetadata mainMetadata = service .getClassMetadata(getSectionPersistencePackageRequest(mainClassName, sectionCrumbs, pathVars)) .getDynamicResultSet().getClassMetaData(); Property collectionProperty = mainMetadata.getPMap().get(collectionField); FieldMetadata md = collectionProperty.getMetadata(); PersistencePackageRequest ppr = PersistencePackageRequest.fromMetadata(md, sectionCrumbs) .withFilterAndSortCriteria(getCriteria(requestParams)).withStartIndex(getStartIndex(requestParams)) .withMaxIndex(getMaxIndex(requestParams)); if (md instanceof BasicCollectionMetadata) { BasicCollectionMetadata fmd = (BasicCollectionMetadata) md; if (fmd.getAddMethodType().equals(AddMethodType.PERSIST)) { ClassMetadata cmd = service.getClassMetadata(ppr).getDynamicResultSet().getClassMetaData(); // If the entity type isn't specified, we need to determine if there are various polymorphic types // for this entity. String entityType = null; if (requestParams.containsKey("entityType")) { entityType = requestParams.get("entityType").get(0); } if (StringUtils.isBlank(entityType)) { if (cmd.getPolymorphicEntities().getChildren().length == 0) { entityType = cmd.getPolymorphicEntities().getFullyQualifiedClassname(); } else { entityType = getDefaultEntityType(); } } else { entityType = URLDecoder.decode(entityType, "UTF-8"); } if (StringUtils.isBlank(entityType)) { List<ClassTree> entityTypes = getAddEntityTypes(cmd.getPolymorphicEntities()); model.addAttribute("entityTypes", entityTypes); model.addAttribute("viewType", "modal/entityTypeSelection"); model.addAttribute("entityFriendlyName", cmd.getPolymorphicEntities().getFriendlyName()); String requestUri = request.getRequestURI(); if (!request.getContextPath().equals("/") && requestUri.startsWith(request.getContextPath())) { requestUri = requestUri.substring(request.getContextPath().length() + 1, requestUri.length()); } model.addAttribute("currentUri", requestUri); model.addAttribute("modalHeaderType", "addEntity"); setModelAttributes(model, sectionKey); return "modules/modalContainer"; } else { ppr = ppr.withCeilingEntityClassname(entityType); } } } //service.getContextSpecificRelationshipId(mainMetadata, entity, prefix); model.addAttribute("currentParams", new ObjectMapper().writeValueAsString(requestParams)); return buildAddCollectionItemModel(request, response, model, id, collectionField, sectionKey, collectionProperty, md, ppr, null, null); }
From source file:org.cloudfoundry.identity.uaa.authentication.manager.LdapLoginAuthenticationManager.java
@Override protected MultiValueMap<String, String> getUserAttributes(UserDetails request) { MultiValueMap<String, String> result = super.getUserAttributes(request); logger.debug(String.format("Mapping custom attributes for origin:%s and zone:%s", getOrigin(), IdentityZoneHolder.get().getId())); if (getProviderProvisioning() != null) { IdentityProvider provider = getProviderProvisioning().retrieveByOrigin(getOrigin(), IdentityZoneHolder.get().getId()); if (request instanceof ExtendedLdapUserDetails) { ExtendedLdapUserDetails ldapDetails = ((ExtendedLdapUserDetails) request); LdapIdentityProviderDefinition ldapIdentityProviderDefinition = ObjectUtils .castInstance(provider.getConfig(), LdapIdentityProviderDefinition.class); Map<String, Object> providerMappings = ldapIdentityProviderDefinition.getAttributeMappings(); for (Map.Entry<String, Object> entry : providerMappings.entrySet()) { if (entry.getKey().startsWith(USER_ATTRIBUTE_PREFIX) && entry.getValue() != null) { String key = entry.getKey().substring(USER_ATTRIBUTE_PREFIX.length()); String[] values = ldapDetails.getAttribute((String) entry.getValue(), false); if (values != null && values.length > 0) { result.put(key, Arrays.asList(values)); logger.debug(String.format("Mappcustom attribute key:%s and value:%s", key, result.get(key))); }/*w w w . j a v a2s. c om*/ } } } } else { logger.debug(String.format("Did not find custom attribute configuration for origin:%s and zone:%s", getOrigin(), IdentityZoneHolder.get().getId())); } return result; }
From source file:org.cloudfoundry.identity.uaa.integration.feature.OpenIdTokenGrantsIT.java
@Test public void testImplicitGrant() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); LinkedMultiValueMap<String, String> postBody = new LinkedMultiValueMap<>(); postBody.add("client_id", "cf"); postBody.add("redirect_uri", "https://uaa.cloudfoundry.com/redirect/cf"); postBody.add("response_type", "token id_token"); postBody.add("source", "credentials"); postBody.add("username", user.getUserName()); postBody.add("password", secret); ResponseEntity<Void> responseEntity = restOperations.exchange(loginUrl + "/oauth/authorize", HttpMethod.POST, new HttpEntity<>(postBody, headers), Void.class); Assert.assertEquals(HttpStatus.FOUND, responseEntity.getStatusCode()); UriComponents locationComponents = UriComponentsBuilder.fromUri(responseEntity.getHeaders().getLocation()) .build();/* w ww. j a v a 2 s . c o m*/ Assert.assertEquals("uaa.cloudfoundry.com", locationComponents.getHost()); Assert.assertEquals("/redirect/cf", locationComponents.getPath()); MultiValueMap<String, String> params = parseFragmentParams(locationComponents); Assert.assertThat(params.get("jti"), not(empty())); Assert.assertEquals("bearer", params.getFirst("token_type")); Assert.assertThat(Integer.parseInt(params.getFirst("expires_in")), Matchers.greaterThan(40000)); String[] scopes = UriUtils.decode(params.getFirst("scope"), "UTF-8").split(" "); Assert.assertThat(Arrays.asList(scopes), containsInAnyOrder("scim.userids", "password.write", "cloud_controller.write", "openid", "cloud_controller.read", "uaa.user")); validateToken("access_token", params.toSingleValueMap(), scopes, aud); validateToken("id_token", params.toSingleValueMap(), openid, new String[] { "cf" }); }
From source file:org.dspace.app.rest.utils.RestRepositoryUtils.java
private Object[] prepareParameters(Method method, MultiValueMap<String, ? extends Object> rawParameters, Pageable pageable, Sort sort) { List<MethodParameter> parameters = new MethodParameters(method, PARAM_ANNOTATION).getParameters(); if (parameters.isEmpty()) { return new Object[0]; }/*from www .j ava2 s. com*/ Object[] result = new Object[parameters.size()]; Sort sortToUse = pageable == null ? sort : pageable.getSort(); for (int i = 0; i < result.length; i++) { MethodParameter param = parameters.get(i); Class<?> targetType = param.getParameterType(); if (Pageable.class.isAssignableFrom(targetType)) { result[i] = pageable; } else if (Sort.class.isAssignableFrom(targetType)) { result[i] = sortToUse; } else { String parameterName = param.getParameterName(); if (StringUtils.isBlank(parameterName)) { throw new IllegalArgumentException( String.format(NAME_NOT_FOUND, ClassUtils.getQualifiedMethodName(method))); } Object value = unwrapSingleElement(rawParameters.get(parameterName)); result[i] = targetType.isInstance(value) ? value : convert(value, param); } } return result; }
From source file:org.encuestame.social.api.templates.FacebookAPITemplate.java
public TweetPublishedMetadata publish(String object, String connection, MultiValueMap<String, String> data) { final MultiValueMap<String, String> requestData = new LinkedMultiValueMap<String, String>(data); log.debug("before facebookResponse:{" + requestData); final Map facebookResponse = getRestTemplate().postForObject(CONNECTION_URL, requestData, Map.class, object, connection);/*from w w w . j a v a 2 s . c o m*/ log.debug("facebookResponse:{" + facebookResponse); final TweetPublishedMetadata status = createStatus(data.get("message").toString()); status.setTweetId(facebookResponse.get("id").toString()); return status; }
From source file:org.fao.geonet.guiservices.csw.Set2.java
private void saveCswCapabilitiesInfo(MultiValueMap parameters) throws Exception { final ConfigurableApplicationContext context = ApplicationContextHolder.get(); LanguageRepository languageRepository = context.getBean(LanguageRepository.class); CswCapabilitiesInfoFieldRepository cswCapabilitiesInfoFieldRepository = context .getBean(CswCapabilitiesInfoFieldRepository.class); final List<Language> langs = languageRepository.findAll(); for (Language lang : langs) { CswCapabilitiesInfo cswCapInfo = cswCapabilitiesInfoFieldRepository .findCswCapabilitiesInfo(lang.getId()); String langId = lang.getId(); if (parameters.get("csw.title_" + langId) != null) { String title = (String) ((LinkedList) parameters.get("csw.title_" + langId)).get(0); if (StringUtils.isNotEmpty(title)) { cswCapInfo.setTitle(title); }/* w w w . j a v a 2s .c o m*/ } if (parameters.get("csw.abstract_" + langId) != null) { String abs = (String) ((LinkedList) parameters.get("csw.abstract_" + langId)).get(0); if (StringUtils.isNotEmpty(abs)) { cswCapInfo.setAbstract(abs); } } if (parameters.get("csw.fees_" + langId) != null) { String fees = (String) ((LinkedList) parameters.get("csw.fees_" + langId)).get(0); if (StringUtils.isNotEmpty(fees)) { cswCapInfo.setFees(fees); } } if (parameters.get("csw.accessConstraints_" + langId) != null) { String accessConstraints = (String) ((LinkedList) parameters.get("csw.accessConstraints_" + langId)) .get(0); if (StringUtils.isNotEmpty(accessConstraints)) { cswCapInfo.setAccessConstraints(accessConstraints); } } // Save item cswCapabilitiesInfoFieldRepository.save(cswCapInfo); } }