Search in sources :

Example 1 with HeaderParam

use of jakarta.ws.rs.HeaderParam in project resteasy by resteasy.

the class ProcessorFactory method createProcessor.

public static Object createProcessor(Class<?> declaring, String defaultParameterName, ClientConfiguration configuration, Class<?> type, Annotation[] annotations, Type genericType, AccessibleObject target, MediaType defaultConsumes, boolean ignoreBody) {
    Object processor = null;
    QueryParam query;
    org.jboss.resteasy.annotations.jaxrs.QueryParam queryParam2;
    HeaderParam header;
    org.jboss.resteasy.annotations.jaxrs.HeaderParam header2;
    MatrixParam matrix;
    org.jboss.resteasy.annotations.jaxrs.MatrixParam matrix2;
    PathParam uriParam;
    org.jboss.resteasy.annotations.jaxrs.PathParam uriParam2;
    CookieParam cookie;
    org.jboss.resteasy.annotations.jaxrs.CookieParam cookie2;
    FormParam formParam;
    org.jboss.resteasy.annotations.jaxrs.FormParam formParam2;
    // Form form;
    boolean isEncoded = FindAnnotation.findAnnotation(annotations, Encoded.class) != null;
    if ((query = FindAnnotation.findAnnotation(annotations, QueryParam.class)) != null) {
        processor = new QueryParamProcessor(query.value(), genericType, annotations, configuration);
    } else if ((queryParam2 = FindAnnotation.findAnnotation(annotations, org.jboss.resteasy.annotations.jaxrs.QueryParam.class)) != null) {
        processor = new QueryParamProcessor(getParamName(defaultParameterName, queryParam2.value()), genericType, annotations, configuration);
    } else if ((header = FindAnnotation.findAnnotation(annotations, HeaderParam.class)) != null) {
        processor = new HeaderParamProcessor(header.value(), genericType, annotations, configuration);
    } else if ((header2 = FindAnnotation.findAnnotation(annotations, org.jboss.resteasy.annotations.jaxrs.HeaderParam.class)) != null) {
        processor = new HeaderParamProcessor(getParamName(defaultParameterName, header2.value()), genericType, annotations, configuration);
    } else if ((cookie = FindAnnotation.findAnnotation(annotations, CookieParam.class)) != null) {
        processor = new CookieParamProcessor(cookie.value(), genericType, annotations);
    } else if ((cookie2 = FindAnnotation.findAnnotation(annotations, org.jboss.resteasy.annotations.jaxrs.CookieParam.class)) != null) {
        processor = new CookieParamProcessor(getParamName(defaultParameterName, cookie2.value()), genericType, annotations);
    } else if ((uriParam = FindAnnotation.findAnnotation(annotations, PathParam.class)) != null) {
        processor = new PathParamProcessor(uriParam.value(), isEncoded, genericType, annotations, configuration);
    } else if ((uriParam2 = FindAnnotation.findAnnotation(annotations, org.jboss.resteasy.annotations.jaxrs.PathParam.class)) != null) {
        processor = new PathParamProcessor(getParamName(defaultParameterName, uriParam2.value()), isEncoded, genericType, annotations, configuration);
    } else if ((matrix = FindAnnotation.findAnnotation(annotations, MatrixParam.class)) != null) {
        processor = new MatrixParamProcessor(matrix.value(), genericType, annotations, configuration);
    } else if ((matrix2 = FindAnnotation.findAnnotation(annotations, org.jboss.resteasy.annotations.jaxrs.MatrixParam.class)) != null) {
        processor = new MatrixParamProcessor(getParamName(defaultParameterName, matrix2.value()), genericType, annotations, configuration);
    } else if ((formParam = FindAnnotation.findAnnotation(annotations, FormParam.class)) != null) {
        processor = new FormParamProcessor(formParam.value(), genericType, annotations, configuration);
    } else if ((formParam2 = FindAnnotation.findAnnotation(annotations, org.jboss.resteasy.annotations.jaxrs.FormParam.class)) != null) {
        processor = new FormParamProcessor(getParamName(defaultParameterName, formParam2.value()), genericType, annotations, configuration);
    } else if ((/* form = */
    FindAnnotation.findAnnotation(annotations, Form.class)) != null) {
        processor = new FormProcessor(type, configuration, defaultParameterName);
    } else if ((/* form = */
    FindAnnotation.findAnnotation(annotations, BeanParam.class)) != null) {
        processor = new FormProcessor(type, configuration, defaultParameterName);
    } else if ((FindAnnotation.findAnnotation(annotations, Context.class)) != null) {
        processor = null;
    } else if (type.equals(Cookie.class)) {
        processor = new CookieParamProcessor(null);
    } else // this is for HATEAOS clients
    if (FindAnnotation.findAnnotation(annotations, ClientURI.class.getName()) != null) {
        processor = new URIParamProcessor();
    } else if (!ignoreBody) {
        MediaType mediaType = MediaTypeHelper.getConsumes(declaring, target);
        if (mediaType == null)
            mediaType = defaultConsumes;
        if (mediaType == null) {
            throw new RuntimeException(Messages.MESSAGES.mustDefineConsumesType());
        }
        processor = new MessageBodyParameterProcessor(mediaType, type, genericType, annotations);
    }
    return processor;
}
Also used : HeaderParam(jakarta.ws.rs.HeaderParam) MatrixParam(jakarta.ws.rs.MatrixParam) Encoded(jakarta.ws.rs.Encoded) FormParamProcessor(org.jboss.resteasy.client.jaxrs.internal.proxy.processors.invocation.FormParamProcessor) MessageBodyParameterProcessor(org.jboss.resteasy.client.jaxrs.internal.proxy.processors.invocation.MessageBodyParameterProcessor) MediaType(jakarta.ws.rs.core.MediaType) PathParam(jakarta.ws.rs.PathParam) HeaderParamProcessor(org.jboss.resteasy.client.jaxrs.internal.proxy.processors.invocation.HeaderParamProcessor) MatrixParamProcessor(org.jboss.resteasy.client.jaxrs.internal.proxy.processors.webtarget.MatrixParamProcessor) BeanParam(jakarta.ws.rs.BeanParam) Cookie(jakarta.ws.rs.core.Cookie) CookieParamProcessor(org.jboss.resteasy.client.jaxrs.internal.proxy.processors.invocation.CookieParamProcessor) URIParamProcessor(org.jboss.resteasy.client.jaxrs.internal.proxy.processors.invocation.URIParamProcessor) CookieParam(jakarta.ws.rs.CookieParam) QueryParam(jakarta.ws.rs.QueryParam) PathParamProcessor(org.jboss.resteasy.client.jaxrs.internal.proxy.processors.webtarget.PathParamProcessor) AccessibleObject(java.lang.reflect.AccessibleObject) FormParam(jakarta.ws.rs.FormParam) QueryParamProcessor(org.jboss.resteasy.client.jaxrs.internal.proxy.processors.webtarget.QueryParamProcessor)

