org.wso2.msf4j.formparam.FormDataParam Java Examples

The following examples show how to use org.wso2.msf4j.formparam.FormDataParam. 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: FormService.java    From msf4j with Apache License 2.0 6 votes vote down vote up
@POST
@Path("/complexForm")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response complexForm(@FormDataParam("file") File file,
                            @FormDataParam("id") int id,
                            @FormDataParam("people") List<Person> personList,
                            @FormDataParam("company") Company company) {
    System.out.println("First Person in List " + personList.get(0).getName());
    System.out.println("Id " + id);
    System.out.println("Company " + company.getType());
    try {
        Files.copy(file.toPath(), Paths.get(System.getProperty("java.io.tmpdir"), file.getName()));
    } catch (IOException e) {
        log.error("Error while Copying the file " + e.getMessage(), e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
    return Response.ok().entity("Request completed").build();
}
 
Example #2
Source File: TestMicroservice.java    From msf4j with Apache License 2.0 6 votes vote down vote up
@POST
@Path("/streamFile")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response multipleFiles(@FormDataParam("file") FileInfo fileInfo,
                              @FormDataParam("file") InputStream inputStream) {
    StringBuilder stringBuilder = new StringBuilder();
    try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream))) {
        while (bufferedReader.ready()) {
            stringBuilder.append(bufferedReader.readLine());
        }
    } catch (IOException e) {
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    } finally {
        IOUtils.closeQuietly(inputStream);
    }
    return Response.ok().entity(stringBuilder.toString() + "-" + fileInfo.getFileName()).build();
}
 
Example #3
Source File: FormService.java    From msf4j with Apache License 2.0 6 votes vote down vote up
@POST
@Path("/multipleFiles")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response multipleFiles(@FormDataParam("files") List<File> files) {
    StringBuilder response = new StringBuilder();
    files.forEach(file -> {
        try {
            Files.copy(file.toPath(), Paths.get(System.getProperty("java.io.tmpdir"), file.getName()));
        } catch (IOException e) {
            response.append("Unable to upload the file ").append(e.getMessage());
            log.error("Error while Copying the file " + e.getMessage(), e);
        }
    });
    if (!response.toString().isEmpty()) {
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(response.toString()).build();
    }
    return Response.ok().entity("Request completed").build();
}
 
Example #4
Source File: PetApi.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@POST
    @Path("/{petId}/uploadImage")
    @Consumes({ "multipart/form-data" })
    @Produces({ "application/json" })
    @io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = {
        @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = {
            @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
            @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets")
        })
    }, tags={ "pet", })
    @io.swagger.annotations.ApiResponses(value = { 
        @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) })
    public Response uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathParam("petId") Long petId
,@ApiParam(value = "Additional data to pass to server")@FormDataParam("additionalMetadata")  String additionalMetadata
,
            @FormDataParam("file") InputStream fileInputStream,
            @FormDataParam("file") FileInfo fileDetail
)
    throws NotFoundException {
        return delegate.uploadFile(petId,additionalMetadata,fileInputStream, fileDetail);
    }
 
Example #5
Source File: EtcApi.java    From swagger-aem with Apache License 2.0 6 votes vote down vote up
@POST
    @Path("/truststore")
    @Consumes({ "multipart/form-data" })
    @Produces({ "text/plain" })
    @io.swagger.annotations.ApiOperation(value = "", notes = "", response = String.class, authorizations = {
        @io.swagger.annotations.Authorization(value = "aemAuth")
    }, tags={ "sling", })
    @io.swagger.annotations.ApiResponses(value = { 
        @io.swagger.annotations.ApiResponse(code = 200, message = "Default response", response = String.class) })
    public Response postTruststorePKCS12(
            @FormDataParam("truststore.p12") InputStream truststoreP12InputStream,
            @FormDataParam("truststore.p12") FileInfo truststoreP12Detail
)
    throws NotFoundException {
        return delegate.postTruststorePKCS12(truststoreP12InputStream, truststoreP12Detail);
    }
 
