org.wso2.msf4j.formparam.FileInfo Java Examples
The following examples show how to use
org.wso2.msf4j.formparam.FileInfo.
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: LibsApi.java From swagger-aem with Apache License 2.0 | 6 votes |
@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 #2
Source File: TestMicroservice.java From msf4j with Apache License 2.0 | 6 votes |
@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: EtcApi.java From swagger-aem with Apache License 2.0 | 6 votes |
@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 #4
Source File: CrxApi.java From swagger-aem with Apache License 2.0 | 6 votes |
@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 #5
Source File: PathApi.java From swagger-aem with Apache License 2.0 | 6 votes |
@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 #6
Source File: IntermediatePathApiServiceImpl.java From swagger-aem with Apache License 2.0 | 6 votes |
@Override public Response postAuthorizableKeystore(String intermediatePath , String authorizableId , String colonOperation , String currentPassword , String newPassword , String rePassword , String keyPassword , String keyStorePass , String alias , String newAlias , String removeAlias , InputStream certChainInputStream, FileInfo certChainDetail , InputStream pkInputStream, FileInfo pkDetail , InputStream keyStoreInputStream, FileInfo keyStoreDetail ) throws NotFoundException { // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); }
Example #7
Source File: FakeApi.java From openapi-generator with Apache License 2.0 | 6 votes |
@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 #8
Source File: PetApi.java From openapi-generator with Apache License 2.0 | 6 votes |
@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 #9
Source File: FakeApiServiceImpl.java From openapi-generator with Apache License 2.0 | 6 votes |
@Override public Response testEndpointParameters(BigDecimal number , Double _double , String patternWithoutDelimiter , byte[] _byte , Integer integer , Integer int32 , Long int64 , Float _float , String string , InputStream binaryInputStream, FileInfo binaryDetail , Date date , Date dateTime , String password , String paramCallback ) throws NotFoundException { // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); }
Example #10
Source File: FakeApi.java From openapi-generator with Apache License 2.0 | 5 votes |
@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 #11
Source File: PathApiServiceImpl.java From swagger-aem with Apache License 2.0 | 5 votes |
@Override public Response postNode(String path , String name , String colonOperation , String deleteAuthorizable , InputStream fileInputStream, FileInfo fileDetail ) throws NotFoundException { // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); }
Example #12
Source File: CrxApiServiceImpl.java From swagger-aem with Apache License 2.0 | 5 votes |
@Override public Response postPackageServiceJson(String path , String cmd , String groupName , String packageName , String packageVersion , String charset , Boolean force , Boolean recursive , InputStream _packageInputStream, FileInfo _packageDetail ) throws NotFoundException { // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); }
Example #13
Source File: LibsApiServiceImpl.java From swagger-aem with Apache License 2.0 | 5 votes |
@Override public Response postTruststore(String colonOperation , String newPassword , String rePassword , String keyStoreType , String removeAlias , InputStream certificateInputStream, FileInfo certificateDetail ) throws NotFoundException { // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); }
Example #14
Source File: PetApiServiceImpl.java From openapi-generator with Apache License 2.0 | 5 votes |
@Override public Response uploadFile(Long petId , String additionalMetadata , InputStream fileInputStream, FileInfo fileDetail ) throws NotFoundException { // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); }
Example #15
Source File: IntermediatePathApiService.java From swagger-aem with Apache License 2.0 | 5 votes |
public abstract Response postAuthorizableKeystore(String intermediatePath ,String authorizableId ,String colonOperation ,String currentPassword ,String newPassword ,String rePassword ,String keyPassword ,String keyStorePass ,String alias ,String newAlias ,String removeAlias ,InputStream certChainInputStream, FileInfo certChainDetail ,InputStream pkInputStream, FileInfo pkDetail ,InputStream keyStoreInputStream, FileInfo keyStoreDetail ) throws NotFoundException;
Example #16
Source File: CrxApiService.java From swagger-aem with Apache License 2.0 | 5 votes |
public abstract Response postPackageServiceJson(String path ,String cmd ,String groupName ,String packageName ,String packageVersion ,String charset ,Boolean force ,Boolean recursive ,InputStream _packageInputStream, FileInfo _packageDetail ) throws NotFoundException;
Example #17
Source File: HttpResourceModelProcessor.java From msf4j with Apache License 2.0 | 5 votes |
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 #18
Source File: FormService.java From msf4j with Apache License 2.0 | 5 votes |
@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 #19
Source File: FakeApiService.java From openapi-generator with Apache License 2.0 | 5 votes |
public abstract Response testEndpointParameters(BigDecimal number ,Double _double ,String patternWithoutDelimiter ,byte[] _byte ,Integer integer ,Integer int32 ,Long int64 ,Float _float ,String string ,InputStream binaryInputStream, FileInfo binaryDetail ,Date date ,Date dateTime ,String password ,String paramCallback ) throws NotFoundException;
Example #20
Source File: IntermediatePathApi.java From swagger-aem with Apache License 2.0 | 5 votes |
@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 #21
Source File: FakeApiServiceImpl.java From openapi-generator with Apache License 2.0 | 5 votes |
@Override public Response uploadFileWithRequiredFile(Long petId , InputStream requiredFileInputStream, FileInfo requiredFileDetail , String additionalMetadata ) throws NotFoundException { // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); }
Example #22
Source File: LibsApiService.java From swagger-aem with Apache License 2.0 | 5 votes |
public abstract Response postTruststore(String colonOperation ,String newPassword ,String rePassword ,String keyStoreType ,String removeAlias ,InputStream certificateInputStream, FileInfo certificateDetail ) throws NotFoundException;
Example #23
Source File: PathApiService.java From swagger-aem with Apache License 2.0 | 4 votes |
public abstract Response postNode(String path ,String name ,String colonOperation ,String deleteAuthorizable ,InputStream fileInputStream, FileInfo fileDetail ) throws NotFoundException;
Example #24
Source File: HttpResourceModelProcessor.java From msf4j with Apache License 2.0 | 4 votes |
/** * Extract the form items in the request. * * @param request Request which need to be processed * @param paramInfo of the method * @param addFileInfo if FileInfo object needed to be added to params. In a case of InputStream this should be true * @return MultivaluedMap of form items * @throws IOException if error occurs while processing the multipart/form-data request */ private MultivaluedMap<String, Object> extractRequestFormParams(Request request, HttpResourceModel.ParameterInfo paramInfo, boolean addFileInfo) throws IOException { MultivaluedMap<String, Object> parameters = new MultivaluedHashMap<>(); if (MediaType.MULTIPART_FORM_DATA.equals(request.getContentType())) { FormParamIterator formParamIterator = new FormParamIterator(request); while (formParamIterator.hasNext()) { FormItem item = formParamIterator.next(); String cType = item.getContentType(); if (cType != null && cType.contains(";")) { cType = cType.split(";")[0]; } if (cType == null) { cType = MediaType.TEXT_PLAIN; } boolean isFile = item.getHeaders().getHeader("content-disposition").contains("filename") || MediaType.APPLICATION_OCTET_STREAM.equals(item.getHeaders().getHeader("content-type")); formParamContentType.putIfAbsent(item.getFieldName(), cType); List<Object> existingValues = parameters.get(item.getFieldName()); if (existingValues == null) { parameters.put(item.getFieldName(), isFile ? new ArrayList<>(Collections.singletonList(createAndTrackTempFile(item))) : new ArrayList<>(Collections.singletonList(StreamUtil.asString(item.openStream())))); } else { existingValues.add(isFile ? createAndTrackTempFile(item) : StreamUtil.asString(item.openStream())); } if (addFileInfo && isFile) { //Create FileInfo bean to handle InputStream FileInfo fileInfo = new FileInfo(); fileInfo.setFileName(item.getName()); fileInfo.setContentType(item.getContentType()); parameters.putSingle(item.getFieldName() + FILEINFO_POSTFIX, fileInfo); } } } else if (MediaType.APPLICATION_FORM_URLENCODED.equals(request.getContentType())) { try (InputStream inputStream = request.getMessageContentStream()) { String bodyStr = BeanConverter .getConverter((request.getContentType() != null) ? request.getContentType() : MediaType .WILDCARD).convertToObject(inputStream, paramInfo.getParameterType()).toString(); QueryStringDecoderUtil queryStringDecoderUtil = new QueryStringDecoderUtil(bodyStr, false); queryStringDecoderUtil.parameters().entrySet(). forEach(entry -> parameters.put(entry.getKey(), new ArrayList<>(entry.getValue()))); } } return parameters; }
Example #25
Source File: FakeApiService.java From openapi-generator with Apache License 2.0 | 4 votes |
public abstract Response uploadFileWithRequiredFile(Long petId ,InputStream requiredFileInputStream, FileInfo requiredFileDetail ,String additionalMetadata ) throws NotFoundException;
Example #26
Source File: PetApiService.java From openapi-generator with Apache License 2.0 | 4 votes |
public abstract Response uploadFile(Long petId ,String additionalMetadata ,InputStream fileInputStream, FileInfo fileDetail ) throws NotFoundException;
Example #27
Source File: EtcApiService.java From swagger-aem with Apache License 2.0 | 4 votes |
public abstract Response postTruststorePKCS12(InputStream truststoreP12InputStream, FileInfo truststoreP12Detail ) throws NotFoundException;
Example #28
Source File: EtcApiServiceImpl.java From swagger-aem with Apache License 2.0 | 4 votes |
@Override public Response postTruststorePKCS12(InputStream truststoreP12InputStream, FileInfo truststoreP12Detail ) throws NotFoundException { // do some magic! return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); }