Example 2 with HeaderParam

use of jakarta.ws.rs.HeaderParam in project resteasy by resteasy.

the class MethodMetaData method processMetaData.

protected void processMetaData(Class<?> type, Annotation[] annotations, boolean useBody) {
    QueryParam query;
    HeaderParam header;
    MatrixParam matrix;
    PathParam uriParam;
    CookieParam cookie;
    FormParam formParam;
    Form form;
    if ((query = FindAnnotation.findAnnotation(annotations, QueryParam.class)) != null) {
        addParameter(type, annotations, MethodParamType.QUERY_PARAMETER, query.value());
    } else if ((header = FindAnnotation.findAnnotation(annotations, HeaderParam.class)) != null) {
        addParameter(type, annotations, MethodParamType.HEADER_PARAMETER, header.value());
    } else if ((cookie = FindAnnotation.findAnnotation(annotations, CookieParam.class)) != null) {
        addParameter(type, annotations, MethodParamType.COOKIE_PARAMETER, cookie.value());
    } else if ((uriParam = FindAnnotation.findAnnotation(annotations, PathParam.class)) != null) {
        addParameter(type, annotations, MethodParamType.PATH_PARAMETER, uriParam.value());
    } else if ((matrix = FindAnnotation.findAnnotation(annotations, MatrixParam.class)) != null) {
        addParameter(type, annotations, MethodParamType.MATRIX_PARAMETER, matrix.value());
    } else if ((formParam = FindAnnotation.findAnnotation(annotations, FormParam.class)) != null) {
        addParameter(type, annotations, MethodParamType.FORM_PARAMETER, formParam.value());
        this.wantsForm = true;
    } else if ((form = FindAnnotation.findAnnotation(annotations, Form.class)) != null) {
        if (type == Map.class || type == List.class) {
            addParameter(type, annotations, MethodParamType.FORM, form.prefix());
            this.wantsForm = true;
        } else
            walkForm(type);
    } else if ((FindAnnotation.findAnnotation(annotations, Context.class)) != null) {
    // righfully ignore
    } else if (useBody) {
        addParameter(type, annotations, MethodParamType.ENTITY_PARAMETER, null);
    }
}
Also used : CookieParam(jakarta.ws.rs.CookieParam) Context(jakarta.ws.rs.core.Context) HeaderParam(jakarta.ws.rs.HeaderParam) MatrixParam(jakarta.ws.rs.MatrixParam) QueryParam(jakarta.ws.rs.QueryParam) Form(org.jboss.resteasy.annotations.Form) ArrayList(java.util.ArrayList) List(java.util.List) PathParam(jakarta.ws.rs.PathParam) FormParam(jakarta.ws.rs.FormParam) Map(java.util.Map)