Example #6
Source File: CrxApi.java    From swagger-aem with Apache License 2.0 6 votes vote down vote up
@POST
    @Path("/packmgr/service/.json/{path}")
    @Consumes({ "multipart/form-data" })
    @Produces({ "application/json" })
    @io.swagger.annotations.ApiOperation(value = "", notes = "", response = String.class, authorizations = {
        @io.swagger.annotations.Authorization(value = "aemAuth")
    }, tags={ "crx", })
    @io.swagger.annotations.ApiResponses(value = { 
        @io.swagger.annotations.ApiResponse(code = 200, message = "Default response", response = String.class) })
    public Response postPackageServiceJson(@ApiParam(value = "",required=true) @PathParam("path") String path
,@ApiParam(value = "",required=true) @QueryParam("cmd") String cmd
,@ApiParam(value = "") @QueryParam("groupName") String groupName
,@ApiParam(value = "") @QueryParam("packageName") String packageName
,@ApiParam(value = "") @QueryParam("packageVersion") String packageVersion
,@ApiParam(value = "") @QueryParam("_charset_") String charset
,@ApiParam(value = "") @QueryParam("force") Boolean force
,@ApiParam(value = "") @QueryParam("recursive") Boolean recursive
,
            @FormDataParam("package") InputStream _packageInputStream,
            @FormDataParam("package") FileInfo _packageDetail
)
    throws NotFoundException {
        return delegate.postPackageServiceJson(path,cmd,groupName,packageName,packageVersion,charset,force,recursive,_packageInputStream, _packageDetail);
    }
 
Example #7
Source File: PathApi.java    From swagger-aem with Apache License 2.0 6 votes vote down vote up
@POST
    @Path("/{name}")
    @Consumes({ "multipart/form-data" })
    
    @io.swagger.annotations.ApiOperation(value = "", notes = "", response = Void.class, authorizations = {
        @io.swagger.annotations.Authorization(value = "aemAuth")
    }, tags={ "sling", })
    @io.swagger.annotations.ApiResponses(value = { 
        @io.swagger.annotations.ApiResponse(code = 200, message = "Default response", response = Void.class) })
    public Response postNode(@ApiParam(value = "",required=true) @PathParam("path") String path
,@ApiParam(value = "",required=true) @PathParam("name") String name
,@ApiParam(value = "") @QueryParam(":operation") String colonOperation
,@ApiParam(value = "") @QueryParam("deleteAuthorizable") String deleteAuthorizable
,
            @FormDataParam("file") InputStream fileInputStream,
            @FormDataParam("file") FileInfo fileDetail
)
    throws NotFoundException {
        return delegate.postNode(path,name,colonOperation,deleteAuthorizable,fileInputStream, fileDetail);
    }
 
Example #8
Source File: LibsApi.java    From swagger-aem with Apache License 2.0 6 votes vote down vote up
@POST
    @Path("/granite/security/post/truststore")
    @Consumes({ "multipart/form-data" })
    @Produces({ "text/plain" })
    @io.swagger.annotations.ApiOperation(value = "", notes = "", response = String.class, authorizations = {
        @io.swagger.annotations.Authorization(value = "aemAuth")
    }, tags={ "sling", })
    @io.swagger.annotations.ApiResponses(value = { 
        @io.swagger.annotations.ApiResponse(code = 200, message = "Default response", response = String.class) })
    public Response postTruststore(@ApiParam(value = "") @QueryParam(":operation") String colonOperation
,@ApiParam(value = "") @QueryParam("newPassword") String newPassword
,@ApiParam(value = "") @QueryParam("rePassword") String rePassword
,@ApiParam(value = "") @QueryParam("keyStoreType") String keyStoreType
,@ApiParam(value = "") @QueryParam("removeAlias") String removeAlias
,
            @FormDataParam("certificate") InputStream certificateInputStream,
            @FormDataParam("certificate") FileInfo certificateDetail
)
    throws NotFoundException {
        return delegate.postTruststore(colonOperation,newPassword,rePassword,keyStoreType,removeAlias,certificateInputStream, certificateDetail);
    }
 
