当前位置: 首页>>代码示例>>Java>>正文


Java ResponseBuilder.type方法代码示例

本文整理汇总了Java中javax.ws.rs.core.Response.ResponseBuilder.type方法的典型用法代码示例。如果您正苦于以下问题:Java ResponseBuilder.type方法的具体用法?Java ResponseBuilder.type怎么用?Java ResponseBuilder.type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.ws.rs.core.Response.ResponseBuilder的用法示例。


在下文中一共展示了ResponseBuilder.type方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getApiListing

import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
@GET
@Produces({ MediaType.APPLICATION_JSON, "application/yaml" })
@ApiOperation(value = "Swagger API documentation in either JSON or YAML", hidden = true)
public Response getApiListing(@QueryParam("type") String type) {
	Swagger swagger = getSwagger(getConfigId());
	if (swagger == null) {
		return Response.noContent().build();
	}

	ResponseBuilder response = Response.ok().entity(swagger);

	if (StringUtils.isNotBlank(type) && type.trim().equalsIgnoreCase("yaml")) {
		// as YAML
		response.type("application/yaml");
	} else {
		// as JSON
		response.type(MediaType.APPLICATION_JSON_TYPE);
	}

	return response.build();
}
 
开发者ID:holon-platform,项目名称:holon-jaxrs,代码行数:22,代码来源:SwaggerApiListingResource.java

示例2: headFile

import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
@Override
public Response headFile(HttpHeaders headers, String uuid, int version, String path)
{
	ItemId itemId = new ItemId(uuid, version);
	checkViewItem(itemId);

	ItemFile itemFile = itemFileService.getItemFile(itemId, null);
	ResponseBuilder builder = makeBlobHeaders(itemFile, path);

	String contentType = mimeService.getMimeTypeForFilename(path);
	builder.type(contentType);

	if( !fileSystemService.fileExists(itemFile, path) )
	{
		return Response.status(Status.NOT_FOUND).build();
	}
	return builder.build();
}
 
开发者ID:equella,项目名称:Equella,代码行数:19,代码来源:ItemResourceImpl.java

示例3: toResponse

import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
@Override
public Response toResponse(@NonNull Exception exception) {
	ResponseBuilder builder;
	StatusType statusInfo;
	if (exception instanceof WebApplicationException) {
		Response response = ((WebApplicationException) exception).getResponse();
		builder = Response.fromResponse(response);
		statusInfo = response.getStatusInfo();
	} else {
		builder = Response.serverError();
		statusInfo = Status.INTERNAL_SERVER_ERROR;
	}

	SimpleExceptionJson simpleExceptionJson = new SimpleExceptionJson(statusInfo.getReasonPhrase(),
			statusInfo.getStatusCode(), exception.getMessage());
	builder.entity(simpleExceptionJson);
	builder.type("application/problem+json");

	if (statusInfo.getFamily() == Family.CLIENT_ERROR) {
		log.debug("Got client Exception", exception);
	} else {
		log.error("Sending error to client", exception);
	}

	return builder.build();
}
 
开发者ID:Mercateo,项目名称:rest-jersey-utils,代码行数:27,代码来源:RFCExceptionMapper.java

示例4: 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();
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:9,代码来源:FileDavResourceBase.java


注:本文中的javax.ws.rs.core.Response.ResponseBuilder.type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。