List of usage examples for org.springframework.web.util UriComponentsBuilder queryParam
@Override
public UriComponentsBuilder queryParam(String name, @Nullable Collection<?> values)
From source file:org.openmrs.module.radiology.dicom.DicomWebViewer.java
/** * Return URL to open DICOM web viewer for given Study. * //from www. j a v a 2s. c o m * @param study Study for which DICOM web viewer URL should be created * @throws IllegalArgumentException given null * @throws IllegalArgumentException given a study with studyInstanceUid null * @should return a url to open dicom images of the given study in the configured dicom viewer * @should add query param server name to url if local server name is not blank * @should throw an illegal argument exception given null * @should throw an illegal argument exception given study with studyInstanceUid null */ public String getDicomViewerUrl(Study study) { if (study == null) { throw new IllegalArgumentException("study cannot be null"); } else if (study.getStudyInstanceUid() == null) { throw new IllegalArgumentException("studyInstanceUid cannot be null"); } final UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.newInstance().scheme("http") .host(radiologyProperties.getDicomWebViewerAddress()) .port(Integer.valueOf(radiologyProperties.getDicomWebViewerPort())) .path(radiologyProperties.getDicomWebViewerBaseUrl()) .queryParam("studyUID", study.getStudyInstanceUid()); final String serverName = radiologyProperties.getDicomWebViewerLocalServerName(); if (StringUtils.isNotBlank(serverName)) { uriComponentsBuilder.queryParam("serverName", serverName); } return uriComponentsBuilder.buildAndExpand().encode().toString(); }
From source file:org.springframework.security.oauth2.provider.endpoint.AuthorizationEndpoint.java
private String append(String base, Map<String, ?> query, Map<String, String> keys, boolean fragment) { UriComponentsBuilder template = UriComponentsBuilder.newInstance(); UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(base); URI redirectUri;//from w ww . j a va2 s .com try { // assume it's encoded to start with (if it came in over the wire) redirectUri = builder.build(true).toUri(); } catch (Exception e) { // ... but allow client registrations to contain hard-coded non-encoded values redirectUri = builder.build().toUri(); builder = UriComponentsBuilder.fromUri(redirectUri); } template.scheme(redirectUri.getScheme()).port(redirectUri.getPort()).host(redirectUri.getHost()) .userInfo(redirectUri.getUserInfo()).path(redirectUri.getPath()); if (fragment) { StringBuilder values = new StringBuilder(); if (redirectUri.getFragment() != null) { String append = redirectUri.getFragment(); values.append(append); } for (String key : query.keySet()) { if (values.length() > 0) { values.append("&"); } String name = key; if (keys != null && keys.containsKey(key)) { name = keys.get(key); } values.append(name + "={" + key + "}"); } if (values.length() > 0) { template.fragment(values.toString()); } UriComponents encoded = template.build().expand(query).encode(); builder.fragment(encoded.getFragment()); } else { for (String key : query.keySet()) { String name = key; if (keys != null && keys.containsKey(key)) { name = keys.get(key); } template.queryParam(name, "{" + key + "}"); } template.fragment(redirectUri.getFragment()); UriComponents encoded = template.build().expand(query).encode(); builder.query(encoded.getQuery()); } return builder.build().toUriString(); }
From source file:ru.org.linux.topic.TagTopicListController.java
private static String buildTagUri(String tag, int section, int offset) { UriComponentsBuilder builder = UriComponentsBuilder.fromUri(TAG_URI_TEMPLATE.expand(tag)); if (section != 0) { builder.queryParam("section", section); }//from w w w .j a va 2 s . co m if (offset != 0) { builder.queryParam("offset", offset); } return builder.build().toUriString(); }