本文整理汇总了Java中javax.ws.rs.core.Response.ResponseBuilder.build方法的典型用法代码示例。如果您正苦于以下问题:Java ResponseBuilder.build方法的具体用法?Java ResponseBuilder.build怎么用?Java ResponseBuilder.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ws.rs.core.Response.ResponseBuilder
的用法示例。
在下文中一共展示了ResponseBuilder.build方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toResponse
import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
@Override
public Response toResponse(DefaultOptionsMethodException arg0)
{
final ResponseBuilder response = Response.ok();
response.header("Access-Control-Allow-Origin", "*");
response.header("Access-Control-Allow-Methods", ALL_METHODS);
response.header("Allow", ALL_METHODS);
response.header("Access-Control-Allow-Headers", "X-Authorization, Content-Type");
response.header("Access-Control-Max-Age", TimeUnit.DAYS.toSeconds(1));
response.header("Access-Control-Expose-Headers", "Location");
return response.build();
}
示例2: get
import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
@GET
@Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
MIMETYPE_PROTOBUF_IETF})
public Response get(final @Context UriInfo uriInfo) {
if (LOG.isDebugEnabled()) {
LOG.debug("GET " + uriInfo.getAbsolutePath());
}
servlet.getMetrics().incrementRequests(1);
try {
ResponseBuilder response = Response.ok(getTableList());
response.cacheControl(cacheControl);
servlet.getMetrics().incrementSucessfulGetRequests(1);
return response.build();
} catch (Exception e) {
servlet.getMetrics().incrementFailedGetRequests(1);
return processException(e);
}
}
示例3: get
import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
@GET
@Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
MIMETYPE_PROTOBUF_IETF})
public Response get(final @Context UriInfo uriInfo) {
if (LOG.isDebugEnabled()) {
LOG.debug("GET " + uriInfo.getAbsolutePath());
}
servlet.getMetrics().incrementRequests(1);
try {
ResponseBuilder response =
Response.ok(new TableSchemaModel(getTableSchema()));
response.cacheControl(cacheControl);
servlet.getMetrics().incrementSucessfulGetRequests(1);
return response.build();
} catch (Exception e) {
servlet.getMetrics().incrementFailedGetRequests(1);
return processException(e);
}
}
示例4: executeQuery
import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
/**
* Executes the query parsed by {@link #queryEntities(String, File, HttpHeaders)} or created based
* {@link #findEntity(String, String, String, int, int, HttpHeaders)}
*
* @param manager The {@link SiteManager}
* @param query
* The query to execute
* @param headers the request headers
* @return the response (results of error)
*/
private Response executeQuery(OntoNetHubSiteManager manager,
FieldQuery query, MediaType mediaType, String lang,
HttpHeaders headers) throws WebApplicationException {
/*
if(query instanceof LDPathSelect && ((LDPathSelect)query).getLDPathSelect() != null){
//use the LDPath variant to process this query
return executeLDPathQuery(manager, query, ((LDPathSelect)query).getLDPathSelect(),
mediaType, headers);
} else { //use the default query execution
*/
QueryResultList<Entity> result = manager.findEntities(query);
QueryResultList<Representation> representations = new QueryResultListImpl<Representation>(query, transformQueryResult(result, lang), Representation.class);
ResponseBuilder rb = Response.ok(representations);
rb.header(HttpHeaders.CONTENT_TYPE, mediaType+"; charset=utf-8");
//addCORSOrigin(servletContext, rb, headers);
return rb.build();
//}
}
示例5: getEmptyResponse
import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
/**
* イベントログが存在しない場合に返却する空レスポンスを取得する.
* @return 空レスポンス
*/
private Response getEmptyResponse() {
// レスポンスの返却
ResponseBuilder res = Response.status(HttpStatus.SC_OK);
res.header(HttpHeaders.CONTENT_TYPE, EventUtils.TEXT_CSV);
res.entity("");
log.debug("main thread end.");
return res.build();
}
示例6: aggregatePDFFiles
import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
@GET
@Path("{id}/files/pdf")
public Response aggregatePDFFiles(@PathParam("id") Long id, @Context UriInfo uriInfo) throws AuthenticationException, AuthorisationException, ServiceException {
FilePDFVO vo = WebUtil.getServiceLocator().getFileService().aggregatePDFFiles(auth, fileModule, id, null, null, new PSFUriPart(uriInfo));
// http://stackoverflow.com/questions/9204287/how-to-return-a-png-image-from-jersey-rest-service-method-to-the-browser
// non-streamed
ResponseBuilder response = Response.ok(vo.getDocumentDatas(), vo.getContentType().getMimeType());
response.header(HttpHeaders.CONTENT_LENGTH, vo.getSize());
return response.build();
}
示例7: toResponse
import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
@Override
public Response toResponse(IllegalArgumentException exception) {
logger.error("Error serving rest request", exception);
ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
if (exception.getMessage() != null)
builder = builder.entity("Illegal argument: " + exception.getMessage()).type("text/plain");
else
builder = builder.entity("Illegal argument").type("text/plain");
return builder.build();
}
示例8: testSetStatusCode
import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
@Test
public void testSetStatusCode() {
final ResponseBuilder builder = Response.status(404);
final Response response = builder.build();
assertEquals(404, response.getStatus());
assertEquals("Not Found", response.getStatusInfo().getReasonPhrase());
}
示例9: createResponse
import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
protected Response createResponse(CreatedTaskDto task) {
ResponseBuilder builder = Response.status(Status.CREATED)
.header(HttpHeaders.LOCATION, getLocation(task).toString())
.header(TaskService.X_QUEUE_SIZE, task.getQueueTasks())
.entity(task)
.type(MediaType.APPLICATION_JSON_TYPE);
return builder.build();
}
示例10: toResponse
import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
@Override
public Response toResponse(UnauthenticatedException exception) {
ResponseBuilder builder = Response.status(Response.Status.UNAUTHORIZED);
builder.header("WWW-Authenticate", HttpServletRequest.BASIC_AUTH + " realm=\"" + appName + "\"");
if (exception.getMessage() != null)
builder = builder.entity(exception.getMessage()).type("text/plain");
return builder.build();
}
示例11: handleCorsPreflightOntology
import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
@OPTIONS
@Path("/{id}")
public Response handleCorsPreflightOntology(@PathParam(value = "id") String id,
@Context HttpHeaders headers){
ResponseBuilder res = Response.ok();
return res.build();
}
示例12: davHead
import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
protected javax.ws.rs.core.Response davHead(Long id, String fileName) throws AuthenticationException, AuthorisationException, ServiceException {
FileOutVO out = getFileFromDavFileName(id, fileName);
ResponseBuilder response = javax.ws.rs.core.Response.ok();
response.header(HttpHeaders.CONTENT_LENGTH, out.getSize());
response.type(out.getContentType().getMimeType());
return response.build();
// return (Contact) this.em().createNamedQuery("FindContactByMatchCode").setParameter(1, matchCode).getSingleResult();
}
示例13: getOntologySource
import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
@GET
@Consumes(MediaType.WILDCARD)
@Produces({
KRFormat.RDF_XML,
KRFormat.RDF_JSON,
KRFormat.TURTLE,
KRFormat.N_TRIPLE,
KRFormat.N3,
"application/json-ld"
})
@Path("/{id}/source")
public Response getOntologySource(@PathParam("id") String id){
ResponseBuilder responseBuilder = null;
Model model;
try {
model = ontonetHub.getOntologySource(id);
responseBuilder = Response.ok(model);
} catch (NoSuchOntologyException e1) {
JSONObject json = new JSONObject();
try {
json.put("error", "No ontology exists with the ID provided.");
} catch (JSONException e) {
log.error(e.getMessage(), e);
}
responseBuilder = Response.status(Status.NOT_FOUND).entity(json);
}
return responseBuilder.build();
}
示例14: handleCorsPreflightOntology
import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
@OPTIONS
public Response handleCorsPreflightOntology(@PathParam(value = "id") String id,
@Context HttpHeaders headers){
ResponseBuilder res = Response.ok();
return res.build();
}
示例15: handleCorsPreflightFind
import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
@OPTIONS
@Path("/find")
public Response handleCorsPreflightFind(@Context HttpHeaders headers){
ResponseBuilder res = Response.ok();
return res.build();
}