Example #9
Source File: FakeApi.java    From openapi-generator with Apache License 2.0 6 votes vote down vote up
@POST
    @Path("/{petId}/uploadImageWithRequiredFile")
    @Consumes({ "multipart/form-data" })
    @Produces({ "application/json" })
    @io.swagger.annotations.ApiOperation(value = "uploads an image (required)", notes = "", response = ModelApiResponse.class, authorizations = {
        @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = {
            @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
            @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets")
        })
    }, tags={ "pet", })
    @io.swagger.annotations.ApiResponses(value = { 
        @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) })
    public Response uploadFileWithRequiredFile(@ApiParam(value = "ID of pet to update",required=true) @PathParam("petId") Long petId
,
            @FormDataParam("requiredFile") InputStream requiredFileInputStream,
            @FormDataParam("requiredFile") FileInfo requiredFileDetail
,@ApiParam(value = "Additional data to pass to server")@FormDataParam("additionalMetadata")  String additionalMetadata
)
    throws NotFoundException {
        return delegate.uploadFileWithRequiredFile(petId,requiredFileInputStream, requiredFileDetail,additionalMetadata);
    }
 
Example #10
Source File: IntermediatePathApi.java    From swagger-aem with Apache License 2.0 5 votes vote down vote up
@POST
    @Path("/{authorizableId}.ks.html")
    @Consumes({ "multipart/form-data" })
    @Produces({ "text/plain" })
    @io.swagger.annotations.ApiOperation(value = "", notes = "", response = KeystoreInfo.class, authorizations = {
        @io.swagger.annotations.Authorization(value = "aemAuth")
    }, tags={ "sling", })
    @io.swagger.annotations.ApiResponses(value = { 
        @io.swagger.annotations.ApiResponse(code = 200, message = "Retrieved Authorizable Keystore info", response = KeystoreInfo.class),
        
        @io.swagger.annotations.ApiResponse(code = 200, message = "Default response", response = KeystoreInfo.class) })
    public Response postAuthorizableKeystore(@ApiParam(value = "",required=true) @PathParam("intermediatePath") String intermediatePath
,@ApiParam(value = "",required=true) @PathParam("authorizableId") String authorizableId
,@ApiParam(value = "") @QueryParam(":operation") String colonOperation
,@ApiParam(value = "") @QueryParam("currentPassword") String currentPassword
,@ApiParam(value = "") @QueryParam("newPassword") String newPassword
,@ApiParam(value = "") @QueryParam("rePassword") String rePassword
,@ApiParam(value = "") @QueryParam("keyPassword") String keyPassword
,@ApiParam(value = "") @QueryParam("keyStorePass") String keyStorePass
,@ApiParam(value = "") @QueryParam("alias") String alias
,@ApiParam(value = "") @QueryParam("newAlias") String newAlias
,@ApiParam(value = "") @QueryParam("removeAlias") String removeAlias
,
            @FormDataParam("cert-chain") InputStream certChainInputStream,
            @FormDataParam("cert-chain") FileInfo certChainDetail
,
            @FormDataParam("pk") InputStream pkInputStream,
            @FormDataParam("pk") FileInfo pkDetail
,
            @FormDataParam("keyStore") InputStream keyStoreInputStream,
            @FormDataParam("keyStore") FileInfo keyStoreDetail
)
    throws NotFoundException {
        return delegate.postAuthorizableKeystore(intermediatePath,authorizableId,colonOperation,currentPassword,newPassword,rePassword,keyPassword,keyStorePass,alias,newAlias,removeAlias,certChainInputStream, certChainDetail,pkInputStream, pkDetail,keyStoreInputStream, keyStoreDetail);
    }
 
