Java Code Examples for javax.ws.rs.core.MultivaluedMap#size()
The following examples show how to use
javax.ws.rs.core.MultivaluedMap#size() .
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 |
private LoginFormsProvider createSelectUserForm(AuthenticationFlowContext context, String error) { MultivaluedMap<String, String> formData = createLoginFormData(context); LoginFormsProvider form = context.form(); if (formData.size() > 0) { form.setFormData(formData); } form.setAttribute("login", new LoginBean(formData)); if (error != null) { form.setError(error); } return form; }
Example 2
Source File: APIRequest.java From guacamole-client with Apache License 2.0 | 6 votes |
/** * Wraps the given HttpServletRequest, using the given MultivaluedMap to * provide all request parameters. All HttpServletRequest functions which * do not deal with parameter names and values are delegated to the wrapped * request. * * @param request * The HttpServletRequest to wrap. * * @param parameters * All request parameters. */ public APIRequest(HttpServletRequest request, MultivaluedMap<String, String> parameters) { super(request); // Grab the remote host info this.remoteHost = request.getRemoteHost(); // Grab the remote ip info this.remoteAddr = request.getRemoteAddr(); // Copy parameters from given MultivaluedMap this.parameters = new HashMap<String, String[]>(parameters.size()); for (Map.Entry<String, List<String>> entry : parameters.entrySet()) { // Get parameter name and all corresponding values String name = entry.getKey(); List<String> values = entry.getValue(); // Add parameters to map this.parameters.put(name, values.toArray(new String[values.size()])); } }
Example 3
Source File: JAXRSUtils.java From cxf with Apache License 2.0 | 6 votes |
public static void pushOntoStack(OperationResourceInfo ori, MultivaluedMap<String, String> params, Message msg) { OperationResourceInfoStack stack = msg.get(OperationResourceInfoStack.class); if (stack == null) { stack = new OperationResourceInfoStack(); msg.put(OperationResourceInfoStack.class, stack); } List<String> values = null; if (params.size() <= 1) { values = Collections.emptyList(); } else { values = new ArrayList<>(params.size() - 1); addTemplateVarValues(values, params, ori.getClassResourceInfo().getURITemplate()); addTemplateVarValues(values, params, ori.getURITemplate()); } Class<?> realClass = ori.getClassResourceInfo().getServiceClass(); stack.push(new MethodInvocationInfo(ori, realClass, values)); }
Example 4
Source File: APIRequest.java From guacamole-client with Apache License 2.0 | 6 votes |
/** * Wraps the given HttpServletRequest, using the given MultivaluedMap to * provide all request parameters. All HttpServletRequest functions which * do not deal with parameter names and values are delegated to the wrapped * request. * * @param request * The HttpServletRequest to wrap. * * @param parameters * All request parameters. */ public APIRequest(HttpServletRequest request, MultivaluedMap<String, String> parameters) { super(request); // Grab the remote host info this.remoteHost = request.getRemoteHost(); // Grab the remote ip info this.remoteAddr = request.getRemoteAddr(); // Copy parameters from given MultivaluedMap this.parameters = new HashMap<String, String[]>(parameters.size()); for (Map.Entry<String, List<String>> entry : parameters.entrySet()) { // Get parameter name and all corresponding values String name = entry.getKey(); List<String> values = entry.getValue(); // Add parameters to map this.parameters.put(name, values.toArray(new String[values.size()])); } }
Example 5
Source File: PlainTextExamplesMessageBodyReader.java From vw-webservice with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public ExamplesIterable readFrom(Class<ExamplesIterable> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { if (LOGGER.isDebugEnabled()) if (httpHeaders != null && httpHeaders.size() > 0) { LOGGER.debug("Rec'd HTTP headers: "); for (Entry<String, List<String>> entry : httpHeaders.entrySet()) { LOGGER.debug("{}:{}", entry.getKey(), StringUtils.join(entry.getValue(), ',')); } } // TODO: // if a content-length has been provided, then use that to read entire // string in one go. Charset charset = ReaderWriter.getCharset(mediaType); LOGGER.debug("Reading examples using charset: {}", charset.displayName()); StringExampleIterator theIterator = new StringExampleIterator(entityStream, charset); // TODO: provide the proper number of examples here // setting this to Integer.MAX_VALUE for now to force streaming return new ExamplesIterableImpl(Integer.MAX_VALUE, null, theIterator); }
Example 6
Source File: JAXRSHTTPSignatureTest.java From cxf with Apache License 2.0 | 5 votes |
private Map<String, List<String>> convertHeaders(MultivaluedMap<String, Object> requestHeaders) { Map<String, List<String>> convertedHeaders = new HashMap<>(requestHeaders.size()); for (Map.Entry<String, List<Object>> entry : requestHeaders.entrySet()) { convertedHeaders.put(entry.getKey(), entry.getValue().stream().map(Object::toString).collect(Collectors.toList())); } return convertedHeaders; }
Example 7
Source File: MultipartStore.java From cxf with Apache License 2.0 | 5 votes |
@POST @Path("/books/mixedmultivaluedmap") @Consumes("multipart/mixed") @Produces("text/xml") public Response addBookFromFormConsumesMixed( @Multipart(value = "mapdata", type = MediaType.APPLICATION_FORM_URLENCODED) MultivaluedMap<String, String> data, @Multipart(value = "test-cid", type = MediaType.APPLICATION_XML) String testXml) throws Exception { if (!"Dreams".equals(data.get("id-name").get(0))) { throw new Exception("Map entry 0 does not match"); } if (!"True".equals(data.get("entity-name").get(0))) { throw new Exception("Map entry 1 does not match"); } if (!"NAT5\n".equals(data.get("native-id").get(0))) { throw new Exception("Map entry 2 does not match"); } if (data.size() != 3) { throw new Exception("Map size does not match"); } if ("<hello>World2</hello>".equals(testXml)) { throw new Exception("testXml does not match"); } Book b = new Book(); b.setId(124); b.setName("CXF in Action - 2"); return Response.ok(b).build(); }
Example 8
Source File: FaultyRequestHandler.java From cxf with Apache License 2.0 | 5 votes |
@Override public void filter(ContainerRequestContext context) { if (uriInfo.getPath().endsWith("/propogateExceptionVar/1")) { MultivaluedMap<String, String> vars = uriInfo.getPathParameters(); if (vars.size() == 1 && vars.get("i") != null && vars.get("i").size() == 1 && "1".equals(vars.getFirst("i"))) { JAXRSUtils.getCurrentMessage().getExchange() .put("org.apache.cxf.systest.for-out-fault-interceptor", Boolean.TRUE); throw new RuntimeException(); } } }
Example 9
Source File: AbstractSignatureOutFilter.java From cxf with Apache License 2.0 | 5 votes |
private Map<String, List<String>> convertHeaders(MultivaluedMap<String, Object> requestHeaders) { Map<String, List<String>> convertedHeaders = new HashMap<>(requestHeaders.size()); for (Map.Entry<String, List<Object>> entry : requestHeaders.entrySet()) { convertedHeaders.put(entry.getKey(), entry.getValue().stream().map(o -> o.toString().trim()).collect(Collectors.toList())); } return convertedHeaders; }
Example 10
Source File: SearchContextImpl.java From cxf with Apache License 2.0 | 5 votes |
private String convertPlainQueriesToFiqlExp(MultivaluedMap<String, String> params) { SearchConditionBuilder builder = SearchConditionBuilder.instance(); List<CompleteCondition> list = new ArrayList<>(params.size()); for (Map.Entry<String, List<String>> entry : params.entrySet()) { list.add(getOrCondition(builder, entry)); } return builder.and(list).query(); }
Example 11
Source File: SimpleJsonExamplesMessageBodyReader.java From vw-webservice with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public ExamplesIterable readFrom(Class<ExamplesIterable> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { if (LOGGER.isDebugEnabled()) if (httpHeaders != null && httpHeaders.size() > 0) { LOGGER.debug("Rec'd HTTP headers: "); for (Entry<String, List<String>> entry : httpHeaders.entrySet()) { LOGGER.debug("{}:{}", entry.getKey(), StringUtils.join(entry.getValue(), ',')); } } //TODO: hard-coding to GsonJsonExamplesProvider for now return new ExamplesIterableImpl(Integer.MAX_VALUE, null, new GsonJsonExamplesProvider().getExamplesFromStream(entityStream)); }
Example 12
Source File: StructuredJsonExamplesMessageBodyReader.java From vw-webservice with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public ExamplesIterable readFrom(Class<ExamplesIterable> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { if (LOGGER.isDebugEnabled()) if (httpHeaders != null && httpHeaders.size() > 0) { LOGGER.debug("Rec'd HTTP headers: "); for (Entry<String, List<String>> entry : httpHeaders.entrySet()) { LOGGER.debug("{}:{}", entry.getKey(), StringUtils.join(entry.getValue(), ',')); } } //TODO: hard-coding to GsonJsonExamplesProvider for now return new ExamplesIterableImpl(Integer.MAX_VALUE, null, new StructuredJsonExamplesProvider(-1, -1).getExamplesFromStream(entityStream)); }
Example 13
Source File: UsernamePasswordForm.java From keycloak with Apache License 2.0 | 3 votes |
protected Response challenge(AuthenticationFlowContext context, MultivaluedMap<String, String> formData) { LoginFormsProvider forms = context.form(); if (formData.size() > 0) forms.setFormData(formData); return forms.createLoginUsernamePassword(); }