本文整理汇总了Java中javax.ws.rs.core.Response.ok方法的典型用法代码示例。如果您正苦于以下问题:Java Response.ok方法的具体用法?Java Response.ok怎么用?Java Response.ok使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ws.rs.core.Response
的用法示例。
在下文中一共展示了Response.ok方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: putConnectorConfig
import javax.ws.rs.core.Response; //导入方法依赖的package包/类
@PUT
@Path("/{connector}/config")
public Response putConnectorConfig(final @PathParam("connector") String connector,
final @QueryParam("forward") Boolean forward,
final Map<String, String> connectorConfig) throws Throwable {
FutureCallback<Herder.Created<ConnectorInfo>> cb = new FutureCallback<>();
String includedName = connectorConfig.get(ConnectorConfig.NAME_CONFIG);
if (includedName != null) {
if (!includedName.equals(connector))
throw new BadRequestException("Connector name configuration (" + includedName + ") doesn't match connector name in the URL (" + connector + ")");
} else {
connectorConfig.put(ConnectorConfig.NAME_CONFIG, connector);
}
herder.putConnectorConfig(connector, connectorConfig, true, cb);
Herder.Created<ConnectorInfo> createdInfo = completeOrForwardRequest(cb, "/connectors/" + connector + "/config",
"PUT", connectorConfig, new TypeReference<ConnectorInfo>() { }, new CreatedConnectorInfoTranslator(), forward);
Response.ResponseBuilder response;
if (createdInfo.created())
response = Response.created(URI.create("/connectors/" + connector));
else
response = Response.ok();
return response.entity(createdInfo.result()).build();
}
示例2: get
import javax.ws.rs.core.Response; //导入方法依赖的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);
}
}
示例3: get
import javax.ws.rs.core.Response; //导入方法依赖的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);
}
}
示例4: executeQuery
import javax.ws.rs.core.Response; //导入方法依赖的package包/类
/**
* Executes the query parsed by {@link #queryEntities(String, File, HttpHeaders)} or created based
* {@link #findEntity(String, String, String, int, int, HttpHeaders)}
*
* @param query
* The query to execute
* @param headers the request headers
* @return the response (results of error)
*/
private Response executeQuery(Site site, FieldQuery query, HttpHeaders headers) throws WebApplicationException {
MediaType mediaType = getAcceptableMediaType(headers, ENTITY_SUPPORTED_MEDIA_TYPES,
APPLICATION_JSON_TYPE);
if(query instanceof LDPathSelect && ((LDPathSelect)query).getLDPathSelect() != null){
//use the LDPath variant to process this query
return executeLDPathQuery(site, query, ((LDPathSelect)query).getLDPathSelect(),
mediaType, headers);
} else { //use the default query execution
QueryResultList<Representation> result;
try {
result = site.find(query);
} catch (SiteException e) {
String message = String.format("Unable to Query Site '%s' (message: %s)",
site.getId(),e.getMessage());
log.error(message, e);
return Response.status(Status.INTERNAL_SERVER_ERROR)
.entity(message)
.header(HttpHeaders.ACCEPT, mediaType).build();
}
ResponseBuilder rb = Response.ok(result);
rb.header(HttpHeaders.CONTENT_TYPE, mediaType+"; charset=utf-8");
//addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
}
示例5: get
import javax.ws.rs.core.Response; //导入方法依赖的package包/类
@GET
@Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
MIMETYPE_PROTOBUF_IETF, MIMETYPE_BINARY})
public Response get(final @Context UriInfo uriInfo) {
try {
if (!tableResource.exists()) {
return Response.status(Response.Status.NOT_FOUND)
.type(MIMETYPE_TEXT).entity("Not found" + CRLF)
.build();
}
} catch (IOException e) {
return Response.status(Response.Status.SERVICE_UNAVAILABLE)
.type(MIMETYPE_TEXT).entity("Unavailable" + CRLF)
.build();
}
ResponseBuilder response = Response.ok();
response.cacheControl(cacheControl);
return response.build();
}
示例6: get
import javax.ws.rs.core.Response; //导入方法依赖的package包/类
@GET
@Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON})
public Response get(final @Context UriInfo uriInfo) {
if (LOG.isDebugEnabled()) {
LOG.debug("GET " + uriInfo.getAbsolutePath());
}
servlet.getMetrics().incrementRequests(1);
try {
StorageClusterVersionModel model = new StorageClusterVersionModel();
model.setVersion(servlet.getAdmin().getClusterStatus().getHBaseVersion());
ResponseBuilder response = Response.ok(model);
response.cacheControl(cacheControl);
servlet.getMetrics().incrementSucessfulGetRequests(1);
return response.build();
} catch (IOException e) {
servlet.getMetrics().incrementFailedGetRequests(1);
return Response.status(Response.Status.SERVICE_UNAVAILABLE)
.type(MIMETYPE_TEXT).entity("Unavailable" + CRLF)
.build();
}
}
示例7: renderTemplate2Response
import javax.ws.rs.core.Response; //导入方法依赖的package包/类
/**
* Generate a {@link Response.ResponseBuilder} instance
* and render the excel template with the specified data to its output stream.
*
* @param template the excel template, can be xlsx or xls format
* @param data the data
* @param filename the download filename of the response
* @return the instance of {@link Response.ResponseBuilder} with the excel data
* @throws RuntimeException if has IOException or UnsupportedEncodingException inner
*/
public static Response.ResponseBuilder renderTemplate2Response(InputStream template, Map<String, Object> data,
String filename) {
StreamingOutput stream = (OutputStream output) -> {
// Convert to jxls Context
Context context = convert2Context(data);
// Add default functions
addDefault(context);
// render
renderByJxls(template, output, context);
};
// create response
Response.ResponseBuilder builder = Response.ok(stream);
if (filename != null) {
try {
builder.header("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(filename, "UTF-8") + "\"");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
return builder;
}
示例8: handleCorsPreflightFind
import javax.ws.rs.core.Response; //导入方法依赖的package包/类
@OPTIONS
@Path("/find")
public Response handleCorsPreflightFind(@Context HttpHeaders headers){
ResponseBuilder res = Response.ok();
return res.build();
}
示例9: renderEcrfs
import javax.ws.rs.core.Response; //导入方法依赖的package包/类
@GET
@Path("{listEntryId}/ecrfpdf")
public Response renderEcrfs(@PathParam("listEntryId") Long listEntryId,
@QueryParam("blank") Boolean blank) throws AuthenticationException, AuthorisationException, ServiceException {
ECRFPDFVO vo = WebUtil.getServiceLocator().getTrialService().renderEcrfs(auth, null, listEntryId, null, blank);
// 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();
}
示例10: syncGroups
import javax.ws.rs.core.Response; //导入方法依赖的package包/类
@PUT
@Path("groups")
public Response syncGroups() {
ResponseBuilder response;
UserInfo userInfo = oidcContext.getUserInfo();
try {
syncService.synchronizeUserGroups(userInfo);
response = Response.ok();
} catch (LDAPException e) {
log.error("Can't create account", e);
response = ServerError.toResponse("SYNC_ERR", e);
}
return response.build();
}
示例11: aggregatePDFFiles
import javax.ws.rs.core.Response; //导入方法依赖的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();
}
示例12: previewFile
import javax.ws.rs.core.Response; //导入方法依赖的package包/类
@Override
public Response previewFile(HttpServletRequest request, HttpHeaders header, Company company, Locale locale,
User user, ServiceContext serviceContext, long registrationId, String referenceUid) {
BackendAuth auth = new BackendAuthImpl();
try {
if (!auth.isAuth(serviceContext)) {
throw new UnauthenticationException();
}
long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));
RegistrationForm registrationForm = RegistrationFormLocalServiceUtil.findFormbyRegidRefid(groupId,
registrationId, referenceUid);
if (registrationForm != null && registrationForm.getFileEntryId() > 0) {
FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(registrationForm.getFileEntryId());
File file = DLFileEntryLocalServiceUtil.getFile(fileEntry.getFileEntryId(), fileEntry.getVersion(),
true);
ResponseBuilder responseBuilder = Response.ok((Object) file);
responseBuilder.header("Content-Disposition",
"attachment; filename=\"" + fileEntry.getFileName() + "\"");
responseBuilder.header("Content-Type", fileEntry.getMimeType());
return responseBuilder.build();
} else {
return Response.status(HttpURLConnection.HTTP_NO_CONTENT).build();
}
} catch (Exception e) {
return processException(e);
}
}
示例13: makeBlobHeaders
import javax.ws.rs.core.Response; //导入方法依赖的package包/类
private ResponseBuilder makeBlobHeaders(ItemFile itemFile, String filename)
{
FileInfo fileInfo = fileSystemService.getFileInfo(itemFile, filename);
ResponseBuilder builder = Response.ok();
builder.lastModified(new Date(fileSystemService.lastModified(itemFile, filename)));
builder.header(HttpHeaders.ETAG, fileInfo.getMd5CheckSum());
builder.header(HttpHeaders.CONTENT_LENGTH, fileInfo.getLength());
builder.header(HttpHeaders.CONTENT_TYPE, mimeService.getMimeTypeForFilename(fileInfo.getFilename()));
return builder;
}
示例14: completeMultipart
import javax.ws.rs.core.Response; //导入方法依赖的package包/类
@Override
public Response completeMultipart(String uuid, String filepath, String uploadId, MultipartCompleteBean completion)
throws IOException
{
StagingFile stagingFile = getStagingFile(uuid);
List<PartBean> parts = completion.getParts();
int[] partNumbers = new int[parts.size()];
String[] etags = new String[parts.size()];
int i = 0;
for( PartBean partBean : parts )
{
partNumbers[i] = partBean.getPartNumber();
etags[i++] = partBean.getEtag();
}
String folderPath = "multipart/" + uploadId;
if( !fileSystemService.fileExists(stagingFile, folderPath) )
{
throw new BadRequestException("Multipart upload doesn't exist: " + uploadId);
}
File folder = fileSystemService.getExternalFile(stagingFile, folderPath);
for( int partNumber : partNumbers )
{
fileSystemService.write(stagingFile, filepath,
fileSystemService.read(stagingFile, folder + "/" + Integer.toString(partNumber)), true);
}
fileSystemService.removeFile(stagingFile, folderPath);
ResponseBuilder resp = Response.ok();
return resp.build();
}
示例15: renderEcrf
import javax.ws.rs.core.Response; //导入方法依赖的package包/类
@GET
@Path("{listEntryId}/ecrfpdf/{ecrfId}")
public Response renderEcrf(@PathParam("listEntryId") Long listEntryId, @PathParam("ecrfId") Long ecrfId,
@QueryParam("blank") Boolean blank) throws AuthenticationException,
AuthorisationException, ServiceException {
ECRFPDFVO vo = WebUtil.getServiceLocator().getTrialService().renderEcrf(auth, ecrfId, null, listEntryId, blank);
// 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();
}