Example 3 with HeaderParam

use of jakarta.ws.rs.HeaderParam in project resteasy by resteasy.

the class ResteasyWadlMethodMetaData method processMetaData.

protected void processMetaData(Class<?> type, Annotation[] annotations, boolean useBody) {
    QueryParam queryParam;
    HeaderParam headerParam;
    MatrixParam matrixParam;
    PathParam pathParam;
    CookieParam cookieParam;
    FormParam formParam;
    Form form;
    if ((queryParam = FindAnnotation.findAnnotation(annotations, QueryParam.class)) != null) {
        addParameter(type, annotations, ResteasyWadlMethodParamMetaData.MethodParamType.QUERY_PARAMETER, queryParam.value());
    } else if ((headerParam = FindAnnotation.findAnnotation(annotations, HeaderParam.class)) != null) {
        addParameter(type, annotations, ResteasyWadlMethodParamMetaData.MethodParamType.HEADER_PARAMETER, headerParam.value());
    } else if ((cookieParam = FindAnnotation.findAnnotation(annotations, CookieParam.class)) != null) {
        addParameter(type, annotations, ResteasyWadlMethodParamMetaData.MethodParamType.COOKIE_PARAMETER, cookieParam.value());
    } else if ((pathParam = FindAnnotation.findAnnotation(annotations, PathParam.class)) != null) {
        addParameter(type, annotations, ResteasyWadlMethodParamMetaData.MethodParamType.PATH_PARAMETER, pathParam.value());
    } else if ((matrixParam = FindAnnotation.findAnnotation(annotations, MatrixParam.class)) != null) {
        addParameter(type, annotations, ResteasyWadlMethodParamMetaData.MethodParamType.MATRIX_PARAMETER, matrixParam.value());
    } else if ((formParam = FindAnnotation.findAnnotation(annotations, FormParam.class)) != null) {
        addParameter(type, annotations, ResteasyWadlMethodParamMetaData.MethodParamType.FORM_PARAMETER, formParam.value());
        this.wantsForm = true;
    } else if ((form = FindAnnotation.findAnnotation(annotations, Form.class)) != null) {
        if (type == List.class) {
            addParameter(type, annotations, ResteasyWadlMethodParamMetaData.MethodParamType.FORM, form.prefix());
            this.wantsForm = true;
        } else if (type == Map.class) {
            addParameter(type, annotations, ResteasyWadlMethodParamMetaData.MethodParamType.FORM, form.prefix());
            this.wantsForm = true;
        } else
            walkForm(type);
    } else if ((FindAnnotation.findAnnotation(annotations, Context.class)) != null) {
    // righfully ignore
    } else if (useBody) {
        addParameter(type, annotations, ResteasyWadlMethodParamMetaData.MethodParamType.ENTITY_PARAMETER, null);
    }
}
Also used : CookieParam(jakarta.ws.rs.CookieParam) Context(jakarta.ws.rs.core.Context) HeaderParam(jakarta.ws.rs.HeaderParam) MatrixParam(jakarta.ws.rs.MatrixParam) QueryParam(jakarta.ws.rs.QueryParam) Form(org.jboss.resteasy.annotations.Form) PathParam(jakarta.ws.rs.PathParam) FormParam(jakarta.ws.rs.FormParam) Map(java.util.Map)

Example 4 with HeaderParam

use of jakarta.ws.rs.HeaderParam in project resteasy by resteasy.

the class InjectorFactoryImpl method createParameterExtractor0.

