本文整理汇总了Java中org.apache.cxf.jaxrs.ext.multipart.MultipartBody类的典型用法代码示例。如果您正苦于以下问题:Java MultipartBody类的具体用法?Java MultipartBody怎么用?Java MultipartBody使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MultipartBody类属于org.apache.cxf.jaxrs.ext.multipart包,在下文中一共展示了MultipartBody类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: uploadSmallAccessFile
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@Test ()
public void uploadSmallAccessFile() throws FileNotFoundException {
loginBasicUser();
WebClient client = getClient(false);
client.type("multipart/form-data");
Attachment att = createAttachmentFromFile("/mondial.accdb", "dataFile");
client = getClient(false);
client.type("multipart/form-data");
Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
assertEquals(201, response.getStatus());
String id = getIdFromResponse(response);
DatabaseReference r = new DatabaseReference(Integer.parseInt(id), false);
AbstractResourceTest.databases.add(r);
}
示例2: uploadSmallSQLFile
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@Test ()
public void uploadSmallSQLFile() throws Exception {
loginBasicUser();
WebClient client = getClient(false);
client.type("multipart/form-data");
Attachment att = createAttachmentFromFile("/databases/main_2812_2811.sql", "dataFile");
client = getClient(false);
client.type("multipart/form-data");
Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
assertEquals(201, response.getStatus());
String id = getIdFromResponse(response);
DatabaseReference r = new DatabaseReference(Integer.parseInt(id), false);
AbstractResourceTest.databases.add(r);
}
示例3: uploadSmallCSVFile
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@Test ()
public void uploadSmallCSVFile() throws Exception {
loginBasicUser();
WebClient client = getClient(false);
client.type("multipart/form-data");
Attachment att = createAttachmentFromFile("/small_test.csv", "dataFile");
Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
assertEquals(201, response.getStatus());
String id = getIdFromResponse(response);
DatabaseReference r = new DatabaseReference(Integer.parseInt(id), false);
AbstractResourceTest.databases.add(r);
logout();
}
示例4: appendCSVToTableWithHeader
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@Test ()
public void appendCSVToTableWithHeader() throws Exception {
loginBasicUser();
WebClient client = getClient(false);
client.type("multipart/form-data");
Attachment att = createAttachmentFromFile("/append_start.csv", "dataFile");
Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
assertEquals(201, response.getStatus());
String id = getIdFromResponse(response);
DatabaseReference r = new DatabaseReference(Integer.parseInt(id), false);
AbstractResourceTest.databases.add(r);
// append
client = getClient(false);
client.type("multipart/form-data");
att = createAttachmentFromFile("/append_continue.csv", "dataFile");
response = client.path("/"+id+"/append/table/append_start/true/test").post(new MultipartBody(att));
assertEquals(201, response.getStatus());
}
示例5: appendCSVToTableInvalid
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@Test ()
public void appendCSVToTableInvalid ( ) throws Exception {
loginBasicUser();
WebClient client = getClient(false);
client.type("multipart/form-data");
Attachment att = createAttachmentFromFile("/append_start.csv", "dataFile");
Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
assertEquals(201, response.getStatus());
String id = getIdFromResponse(response);
DatabaseReference r = new DatabaseReference(Integer.parseInt(id), false);
AbstractResourceTest.databases.add(r);
// append
client = getClient(false);
client.type("multipart/form-data");
att = createAttachmentFromFile("/append_continue_different.csv", "dataFile");
response = client.path("/"+id+"/append/table/append_start/true/test").post(new MultipartBody(att));
assertEquals(409, response.getStatus());
}
示例6: appendCSVToTableNoHeader
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@Test ()
public void appendCSVToTableNoHeader ( ) throws Exception {
loginBasicUser();
WebClient client = getClient(false);
client.type("multipart/form-data");
Attachment att = createAttachmentFromFile("/append_start.csv", "dataFile");
Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
assertEquals(201, response.getStatus());
String id = getIdFromResponse(response);
DatabaseReference r = new DatabaseReference(Integer.parseInt(id), false);
AbstractResourceTest.databases.add(r);
// append
client = getClient(false);
client.type("multipart/form-data");
att = createAttachmentFromFile("/append_continue_no_header.csv", "dataFile");
response = client.path("/"+id+"/append/table/append_start/false/test").post(new MultipartBody(att));
assertEquals(201, response.getStatus());
}
示例7: appendCSVToTableNoHeaderInvalid
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@Test ()
public void appendCSVToTableNoHeaderInvalid ( ) throws Exception {
loginBasicUser();
WebClient client = getClient(false);
client.type("multipart/form-data");
Attachment att = createAttachmentFromFile("/append_start.csv", "dataFile");
Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
assertEquals(201, response.getStatus());
String id = getIdFromResponse(response);
DatabaseReference r = new DatabaseReference(Integer.parseInt(id), false);
AbstractResourceTest.databases.add(r);
// append
client = getClient(false);
client.type("multipart/form-data");
att = createAttachmentFromFile("/append_continue_different_no_header.csv", "dataFile");
response = client.path("/"+id+"/append/table/append_start/false/test").post(new MultipartBody(att));
assertEquals(409, response.getStatus());
}
示例8: exportUnauth
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@Test
public void exportUnauth ( ) throws Exception {
loginBasicUser();
WebClient client = getClient(false);
client.type("multipart/form-data");
Attachment att = createAttachmentFromFile("/small_test.csv", "dataFile");
Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
assertEquals(201, response.getStatus());
String id = getIdFromResponse(response);
DatabaseReference r = new DatabaseReference(Integer.parseInt(id), false);
AbstractResourceTest.databases.add(r);
logout();
client = getClient(true);
client.accept("application/sql");
String exportPath = "/"+id+"/export/sql";
response = client.path(exportPath).get();
assertEquals(403, response.getStatus());
}
示例9: noSqlDataPut
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@POST
@Path("/nosql/data/put/{id}")
public String noSqlDataPut(@PathParam("id") String id, MultipartBody body) throws IOException {
byte[] data = null;
String filename = null;
if (Constants.PLACEHOLDER_NEW_FILE.equals(id))
id = UUID.randomUUID().toString();
for (Attachment attachment : body.getAllAttachments()) {
if (Constants.FIELD_DATA.equalsIgnoreCase(attachment.getContentDisposition().getParameter(Constants.MULTIPART_FIELD_NAME))) {
filename = attachment.getContentDisposition().getParameter(Constants.MULTIPART_FIELD_FILENAME);
data = Utils.getBytes(attachment.getDataHandler().getInputStream());
}
}
logger.info("Archive file id : " + id);
logger.info("Archive file name: " + filename);
if (!NoSqlEngine.noSqlPutData(id, data)) {
logger.error("Failed to store data [" + id + "]");
}
return id;
}
示例10: updateBinaryVariable
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@PUT
@Path("/{processInstanceId}/variables/{variableName}")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response updateBinaryVariable(@PathParam("processInstanceId") String processInstanceId,
@PathParam("variableName") String variableName,
MultipartBody multipartBody) {
Execution execution = getExecutionInstanceFromRequest(processInstanceId);
RestVariable result;
try {
result = setBinaryVariable(multipartBody, execution, RestResponseFactory.VARIABLE_PROCESS, false);
} catch (IOException | ServletException e) {
throw new BPMNRestException("Exception occured during creating binary execution variable", e);
}
return Response.ok().entity(result).build();
}
示例11: createBinaryExecutionVariable
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@POST
@Path("/{processInstanceId}/variables")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response createBinaryExecutionVariable(@PathParam("processInstanceId") String processInstanceId, @Context
HttpServletRequest httpServletRequest, MultipartBody multipartBody) {
Execution execution = getExecutionInstanceFromRequest(processInstanceId);
Response response;
try {
response = createBinaryExecutionVariable(execution, false, RestResponseFactory
.VARIABLE_PROCESS, multipartBody);
} catch (IOException | ServletException e) {
throw new BPMNRestException("Exception occured during creating binary execution variable", e);
}
return response;
}
示例12: createOrUpdateBinaryExecutionVariable
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@PUT
@Path("/{processInstanceId}/variables")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response createOrUpdateBinaryExecutionVariable(@PathParam("processInstanceId") String processInstanceId,
MultipartBody multipartBody) {
Execution execution = getExecutionInstanceFromRequest(processInstanceId);
Response response;
try {
response = createBinaryExecutionVariable(execution, true, RestResponseFactory.VARIABLE_PROCESS,
multipartBody);
} catch (IOException | ServletException e) {
throw new BPMNRestException("Exception occured during creating execution variable", e);
}
return response;
}
示例13: createBinaryTaskVariable
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@POST
@Path("/{taskId}/variables")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response createBinaryTaskVariable(@PathParam("taskId") String taskId, MultipartBody multipartBody) {
Task task = getTaskFromRequest(taskId);
Object result = null;
try {
result = setBinaryVariable(multipartBody, task, true, uriInfo);
} catch (IOException e) {
throw new ActivitiIllegalArgumentException("Error Reading variable attachment", e);
}
if (result != null) {
return Response.ok().status(Response.Status.CREATED).build();
} else {
throw new ActivitiIllegalArgumentException("Binary Task variable creation failed");
}
}
示例14: updateBinaryTaskVariable
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@PUT
@Path("/{taskId}/variables/{variableName}")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response updateBinaryTaskVariable(@PathParam("taskId") String taskId, @PathParam("variableName") String variableName,
MultipartBody multipartBody) {
Task task = getTaskFromRequest(taskId);
RestVariable result = null;
try {
result = setBinaryVariable(multipartBody, task, false, uriInfo);
} catch (IOException e) {
throw new ActivitiIllegalArgumentException("Error Reading variable attachment", e);
}
if (result != null) {
if (!result.getName().equals(variableName)) {
throw new ActivitiIllegalArgumentException("Variable name in the body should be equal to the name used in the requested URL.");
}
}
return Response.ok().entity(result).build();
}
示例15: uploadUnsupportedFile
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; //导入依赖的package包/类
@Test ()
public void uploadUnsupportedFile() throws FileNotFoundException {
loginBasicUser();
WebClient client = getClient(false);
client.type("multipart/form-data");
Attachment att = createAttachmentFromFile("/config.xml", "dataFile");
Response response = client.path("/"+logicalDatabaseId+"/data/test").post(new MultipartBody(att));
assertEquals(415, response.getStatus());
}