Java Code Examples for javax.ws.rs.core.MultivaluedHashMap#add()
The following examples show how to use
javax.ws.rs.core.MultivaluedHashMap#add() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SelectUserAuthenticatorForm.java From keycloak-extension-playground with Apache License 2.0 | 6 votes |
@Override protected Response challenge(AuthenticationFlowContext context, String error) { String useAjax = getConfigProperty(context, USE_AXJAX_CONFIG_PROPERTY, "true"); String loginHint = context.getHttpRequest().getUri().getQueryParameters().getFirst(OIDCLoginProtocol.LOGIN_HINT_PARAM); LoginFormsProvider usernameLoginForm = createSelectUserForm(context, error) .setAttribute("useAjax", "true".equals(useAjax)); if (loginHint != null) { MultivaluedHashMap<String, String> formData = new MultivaluedHashMap<>(); formData.add(AuthenticationManager.FORM_USERNAME, loginHint); usernameLoginForm.setAttribute("login", new LoginBean(formData)); } return usernameLoginForm .createForm("select-user-form.ftl"); }
Example 2
Source File: ODataExceptionWrapperTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
private ODataContextImpl getMockedContextWithLocale(final String requestUri, final String serviceRoot) throws ODataException, URISyntaxException { ODataContextImpl context = Mockito.mock(ODataContextImpl.class); PathInfoImpl pathInfo = new PathInfoImpl(); pathInfo.setRequestUri(new URI(requestUri)); pathInfo.setServiceRoot(new URI(serviceRoot)); when(context.getPathInfo()).thenReturn(pathInfo); MultivaluedHashMap<String,String> headers = new MultivaluedHashMap<String, String>(); headers.add("Accept-Language","de-DE, de;q=0.7"); when(context.getRequestHeaders()).thenReturn(headers); List<Locale> locales = new ArrayList<Locale>(); locales.add(Locale.GERMANY); when(context.getAcceptableLanguages()).thenReturn(locales); return context; }
Example 3
Source File: HttpHeadersImpl.java From msf4j with Apache License 2.0 | 5 votes |
@Override public MultivaluedMap<String, String> getRequestHeaders() { MultivaluedHashMap<String, String> newHeaders = new MultivaluedHashMap<>(); for (Map.Entry<String, String> headerEntry : nettyHttpHeaders.entries()) { if (headerEntry != null) { newHeaders.add(headerEntry.getKey(), headerEntry.getValue()); } } return newHeaders; }
Example 4
Source File: ClientUtils.java From nifi with Apache License 2.0 | 5 votes |
/** * Performs a POST using the specified url and form data. * * @param uri the uri to post to * @param formData the data to post * @return the client response of the post */ public Response post(URI uri, Map<String, String> formData) { // convert the form data final MultivaluedHashMap<String, String> entity = new MultivaluedHashMap(); for (String key : formData.keySet()) { entity.add(key, formData.get(key)); } // get the resource Invocation.Builder builder = client.target(uri).request().accept(MediaType.APPLICATION_JSON); // get the resource return builder.post(Entity.form(entity)); }
Example 5
Source File: YandexTranslate.java From nifi with Apache License 2.0 | 5 votes |
protected Invocation prepareResource(final String key, final List<String> text, final String sourceLanguage, final String destLanguage) { Invocation.Builder builder = client.target(URL).request(MediaType.APPLICATION_JSON); final MultivaluedHashMap entity = new MultivaluedHashMap(); entity.put("text", text); entity.add("key", key); if ((StringUtils.isBlank(sourceLanguage))) { entity.add("lang", destLanguage); } else { entity.add("lang", sourceLanguage + "-" + destLanguage); } return builder.buildPost(Entity.form(entity)); }
Example 6
Source File: NiFiTestUser.java From nifi with Apache License 2.0 | 5 votes |
/** * Attempts to create a token with the specified username and password. * * @param url the url * @param username the username * @param password the password * @return response * @throws Exception ex */ public Response testCreateToken(String url, String username, String password) throws Exception { // convert the form data MultivaluedHashMap<String, String> entity = new MultivaluedHashMap(); entity.add("username", username); entity.add("password", password); // get the resource Invocation.Builder resourceBuilder = addProxiedEntities(client.target(url).request().accept(MediaType.TEXT_PLAIN)); // perform the request return resourceBuilder.post(Entity.form(entity)); }
Example 7
Source File: RemoteNiFiUtils.java From nifi with Apache License 2.0 | 5 votes |
/** * Issues a registration request for this NiFi instance for the instance at the baseApiUri. * * @param baseApiUri uri to register with * @return response */ public Response issueRegistrationRequest(String baseApiUri) { final URI uri = URI.create(String.format("%s/controller/users", baseApiUri)); // set up the query params MultivaluedHashMap entity = new MultivaluedHashMap(); entity.add("justification", "A Remote instance of NiFi has attempted to create a reference to this NiFi. This action must be approved first."); // get the resource return client.target(uri).request().post(Entity.form(entity)); }
Example 8
Source File: EmployeeResourceTest.java From wildfly-samples with MIT License | 5 votes |
/** * Test of getList method, of class MyResource. */ @Test @InSequence(1) public void testPostAndGet() { MultivaluedHashMap<String, String> map = new MultivaluedHashMap<>(); map.add("name", "Penny"); map.add("age", "1"); target.request().post(Entity.form(map)); map.clear(); map.add("name", "Leonard"); map.add("age", "2"); target.request().post(Entity.form(map)); map.clear(); map.add("name", "Sheldon"); map.add("age", "3"); target.request().post(Entity.form(map)); Employee[] list = target.request().get(Employee[].class); assertEquals(3, list.length); assertEquals("Penny", list[0].getName()); assertEquals(1, list[0].getAge()); assertEquals("Leonard", list[1].getName()); assertEquals(2, list[1].getAge()); assertEquals("Sheldon", list[2].getName()); assertEquals(3, list[2].getAge()); }
Example 9
Source File: EmployeeResourceTest.java From wildfly-samples with MIT License | 5 votes |
/** * Test of putToList method, of class MyResource. */ @Test @InSequence(3) public void testPut() { MultivaluedHashMap<String, String> map = new MultivaluedHashMap<>(); map.add("name", "Howard"); map.add("age", "4"); target.request().post(Entity.form(map)); Employee[] list = target.request().get(Employee[].class); assertEquals(4, list.length); assertEquals("Howard", list[3].getName()); assertEquals(4, list[3].getAge()); }