Example #11
Source File: FormService.java    From msf4j with Apache License 2.0 5 votes vote down vote up
@POST
@Path("/streamFile")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response multipleFiles(@FormDataParam("file") FileInfo fileInfo,
                              @FormDataParam("file") InputStream inputStream) {
    try {
        Files.copy(inputStream, Paths.get(System.getProperty("java.io.tmpdir"), fileInfo.getFileName()));
    } catch (IOException e) {
        log.error("Error while Copying the file " + e.getMessage(), e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    } finally {
        IOUtils.closeQuietly(inputStream);
    }
    return Response.ok().entity("Request completed").build();
}
 
Example #12
Source File: HttpResourceModelProcessor.java    From msf4j with Apache License 2.0 5 votes vote down vote up
private Object getFormDataParamValue(HttpResourceModel.ParameterInfo<List<Object>> paramInfo, Request request)
        throws FormUploadException, IOException {
    Type paramType = paramInfo.getParameterType();
    FormDataParam formDataParam = paramInfo.getAnnotation();
    if (getFormParameters() == null) {
        setFormParameters(extractRequestFormParams(request, paramInfo, true));
    }

    List<Object> parameter = getParameter(formDataParam.value());
    boolean isNotNull = (parameter != null);
    if (paramInfo.getConverter() != null) {
        // We need to skip the conversion for java.io.File types and handle special cases
        if (paramType instanceof ParameterizedType && isNotNull &&
                parameter.get(0).getClass().isAssignableFrom(File.class)) {
            return parameter;
        } else if (isNotNull && parameter.get(0).getClass().isAssignableFrom(File.class)) {
            return parameter.get(0);
        } else if (MediaType.TEXT_PLAIN.equalsIgnoreCase(formParamContentType.get(formDataParam.value()))) {
            return paramInfo.convert(parameter);
        } else if (MediaType.APPLICATION_FORM_URLENCODED.equals(request.getContentType())) {
            return paramInfo.convert(parameter);
        }
        // Beans with string constructor
        return createBean(parameter, formDataParam, paramType, isNotNull);
    }
    // We only support InputStream for a single file. Therefore only get first element from the list
    if (paramType == InputStream.class && isNotNull && parameter.get(0).getClass().isAssignableFrom(File.class)) {
        return new FileInputStream((File) parameter.get(0));
    } else if (paramType == FileInfo.class) {
        List<Object> fileInfo = getParameter(formDataParam.value() + FILEINFO_POSTFIX);
        return fileInfo == null ? null : fileInfo.get(0);
    }
    // These are beans without having string constructor. Convert using existing BeanConverter
    return createBean(parameter, formDataParam, paramType, isNotNull);
}
 
Example #13
Source File: TestMicroservice.java    From msf4j with Apache License 2.0 5 votes vote down vote up
@POST
@Path("/complexForm")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response complexForm(@FormDataParam("file") File file,
                            @FormDataParam("id") int id,
                            @FormDataParam("people") List<Person> personList,
                            @FormDataParam("company") Company company) {
    return Response.ok().entity(file.getName() + ":" + id + ":" + personList.size() + ":" + company.getType())
            .build();
}
 
Example #14
Source File: FakeApi.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
@POST
    
    @Consumes({ "application/x-www-form-urlencoded" })
    
    @io.swagger.annotations.ApiOperation(value = "Fake endpoint for testing various parameters  假端點  偽のエンドポイント  가짜 엔드 포인트", notes = "Fake endpoint for testing various parameters  假端點  偽のエンドポイント  가짜 엔드 포인트", response = Void.class, authorizations = {
        @io.swagger.annotations.Authorization(value = "http_basic_test")
    }, tags={ "fake", })
    @io.swagger.annotations.ApiResponses(value = { 
        @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class),
        
        @io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = Void.class) })
    public Response testEndpointParameters(@ApiParam(value = "None", required=true)  @FormParam("number")  BigDecimal number
,@ApiParam(value = "None", required=true)  @FormParam("double")  Double _double
,@ApiParam(value = "None", required=true)  @FormParam("pattern_without_delimiter")  String patternWithoutDelimiter
,@ApiParam(value = "None", required=true)  @FormParam("byte")  byte[] _byte
,@ApiParam(value = "None")  @FormParam("integer")  Integer integer
,@ApiParam(value = "None")  @FormParam("int32")  Integer int32
,@ApiParam(value = "None")  @FormParam("int64")  Long int64
,@ApiParam(value = "None")  @FormParam("float")  Float _float
,@ApiParam(value = "None")  @FormParam("string")  String string
,
            @FormDataParam("binary") InputStream binaryInputStream,
            @FormDataParam("binary") FileInfo binaryDetail
,@ApiParam(value = "None")  @FormParam("date")  Date date
,@ApiParam(value = "None")  @FormParam("dateTime")  Date dateTime
,@ApiParam(value = "None")  @FormParam("password")  String password
,@ApiParam(value = "None")  @FormParam("callback")  String paramCallback
)
    throws NotFoundException {
        return delegate.testEndpointParameters(number,_double,patternWithoutDelimiter,_byte,integer,int32,int64,_float,string,binaryInputStream, binaryDetail,date,dateTime,password,paramCallback);
    }
 