private ValueInjector createParameterExtractor0(Class injectTargetClass, AccessibleObject injectTarget, String defaultName, Class type, Type genericType, Annotation[] annotations, boolean useDefault, ResteasyProviderFactory providerFactory) {
    DefaultValue defaultValue = findAnnotation(annotations, DefaultValue.class);
    boolean encode = findAnnotation(annotations, Encoded.class) != null || injectTarget.isAnnotationPresent(Encoded.class) || type.isAnnotationPresent(Encoded.class);
    String defaultVal = null;
    if (defaultValue != null)
        defaultVal = defaultValue.value();
    QueryParam queryParam;
    HeaderParam header;
    MatrixParam matrix;
    PathParam uriParam;
    CookieParam cookie;
    FormParam formParam;
    Form form;
    if ((queryParam = findAnnotation(annotations, QueryParam.class)) != null) {
        return new QueryParamInjector(type, genericType, injectTarget, queryParam.value(), defaultVal, encode, annotations, providerFactory);
    } else if (findAnnotation(annotations, org.jboss.resteasy.annotations.jaxrs.QueryParam.class) != null) {
        return new QueryParamInjector(type, genericType, injectTarget, defaultName, defaultVal, encode, annotations, providerFactory);
    } else if (findAnnotation(annotations, Query.class) != null) {
        return new QueryInjector(type, providerFactory);
    } else if ((header = findAnnotation(annotations, HeaderParam.class)) != null) {
        return new HeaderParamInjector(type, genericType, injectTarget, header.value(), defaultVal, annotations, providerFactory);
    } else if (findAnnotation(annotations, org.jboss.resteasy.annotations.jaxrs.HeaderParam.class) != null) {
        return new HeaderParamInjector(type, genericType, injectTarget, defaultName, defaultVal, annotations, providerFactory);
    } else if ((formParam = findAnnotation(annotations, FormParam.class)) != null) {
        return new FormParamInjector(type, genericType, injectTarget, formParam.value(), defaultVal, encode, annotations, providerFactory);
    } else if (findAnnotation(annotations, org.jboss.resteasy.annotations.jaxrs.FormParam.class) != null) {
        return new FormParamInjector(type, genericType, injectTarget, defaultName, defaultVal, encode, annotations, providerFactory);
    } else if ((cookie = findAnnotation(annotations, CookieParam.class)) != null) {
        return new CookieParamInjector(type, genericType, injectTarget, cookie.value(), defaultVal, annotations, providerFactory);
    } else if (findAnnotation(annotations, org.jboss.resteasy.annotations.jaxrs.CookieParam.class) != null) {
        return new CookieParamInjector(type, genericType, injectTarget, defaultName, defaultVal, annotations, providerFactory);
    } else if ((uriParam = findAnnotation(annotations, PathParam.class)) != null) {
        return new PathParamInjector(type, genericType, injectTarget, uriParam.value(), defaultVal, encode, annotations, providerFactory);
    } else if (findAnnotation(annotations, org.jboss.resteasy.annotations.jaxrs.PathParam.class) != null) {
        return new PathParamInjector(type, genericType, injectTarget, defaultName, defaultVal, encode, annotations, providerFactory);
    } else if ((form = findAnnotation(annotations, Form.class)) != null) {
        String prefix = form.prefix();
        if (prefix.length() > 0) {
            if (genericType instanceof ParameterizedType) {
                ParameterizedType pType = (ParameterizedType) genericType;
                if (Types.isA(List.class, pType)) {
                    return new ListFormInjector(type, Types.getArgumentType(pType, 0), prefix, providerFactory);
                }
                if (Types.isA(Map.class, pType)) {
                    return new MapFormInjector(type, Types.getArgumentType(pType, 0), Types.getArgumentType(pType, 1), prefix, providerFactory);
                }
            }
            return new PrefixedFormInjector(type, prefix, providerFactory);
        }
        return new FormInjector(type, providerFactory);
    } else if (findAnnotation(annotations, BeanParam.class) != null) {
        return new FormInjector(type, providerFactory);
    } else if ((matrix = findAnnotation(annotations, MatrixParam.class)) != null) {
        return new MatrixParamInjector(type, genericType, injectTarget, matrix.value(), defaultVal, encode, annotations, providerFactory);
    } else if (findAnnotation(annotations, org.jboss.resteasy.annotations.jaxrs.MatrixParam.class) != null) {
        return new MatrixParamInjector(type, genericType, injectTarget, defaultName, defaultVal, encode, annotations, providerFactory);
    } else if (findAnnotation(annotations, Context.class) != null) {
        return new ContextParameterInjector(null, type, genericType, annotations, providerFactory);
    } else if (findAnnotation(annotations, Suspended.class) != null) {
        return new AsynchronousResponseInjector();
    } else if (jakarta.ws.rs.container.AsyncResponse.class.isAssignableFrom(type)) {
        return new AsynchronousResponseInjector();
    } else if (useDefault) {
        return new MessageBodyParameterInjector(injectTargetClass, injectTarget, type, genericType, annotations, providerFactory);
    } else {
        return null;
    }
}
Also used : Collectors(java.util.stream.Collectors) HeaderParam(jakarta.ws.rs.HeaderParam) MatrixParam(jakarta.ws.rs.MatrixParam) Encoded(jakarta.ws.rs.Encoded) Query(org.jboss.resteasy.annotations.Query) Form(org.jboss.resteasy.annotations.Form) ParameterizedType(java.lang.reflect.ParameterizedType) DefaultValue(jakarta.ws.rs.DefaultValue) List(java.util.List) PathParam(jakarta.ws.rs.PathParam) Suspended(jakarta.ws.rs.container.Suspended) BeanParam(jakarta.ws.rs.BeanParam) CookieParam(jakarta.ws.rs.CookieParam) QueryParam(jakarta.ws.rs.QueryParam) FormParam(jakarta.ws.rs.FormParam) Map(java.util.Map)

