com.sun.jersey.api.representation.Form form = new Form(); form.putSingle("j_username", username); form.putSingle("j_password", password);
UriBuilder ub = request.getRequestUriBuilder(); Form f = request.getFormParameters(); for (Map.Entry<String, List<String>> param : f.entrySet()) { ub.queryParam(param.getKey(), param.getValue().toArray());
@Override public String getFormParameterValue(String field) { if (form==null) form = containerRequest.getFormParameters(); return form.getFirst(field); } }
private static Form messageParametersAsMap(String roomIdOrName, String from, String message, Option<Message.Format> format, Option<Message.BackgroundColor> color, Option<Boolean> notify) { final Form params = new Form(); params.putSingle("room_id", roomIdOrName); params.putSingle("from", from); params.putSingle("message", message); if (format.isDefined()) { params.putSingle("message_format", format.get().value); } if (color.isDefined()) { params.putSingle("color", color.get().value); } if (notify.isDefined()) { params.putSingle("notify", notify.get() ? "1" : "0"); } return params; }
/** * Ping as a POST * @param text text to include * @return the response * @throws IOException on any failure */ public PingInformation pingPost(String text) throws IOException { WebResource pingResource = applicationResource(ACTION_PING); Form f = new Form(); f.add("text", text); return pingResource .type(MediaType.APPLICATION_JSON_TYPE) .post(PingInformation.class, f); }
@Override public Form getFormParameters() { if (MediaTypes.typeEquals(MediaType.APPLICATION_FORM_URLENCODED_TYPE, getMediaType())) { InputStream in = getEntityInputStream(); if (in.getClass() != ByteArrayInputStream.class) { // Buffer input ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); try { ReaderWriter.writeTo(in, byteArrayOutputStream); } catch (IOException e) { throw new IllegalArgumentException(e); } in = new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); setEntityInputStream(in); } ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream) in; Form f = getEntity(Form.class); byteArrayInputStream.reset(); return f; } else { return new Form(); } }
@Override public Subject register(String subject, SubjectConfig config) { Form form = new Form(); for(Map.Entry<String, String> entry : RepositoryUtil.safeConfig(config).asMap().entrySet()) { form.putSingle(entry.getKey(), entry.getValue()); } String regSubjectName = webResource.path(subject).type(MediaType.APPLICATION_FORM_URLENCODED).put(String.class, form); return new RESTSubject(regSubjectName); }
/** * Ping as a POST * @param text text to include * @return the response * @throws IOException on any failure */ public PingInformation pingPost(String text) throws IOException { WebResource pingResource = applicationResource(ACTION_PING); Form f = new Form(); f.add("text", text); return pingResource .type(MediaType.APPLICATION_JSON_TYPE) .post(PingInformation.class, f); }
com.sun.jersey.api.representation.Form input = new Form(); input.add("client_id", "Tyler_Kevin"); input.add("client_secret", "VcwDLMGuFMLnUgqldj....."); input.add("scope", "http://api.microsofttranslator.com"); input.add("grant_type", "client_credentials"); // send HTTP POST ClientResponse response = webResource.type("application/x-www-form-urlencoded") .post(ClientResponse.class, input);
@Override public Subject register(String subject, SubjectConfig config) { Form form = new Form(); for(Map.Entry<String, String> entry : RepositoryUtil.safeConfig(config).asMap().entrySet()) { form.putSingle(entry.getKey(), entry.getValue()); } String regSubjectName = webResource.path(subject).type(MediaType.APPLICATION_FORM_URLENCODED).put(String.class, form); return new RESTSubject(regSubjectName); }
/** * {@inheritDoc} */ @Override public <T> T post(Map<String, String> formParams, Class<T> t) { AhcHttpClient asyncClient = AhcHttpClient.create(createAhcConfig()); try { Form form = new Form(); for (Map.Entry<String, String> e : formParams.entrySet()) { form.add(e.getKey(), e.getValue()); } WebResource r = buildRequest(asyncClient); return headers(r, TYPE.POST, true).post(t, form); } catch (UniformInterfaceException u) { headers.put(negotiateHandler.challengedHeaderName(), negotiate(u)); return post(formParams, t); } finally { asyncClient.destroy(); } }
public Form readFrom( Class<Form> type, Type genericType, Annotation annotations[], MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { return readFrom(new Form(), mediaType, entityStream); }
@Override public Subject register(String subject, SubjectConfig config) { Form form = new Form(); for(Map.Entry<String, String> entry : RepositoryUtil.safeConfig(config).asMap().entrySet()) { form.putSingle(entry.getKey(), entry.getValue()); } String regSubjectName = webResource.path(subject).type(MediaType.APPLICATION_FORM_URLENCODED).put(String.class, form); return new RESTSubject(regSubjectName); }
public Form readFrom( Class<Form> type, Type genericType, Annotation annotations[], MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { return readFrom(new Form(), mediaType, entityStream); }
@Override public Subject register(String subject, SubjectConfig config) { Form form = new Form(); for(Map.Entry<String, String> entry : RepositoryUtil.safeConfig(config).asMap().entrySet()) { form.putSingle(entry.getKey(), entry.getValue()); } String regSubjectName = webResource.path(subject).type(MediaType.APPLICATION_FORM_URLENCODED).put(String.class, form); return new RESTSubject(regSubjectName); }
private Response serviceViaOSGIPlugin(final MultivaluedMap<String, String> form, final HttpServletRequest request, final HttpServletResponse response, final ServletContext servletContext, final ServletConfig servletConfig, final UriInfo uriInfo) throws ServletException, IOException { // form will contain form parameters, if any. Even if the request contains such parameters, it may be empty // if a filter (e.g. Shiro) has already consumed them (see kludge below) return serviceViaOSGIPlugin(request, createInputStream(request, form), form, response, servletContext, servletConfig, uriInfo); }
com.sun.jersey.api.representation.Form form = new Form(); form.putSingle("j_username", username); form.putSingle("j_password", password);
/** * Ping as a POST * @param text text to include * @return the response * @throws IOException on any failure */ public PingInformation pingPut(String text) throws IOException { WebResource pingResource = applicationResource(ACTION_PING); Form f = new Form(); return pingResource .type(MediaType.TEXT_PLAIN) .put(PingInformation.class, text); }
/** * Ping as a POST * @param text text to include * @return the response * @throws IOException on any failure */ public PingInformation pingPut(String text) throws IOException { WebResource pingResource = applicationResource(ACTION_PING); Form f = new Form(); return pingResource .type(MediaType.TEXT_PLAIN) .put(PingInformation.class, text); }