Example #15
Source File: FormService.java    From msf4j with Apache License 2.0 4 votes vote down vote up
@POST
@Path("/simpleForm")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED, MediaType.MULTIPART_FORM_DATA })
public Response simpleForm(@FormDataParam("age") int age, @FormDataParam("name") String name) {
    return Response.ok().entity("Name and age " + name + ", " + age).build();
}
 
Example #16
Source File: FormService.java    From msf4j with Apache License 2.0 4 votes vote down vote up
@POST
@Path("/simpleFormWithList")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED, MediaType.MULTIPART_FORM_DATA })
public Response simpleFormWithList(@FormDataParam("name") List<String> name) {
    return Response.ok().entity("Name " + name).build();
}
 
Example #17
Source File: HttpResourceModelProcessor.java    From msf4j with Apache License 2.0 4 votes vote down vote up
/**
 * Build an HttpMethodInfo object to dispatch the request.
 *
 * @param request     HttpRequest to be handled.
 * @param responder   HttpResponder to write the response.
 * @param groupValues Values needed for the invocation.
 * @return HttpMethodInfo
 * @throws HandlerException If an error occurs
 */
@SuppressWarnings("unchecked")
public HttpMethodInfo buildHttpMethodInfo(Request request,
                                          Response responder,
                                          Map<String, String> groupValues)
        throws HandlerException {
    try {
        //Setup args for reflection call
        List<HttpResourceModel.ParameterInfo<?>> paramInfoList = httpResourceModel.getParamInfoList();
        Object[] args = new Object[paramInfoList.size()];
        int idx = 0;
        for (HttpResourceModel.ParameterInfo<?> paramInfo : paramInfoList) {
            if (paramInfo.getAnnotation() != null) {
                Class<? extends Annotation> annotationType = paramInfo.getAnnotation().annotationType();
                if (PathParam.class.isAssignableFrom(annotationType)) {
                    args[idx] = getPathParamValue((HttpResourceModel.ParameterInfo<String>) paramInfo,
                            groupValues);
                } else if (QueryParam.class.isAssignableFrom(annotationType)) {
                    args[idx] = getQueryParamValue((HttpResourceModel.ParameterInfo<List<String>>) paramInfo,
                            request.getUri());
                } else if (HeaderParam.class.isAssignableFrom(annotationType)) {
                    args[idx] = getHeaderParamValue((HttpResourceModel.ParameterInfo<List<String>>) paramInfo,
                            request);
                } else if (CookieParam.class.isAssignableFrom(annotationType)) {
                    args[idx] = getCookieParamValue((HttpResourceModel.ParameterInfo<String>) paramInfo,
                            request);
                } else if (Context.class.isAssignableFrom(annotationType)) {
                    args[idx] = getContextParamValue((HttpResourceModel.ParameterInfo<Object>) paramInfo,
                            request, responder);
                } else if (FormParam.class.isAssignableFrom(annotationType)) {
                    args[idx] = getFormParamValue((HttpResourceModel.ParameterInfo<List<Object>>) paramInfo,
                            request);
                } else if (FormDataParam.class.isAssignableFrom(annotationType)) {
                    args[idx] = getFormDataParamValue((HttpResourceModel.ParameterInfo<List<Object>>) paramInfo,
                            request);
                } else {
                    createObject(request, args, idx, paramInfo);
                }
            } else {
                // If an annotation is not present the parameter is considered a
                // request body data parameter
                createObject(request, args, idx, paramInfo);
            }
            idx++;
        }

        if (httpStreamer == null) {
            return new HttpMethodInfo(httpResourceModel.getMethod(),
                    httpResourceModel.getHttpHandler(),
                    args, formParameters,
                    responder);
        } else {
            return new HttpMethodInfo(httpResourceModel.getMethod(),
                    httpResourceModel.getHttpHandler(),
                    args, formParameters,
                    responder,
                    httpStreamer);
        }
    } catch (Throwable e) {
        throw new HandlerException(javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR,
                String.format("Error in executing request: %s %s", request.getHttpMethod(),
                        request.getUri()), e);
    }
}
 