Example 5 with HeaderParam

use of jakarta.ws.rs.HeaderParam in project jans by JanssenProject.

the class Fido2DeviceWebService method deleteF2Device.

@Path("{id}")
@DELETE
@Produces({ MEDIA_TYPE_SCIM_JSON + UTF8_CHARSET_FRAGMENT, MediaType.APPLICATION_JSON + UTF8_CHARSET_FRAGMENT })
@HeaderParam("Accept")
@DefaultValue(MEDIA_TYPE_SCIM_JSON)
@ProtectedApi(scopes = { "https://jans.io/scim/fido2.write" })
public Response deleteF2Device(@PathParam("id") String id) {
    Response response;
    try {
        log.debug("Executing web service method. deleteDevice");
        GluuFido2Device device = fidoDeviceService.getFido2DeviceById(null, id);
        if (device == null)
            return notFoundResponse(id, fido2ResourceType);
        response = externalConstraintsService.applyEntityCheck(device, null, httpHeaders, uriInfo, HttpMethod.DELETE, fido2ResourceType);
        if (response != null)
            return response;
        fidoDeviceService.removeFido2Device(device);
        response = Response.noContent().build();
    } catch (Exception e) {
        log.error("Failure at deleteDevice method", e);
        response = getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Unexpected error: " + e.getMessage());
    }
    return response;
}
Also used : Response(jakarta.ws.rs.core.Response) GluuFido2Device(io.jans.scim.model.GluuFido2Device) URISyntaxException(java.net.URISyntaxException) SCIMException(io.jans.scim.model.exception.SCIMException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) Path(jakarta.ws.rs.Path) DefaultValue(jakarta.ws.rs.DefaultValue) DELETE(jakarta.ws.rs.DELETE) HeaderParam(jakarta.ws.rs.HeaderParam) Produces(jakarta.ws.rs.Produces) ProtectedApi(io.jans.scim.service.filter.ProtectedApi)

Aggregations

HeaderParam (jakarta.ws.rs.HeaderParam)34 DefaultValue (jakarta.ws.rs.DefaultValue)28 Produces (jakarta.ws.rs.Produces)26 Response (jakarta.ws.rs.core.Response)25 ProtectedApi (io.jans.scim.service.filter.ProtectedApi)22 Path (jakarta.ws.rs.Path)20 URI (java.net.URI)20 URISyntaxException (java.net.URISyntaxException)20 RefAdjusted (io.jans.scim.service.scim2.interceptor.RefAdjusted)17 SCIMException (io.jans.scim.model.exception.SCIMException)16 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)16 Consumes (jakarta.ws.rs.Consumes)15 DuplicateEntryException (io.jans.orm.exception.operation.DuplicateEntryException)10 GET (jakarta.ws.rs.GET)9 POST (jakarta.ws.rs.POST)9 GluuGroup (io.jans.scim.model.GluuGroup)5 ScimCustomPerson (io.jans.scim.model.scim.ScimCustomPerson)5 DELETE (jakarta.ws.rs.DELETE)5 PUT (jakarta.ws.rs.PUT)5 PathParam (jakarta.ws.rs.PathParam)5