javax.ws.rs.core.MediaType#MULTIPART_FORM_DATA源码实例Demo

下面列出了javax.ws.rs.core.MediaType#MULTIPART_FORM_DATA 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: o2oa   文件: AttachmentAction.java
@JaxrsMethodDescribe(value = "上传附件.", action = ActionUploadCallback.class)
@POST
@Path("upload/work/{workId}/callback/{callback}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(HttpMediaType.TEXT_HTML_UTF_8)
public void uploadCallback(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
		@JaxrsParameterDescribe("工作标识") @PathParam("workId") String workId,
		@JaxrsParameterDescribe("回调函数名") @PathParam("callback") String callback,
		@JaxrsParameterDescribe("位置") @FormDataParam("site") String site,
		@JaxrsParameterDescribe("附件名称") @FormDataParam(FILENAME_FIELD) String fileName,
		@FormDataParam(FILE_FIELD) final byte[] bytes,
		@FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
	ActionResult<ActionUploadCallback.Wo<ActionUploadCallback.WoObject>> result = new ActionResult<>();
	EffectivePerson effectivePerson = this.effectivePerson(request);
	try {
		result = new ActionUploadCallback().execute(effectivePerson, workId, callback, site, fileName, bytes,
				disposition);
	} catch (Exception e) {
		logger.error(e, effectivePerson, request, null);
		result.error(e);
	}
	asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
 
源代码2 项目: o2oa   文件: AttachmentAction.java
/** callback方法与前台ie低版本兼容使用post方法 */
@JaxrsMethodDescribe(value = "更新会议附件内容", action = ActionUpdateCallback.class)
@POST
@Path("{id}/update/callback/{ballback}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(HttpMediaType.TEXT_HTML_UTF_8)
public void updateCallback(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
		@JaxrsParameterDescribe("会议标识") @PathParam("id") String id,
		@JaxrsParameterDescribe("回调函数名") @PathParam("callback") String callback,
		@FormDataParam(FILE_FIELD) final byte[] bytes,
		@JaxrsParameterDescribe("文件") @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
	ActionResult<ActionUpdateCallback.Wo<ActionUpdateCallback.WoObject>> result = new ActionResult<>();
	EffectivePerson effectivePerson = this.effectivePerson(request);
	try {
		result = new ActionUpdateCallback().execute(effectivePerson, id, callback, bytes, disposition);
	} catch (Exception e) {
		logger.error(e, effectivePerson, request, null);
		result.error(e);
	}
	asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
 
源代码3 项目: o2oa   文件: OkrWorkImportAction.java
@JaxrsMethodDescribe(value = "进行工作信息导入", action = ActionWorkImport.class)
@POST
@Path("center/{centerId}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public void importWork(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
		@JaxrsParameterDescribe("中心工作ID") @PathParam("centerId") String centerId,
		@JaxrsParameterDescribe("位置") @FormDataParam("site") String site,
		@FormDataParam(FILE_FIELD) final byte[] bytes,
		@FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
	EffectivePerson effectivePerson = this.effectivePerson(request);
	ActionResult<Object> result = new ActionResult<>();
	try {
		result = new ActionWorkImport().execute(request, effectivePerson, centerId, site, bytes, disposition);
	} catch (Exception e) {
		result = new ActionResult<>();
		logger.warn("系统根据中心工作ID获取中心工作所有附件信息过程发生异常。");
		logger.error(e, effectivePerson, request, null);
	}
	asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
 
源代码4 项目: streamline   文件: UDFCatalogResource.java
/**
 * Add a new UDF.
 * <p>
 * curl -X POST 'http://localhost:8080/api/v1/catalog/udfs' -F udfJarFile=/tmp/foo-function.jar
 * -F udfConfig='{"name":"Foo", "description": "testing", "type":"FUNCTION", "className":"com.test.Foo"};type=application/json'
 * </p>
 */
@Timed
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("/udfs")
public Response addUDF(@FormDataParam("udfJarFile") final InputStream inputStream,
                       @FormDataParam("udfJarFile") final FormDataContentDisposition contentDispositionHeader,
                       @FormDataParam("udfConfig") final FormDataBodyPart udfConfig,
                       @FormDataParam("builtin") final boolean builtin,
                       @Context SecurityContext securityContext) throws Exception {
    SecurityUtil.checkRole(authorizer, securityContext, Roles.ROLE_UDF_ADMIN);
    MediaType mediaType = udfConfig.getMediaType();
    LOG.debug("Media type {}", mediaType);
    if (!mediaType.equals(MediaType.APPLICATION_JSON_TYPE)) {
        throw new UnsupportedMediaTypeException(mediaType.toString());
    }
    UDF udf = udfConfig.getValueAs(UDF.class);
    processUdf(inputStream, udf, true, builtin);
    UDF createdUdf = catalogService.addUDF(udf);
    SecurityUtil.addAcl(authorizer, securityContext, UDF.NAMESPACE, createdUdf.getId(), EnumSet.allOf(Permission.class));
    return WSUtils.respondEntity(createdUdf, CREATED);
}
 
源代码5 项目: irontest   文件: AssertionResource.java
/**
 * Save the uploaded XSD file (or zip file) into the (XMLValidAgainstXSD) assertion.
 * Use @POST instead of @PUT because ng-file-upload seems not working with PUT.
 * @param assertionId
 * @param inputStream
 * @param contentDispositionHeader
 * @return
 */
@POST @Path("assertions/{assertionId}/xsdFile")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@PermitAll
public void saveXSDFile(@PathParam("assertionId") long assertionId,
                                @FormDataParam("file") InputStream inputStream,
                                @FormDataParam("file") FormDataContentDisposition contentDispositionHeader) throws IOException {
    //  check the file
    String fileName = contentDispositionHeader.getFileName();
    if (!(fileName.toLowerCase().endsWith(".xsd") || fileName.toLowerCase().endsWith(".zip"))) {
        throw new IllegalArgumentException("Only XSD file and Zip file are supported.");
    }

    XMLValidAgainstXSDAssertionProperties properties = new XMLValidAgainstXSDAssertionProperties();
    properties.setFileName(fileName);
    byte[] fileBytes;
    try {
        fileBytes = IOUtils.toByteArray(inputStream);
    } finally {
        inputStream.close();
    }
    properties.setFileBytes(fileBytes);
    assertionDAO.updateOtherProperties(assertionId, properties);
}
 
源代码6 项目: o2oa   文件: FileAction.java
@JaxrsMethodDescribe(value = "创建Attachment的内容并返回回调.", action = ActionUploadCallback.class)
@POST
@Path("upload/referencetype/{referenceType}/reference/{reference}/scale/{scale}/callback/{callback}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(HttpMediaType.TEXT_HTML_UTF_8)
public void uploadCallback(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
		@JaxrsParameterDescribe("文件类型") @PathParam("referenceType") String referenceType,
		@JaxrsParameterDescribe("关联id") @PathParam("reference") String reference,
		@JaxrsParameterDescribe("缩放") @PathParam("scale") Integer scale,
		@JaxrsParameterDescribe("回调函数名") @PathParam("callback") String callback,
		@FormDataParam(FILE_FIELD) final byte[] bytes,
		@JaxrsParameterDescribe("上传文件") @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition) {
	ActionResult<ActionUploadCallback.Wo<ActionUploadCallback.WoObject>> result = new ActionResult<>();
	EffectivePerson effectivePerson = this.effectivePerson(request);
	try {
		result = new ActionUploadCallback().execute(effectivePerson, referenceType, reference, scale, callback,
				bytes, disposition);
	} catch (Exception e) {
		logger.error(e, effectivePerson, request, null);
		result.error(e);
	}
	asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
 
源代码7 项目: jwala   文件: ResourceServiceRest.java
/**
 * Upload the external properties file
 *
 * @param user a logged in user who's calling this service  @return {@link Response}
 */
@POST
@Path("/properties")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@ApiOperation(value = "Upload the external properties file",
        response = CreateResourceResponseWrapper.class
)
@ApiResponses(@ApiResponse(code = 500, message = "File exceptions thrown while attempting to upload external properties file"))
Response uploadExternalProperties(@ApiParam(value = "The authentication details of user") @BeanParam AuthenticatedUser user);
 
源代码8 项目: container   文件: CsarController.java
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces( {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@ApiOperation(hidden = true, value = "")
public Response uploadCsar(@FormDataParam("enrichment") final String applyEnrichment,
                           @FormDataParam("file") final InputStream is,
                           @FormDataParam("file") final FormDataContentDisposition file) {
    logger.debug("Invoking uploadCsar");
    if (is == null || file == null) {
        return Response.status(Status.BAD_REQUEST).build();
    }
    logger.info("Uploading new CSAR file \"{}\", size {}", file.getFileName(), file.getSize());
    return handleCsarUpload(file.getFileName(), is, applyEnrichment);
}
 
源代码9 项目: entity-fishing   文件: NerdRestService.java
@POST
@Path(CUSTOMISATIONS)
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response addCustomisation(@FormDataParam(NAME) String name, @FormDataParam(VALUE) String content) {
    boolean ok = false;
    Response response = null;
    try {
        ok = NerdRestCustomisation.createCustomisation(name, content);
        response = Response
                .status(Response.Status.OK)
                .entity(responseJson(ok, null))
                .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON + "; charset=UTF-8")
                .header("Access-Control-Allow-Origin", "*")
                .header("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT")
                .build();

    } catch (CustomisationException ce) {
        response = Response
                .status(Response.Status.BAD_REQUEST)
                .entity(responseJson(ok, ce.getMessage()))
                .build();

    } catch (Exception e) {
        response = Response
                .status(Response.Status.INTERNAL_SERVER_ERROR)
                .build();
    }
    return response;
}
 
源代码10 项目: dcos-commons   文件: StateResource.java
/**
 * @see StateQueries
 */
@Path("/files/{name}")
@PUT
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response putFile(
    @PathParam("name") String name,
    @FormDataParam("file") InputStream uploadedInputStream,
    @FormDataParam("file") FormDataContentDisposition fileDetails)
{
  return StateQueries.putFile(stateStore, name, uploadedInputStream, fileDetails);
}
 
源代码11 项目: irontest   文件: FolderResource.java
@POST @Path("{folderId}/importTestcase")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@PermitAll
public Testcase importTestcase(@PathParam("folderId") long folderId, @FormDataParam("file") InputStream inputStream,
                           @FormDataParam("file") FormDataContentDisposition contentDispositionHeader) throws IOException {
    ObjectMapper objectMapper = new ObjectMapper();
    Testcase testcase = objectMapper.readValue(inputStream, Testcase.class);
    long testcaseId = testcaseDAO.createByImport(testcase, folderId);
    Testcase result = new Testcase();
    result.setId(testcaseId);
    return result;
}
 
源代码12 项目: onos   文件: YangWebResource.java
/**
 * Compiles and registers the given yang files.
 *
 * @param modelId model identifier
 * @param stream  YANG, ZIP or JAR file
 * @return 200 OK
 * @throws IOException when fails to generate a file
 */
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response upload(@QueryParam("modelId") @DefaultValue("org.onosproject.model.unknown") String modelId,
                       @FormDataParam("file") InputStream stream) throws IOException {
    YangLiveCompilerService compiler = get(YangLiveCompilerService.class);
    ApplicationAdminService appService = get(ApplicationAdminService.class);
    modelId = getValidModelId(modelId);
    appService.install(compiler.compileYangFiles(modelId, stream));
    appService.activate(appService.getId(modelId));
    return Response.ok().build();
}
 
源代码13 项目: jrestless-examples   文件: ApiResource.java
@POST
@Path("/upload")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public void uploadFile(
		@FormDataParam("file") InputStream uploadedInputStream,
		@FormDataParam("file") FormDataBodyPart body) {
	LOG.info("file name: {}", body.getContentDisposition().getFileName());
	LOG.info("file type: {}", body.getMediaType());
	LOG.info("file contents: {}", new String(toByteArray(uploadedInputStream), StandardCharsets.UTF_8));
}
 
源代码14 项目: ctsms   文件: JobResource.java
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({ MediaType.APPLICATION_JSON })
public JobOutVO addJob(@FormDataParam("json") FormDataBodyPart json,
		@FormDataParam("data") FormDataBodyPart content,
		@FormDataParam("data") FormDataContentDisposition contentDisposition,
		@FormDataParam("data") final InputStream input) throws Exception {
	json.setMediaType(MediaType.APPLICATION_JSON_TYPE);
	JobAddVO in = json.getValueAs(JobAddVO.class);
	in.setDatas(CommonUtil.inputStreamToByteArray(input));
	in.setMimeType(content.getMediaType().toString());
	in.setFileName(contentDisposition.getFileName());
	return WebUtil.getServiceLocator().getJobService().addJob(auth, in);
}
 
源代码15 项目: geowave   文件: FileUploadService.java
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
@Path("/fileupload")
public Response uploadFile(FormDataMultiPart multiPart);
 
源代码16 项目: eplmp   文件: PartBinaryResource.java
@POST
@ApiOperation(value = "Upload attached file",
        response = Response.class)
@ApiImplicitParams({
        @ApiImplicitParam(name = "upload", paramType = "formData", dataType = "file", required = true)
})
@ApiResponses(value = {
        @ApiResponse(code = 204, message = "Upload success"),
        @ApiResponse(code = 401, message = "Unauthorized"),
        @ApiResponse(code = 403, message = "Forbidden"),
        @ApiResponse(code = 500, message = "Internal server error")
})
@Path("/{iteration}/" + PartIteration.ATTACHED_FILES_SUBTYPE)
@Consumes(MediaType.MULTIPART_FORM_DATA)
@RolesAllowed({UserGroupMapping.REGULAR_USER_ROLE_ID})
public Response uploadAttachedFiles(
        @Context HttpServletRequest request,
        @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") final String workspaceId,
        @ApiParam(required = true, value = "Part number") @PathParam("partNumber") final String partNumber,
        @ApiParam(required = true, value = "Part version") @PathParam("version") final String version,
        @ApiParam(required = true, value = "Part iteration") @PathParam("iteration") final int iteration)
        throws EntityNotFoundException, EntityAlreadyExistsException, UserNotActiveException, AccessRightException,
        NotAllowedException, CreationException, WorkspaceNotEnabledException {

    try {

        PartIterationKey partPK = new PartIterationKey(workspaceId, partNumber, version, iteration);
        Collection<Part> formParts = request.getParts();

        String fileName = null;

        for (Part formPart : formParts) {
            fileName = Normalizer.normalize(formPart.getSubmittedFileName(), Normalizer.Form.NFC);
            BinaryResource binaryResource = productService.saveFileInPartIteration(partPK, fileName, PartIteration.ATTACHED_FILES_SUBTYPE, 0);
            OutputStream outputStream = storageManager.getBinaryResourceOutputStream(binaryResource);
            long length = BinaryResourceUpload.uploadBinary(outputStream, formPart);
            productService.saveFileInPartIteration(partPK, fileName, PartIteration.ATTACHED_FILES_SUBTYPE, length);
        }

        if (formParts.size() == 1) {
            return BinaryResourceUpload.tryToRespondCreated(request.getRequestURI() + URLEncoder.encode(fileName, UTF8_ENCODING));
        }

        return Response.noContent().build();

    } catch (IOException | ServletException | StorageException e) {
        return BinaryResourceUpload.uploadError(e);
    }
}
 
源代码17 项目: pulsar   文件: SinksBase.java
@PUT
@ApiOperation(value = "Updates a Pulsar Sink currently running in cluster mode")
@ApiResponses(value = {
        @ApiResponse(code = 400, message = "Invalid request (The Pulsar Sink doesn't exist, update contains no change, etc.)"),
        @ApiResponse(code = 200, message = "Pulsar Sink successfully updated"),
        @ApiResponse(code = 401, message = "Client is not authorized to perform operation"),
        @ApiResponse(code = 404, message = "The Pulsar Sink doesn't exist"),
        @ApiResponse(code = 500, message = "Internal server error (failed to authorize, failed to process package, etc.)"),
        @ApiResponse(code = 503, message = "Function worker service is now initializing. Please try again later.")
})
@Path("/{tenant}/{namespace}/{sinkName}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public void updateSink(@ApiParam(value = "The tenant of a Pulsar Sink")
                       final @PathParam("tenant") String tenant,
                       @ApiParam(value = "The namespace of a Pulsar Sink")
                       final @PathParam("namespace") String namespace,
                       @ApiParam(value = "The name of a Pulsar Sink")
                       final @PathParam("sinkName") String sinkName,
                       final @FormDataParam("data") InputStream uploadedInputStream,
                       final @FormDataParam("data") FormDataContentDisposition fileDetail,
                       final @FormDataParam("url") String sinkPkgUrl,
                       @ApiParam(
                           value =
                               "A JSON value presenting config payload of a Pulsar Sink. All available configuration options are:  \n" +
                                   "- **classname**  \n" +
                                   "   The class name of a Pulsar Sink if archive is file-url-path (file://)  \n" +
                                   "- **sourceSubscriptionName**  \n" +
                                   "   Pulsar source subscription name if user wants a specific  \n" +
                                   "   subscription-name for input-topic consumer  \n" +
                                   "- **inputs**  \n" +
                                   "   The input topic or topics of a Pulsar Sink (specified as a JSON array)  \n" +
                                   "- **topicsPattern**  \n" +
                                   "   TopicsPattern to consume from list of topics under a namespace that " +
                                   "   match the pattern. [input] and [topicsPattern] are mutually " +
                                   "   exclusive. Add SerDe class name for a pattern in customSerdeInputs " +
                                   "   (supported for java fun only)" +
                                   "- **topicToSerdeClassName**  \n" +
                                   "   The map of input topics to SerDe class names (specified as a JSON object)  \n" +
                                   "- **topicToSchemaType**  \n" +
                                   "   The map of input topics to Schema types or class names (specified as a JSON object)  \n" +
                                   "- **inputSpecs**  \n" +
                                   "   The map of input topics to its consumer configuration, each configuration has schema of " +
                                   "   {\"schemaType\": \"type-x\", \"serdeClassName\": \"name-x\", \"isRegexPattern\": true, \"receiverQueueSize\": 5}  \n" +
                                   "- **configs**  \n" +
                                   "   The map of configs (specified as a JSON object)  \n" +
                                   "- **secrets**  \n" +
                                   "   a map of secretName(aka how the secret is going to be \n" +
                                   "   accessed in the function via context) to an object that \n" +
                                   "   encapsulates how the secret is fetched by the underlying \n" +
                                   "   secrets provider. The type of an value here can be found by the \n" +
                                   "   SecretProviderConfigurator.getSecretObjectType() method. (specified as a JSON object)  \n" +
                                   "- **parallelism**  \n" +
                                   "   The parallelism factor of a Pulsar Sink (i.e. the number of a Pulsar Sink instances to run \n" +
                                   "- **processingGuarantees**  \n" +
                                   "   The processing guarantees (aka delivery semantics) applied to the Pulsar Sink. Possible Values: \"ATLEAST_ONCE\", \"ATMOST_ONCE\", \"EFFECTIVELY_ONCE\"  \n" +
                                   "- **retainOrdering**  \n" +
                                   "   Boolean denotes whether the Pulsar Sink consumes and processes messages in order  \n" +
                                   "- **resources**  \n" +
                                   "   {\"cpu\": 1, \"ram\": 2, \"disk\": 3} The CPU (in cores), RAM (in bytes) and disk (in bytes) that needs to be allocated per Pulsar Sink instance (applicable only to Docker runtime)  \n" +
                                   "- **autoAck**  \n" +
                                   "   Boolean denotes whether or not the framework will automatically acknowledge messages  \n" +
                                   "- **timeoutMs**  \n" +
                                   "   Long denotes the message timeout in milliseconds  \n" +
                                   "- **cleanupSubscription**  \n" +
                                   "   Boolean denotes whether the subscriptions the functions created/used should be deleted when the functions is deleted  \n" +
                                   "- **runtimeFlags**  \n" +
                                   "   Any flags that you want to pass to the runtime as a single string  \n",
                           examples = @Example(
                               value = @ExampleProperty(
                                   mediaType = MediaType.APPLICATION_JSON,
                                   value = "{  \n" +
                                       "\t\"classname\": \"org.example.SinkStressTest\",  \n" +
                                           "\t\"inputs\": [\"persistent://public/default/sink-input\"],\n" +
                                           "\t\"processingGuarantees\": \"EFFECTIVELY_ONCE\",\n" +
                                           "\t\"parallelism\": 5\n" +
                                           "}"
                               )
                           )
                       )
                       final @FormDataParam("sinkConfig") SinkConfig sinkConfig,
                       @ApiParam(value = "Update options for the Pulsar Sink")
                       final @FormDataParam("updateOptions") UpdateOptions updateOptions) {
     sink.updateSink(tenant, namespace, sinkName, uploadedInputStream, fileDetail,
            sinkPkgUrl, sinkConfig, clientAppId(), clientAuthData(), updateOptions);

}
 
@POST
@Path("/executeScript")
@Consumes(MediaType.MULTIPART_FORM_DATA)
// The "script" parameter comes in the POST request body (encoded as XML or JSON).
public ScriptExecutionResult executeScript(List<Attachment> atts) throws GenericException {
	ByteArrayOutputStream baOut = new ByteArrayOutputStream();
	ByteArrayOutputStream baErr = new ByteArrayOutputStream();
	ScriptExecutionResult result = new ScriptExecutionResult();
	InputStream is = null;

	try {
		if (PrincipalUtils.hasRole(Config.DEFAULT_ADMIN_ROLE)) {
			for (Attachment att : atts) {
				if ("script".equals(att.getContentDisposition().getParameter("name"))) {
					is = att.getDataHandler().getInputStream();
				}
			}

			if (is != null) {
				String script = IOUtils.toString(is);
				PrintStream psOut = new PrintStream(baOut);
				PrintStream psErr = new PrintStream(baErr);
				Interpreter bsh = new Interpreter(null, psOut, psErr, false);

				try {
					Object ret = bsh.eval(script);
					result.setResult(String.valueOf(ret));
				} finally {
					psOut.flush();
					psErr.flush();
				}

				result.setStderr(baErr.toString());
				result.setStdout(baOut.toString());
				return result;
			} else {
				throw new Exception("Missing script parameter");
			}
		} else {
			throw new AccessDeniedException("Only admin users allowed");
		}
	} catch (Exception e) {
		throw new GenericException(e);
	} finally {
		IOUtils.closeQuietly(is);
		IOUtils.closeQuietly(baErr);
		IOUtils.closeQuietly(baOut);
	}
}
 
源代码19 项目: ipst   文件: SecurityAnalysisApi.java
@POST
@Path("/security-analysis")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response process(MultipartFormDataInput form, @Context SecurityContext securityContext) {
    return delegate.analyze(form);
}
 
源代码20 项目: teamengine   文件: TestRunResource.java
/**
 * Processes a request containing a multipart (multipart/form-data) entity. The entity is expected to consist of two
 * parts:
 * <ol>
 * <li>The (required) "iut" part represents the test subject or provides metadata about it; the entity body is
 * written to a local file, the location of which is set as the value of the {@code iut } argument.</li>
 * <li>The "sch" part defines supplementary constraints defined in a Schematron schema; it is also written to a
 * local file, the location of which is set as the value of the {@code sch} argument.</li>
 * </ol>
 *
 * @param etsCode
 *            A String that identifies the test suite to be run.
 * @param etsVersion
 *            A String specifying the desired test suite version.
 * @param entityBody
 *            A File containing a representation of the test subject.
 * @param schBody
 *            A File containing supplementary constraints (e.g. a Schematron schema).
 * @return An zip archive containing the HTML representation of the test results.
 *
 * @see <a href="http://tools.ietf.org/html/rfc7578" target="_blank">RFC 7578: Returning Values from Forms:
 *      multipart/form-data</a>
 * @see <a href= "http://standards.iso.org/ittf/PubliclyAvailableStandards/c040833_ISO_IEC_19757-3_2006(E).zip"
 *      target="_blank">ISO 19757-3: Schematron</a>
 */
@POST
@Consumes({ MediaType.MULTIPART_FORM_DATA })
@Produces("application/zip;qs=0.25;charset='utf-8'")
public Source handleMultipartFormDataZip( @PathParam("etsCode") String etsCode,
                                          @PathParam("etsVersion") String etsVersion,
                                          @FormDataParam("iut") File entityBody, @FormDataParam("sch") File schBody ) {
    return handleMultipartFormDataPost( etsCode, etsVersion, entityBody, schBody, APPLICATION_ZIP );
}