Example #18
Source File: HttpResourceModel.java    From msf4j with Apache License 2.0 4 votes vote down vote up
/**
 * Gathers all parameters' annotations for the given method, starting from the third parameter.
 */
private List<ParameterInfo<?>> makeParamInfoList(Method method) {
    List<ParameterInfo<?>> paramInfoList = new ArrayList<>();

    Type[] paramTypes = method.getGenericParameterTypes();
    Annotation[][] paramAnnotations = method.getParameterAnnotations();

    for (int i = 0; i < paramAnnotations.length; i++) {
        Annotation[] annotations = paramAnnotations[i];

        //Can have only one from @PathParam, @QueryParam, @HeaderParam or @Context.
        if (Utils.getIntersection(SUPPORTED_PARAM_ANNOTATIONS,
                                  Collections.unmodifiableSet(new HashSet(Arrays.asList(annotations)))) > 1) {
            throw new IllegalArgumentException(
                    String.format("Must have exactly one annotation from %s for parameter %d in method %s",
                            SUPPORTED_PARAM_ANNOTATIONS, i, method));
        }

        Annotation annotation = null;
        Type parameterType = paramTypes[i];
        Function<?, Object> converter = null;
        String defaultVal = null;
        for (Annotation annotation0 : annotations) {
            annotation = annotation0;
            Class<? extends Annotation> annotationType = annotation.annotationType();
            if (PathParam.class.isAssignableFrom(annotationType)) {
                converter = ParamConvertUtils.createPathParamConverter(parameterType);
            } else if (QueryParam.class.isAssignableFrom(annotationType)) {
                converter = ParamConvertUtils.createQueryParamConverter(parameterType);
            } else if (FormParam.class.isAssignableFrom(annotationType)) {
                converter = ParamConvertUtils.createFormParamConverter(parameterType);
            } else if (FormDataParam.class.isAssignableFrom(annotationType)) {
                converter = ParamConvertUtils.createFormDataParamConverter(parameterType);
            } else if (HeaderParam.class.isAssignableFrom(annotationType)) {
                converter = ParamConvertUtils.createHeaderParamConverter(parameterType);
            } else if (CookieParam.class.isAssignableFrom(annotationType)) {
                converter = ParamConvertUtils.createCookieParamConverter(parameterType);
            } else if (DefaultValue.class.isAssignableFrom(annotationType)) {
                defaultVal = ((DefaultValue) annotation).value();
            }
        }
        ParameterInfo<?> parameterInfo = ParameterInfo.create(parameterType, annotation, defaultVal, converter);
        paramInfoList.add(parameterInfo);
    }

    return Collections.unmodifiableList(paramInfoList);
}
 
Example #19
Source File: TestMicroservice.java    From msf4j with Apache License 2.0 4 votes vote down vote up
@Path("/formDataParam")
@POST
@Consumes({MediaType.APPLICATION_FORM_URLENCODED, MediaType.MULTIPART_FORM_DATA})
public Response tesFormDataParam(@FormDataParam("name") String name, @FormDataParam("age") int age) {
    return Response.ok().entity(name + ":" + age).build();
}
 
Example #20
Source File: TestMicroservice.java    From msf4j with Apache License 2.0 4 votes vote down vote up
@POST
@Path("/multipleFiles")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response multipleFiles(@FormDataParam("files") List<File> files) {
    return Response.ok().entity(files.size()).build();
}