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


Java Response.ok方法代码示例

本文整理汇总了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();
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:25,代码来源:ConnectorsResource.java

示例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);
  } 
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:SchemaResource.java

示例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);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:RootResource.java

示例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();
    }
}
 
开发者ID:teamdigitale,项目名称:ontonethub,代码行数:35,代码来源:OntonethubIndexingResource.java

示例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();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:ExistsResource.java

示例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();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:22,代码来源:StorageClusterVersionResource.java

示例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;
}
 
开发者ID:simter,项目名称:simter-jxls-ext,代码行数:35,代码来源:JxlsUtils.java

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

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

示例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();
}
 
开发者ID:hlavki,项目名称:g-suite-identity-sync,代码行数:15,代码来源:UserAccountService.java

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

示例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);
	}
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:36,代码来源:RegistrationManagementImpl.java

示例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;
}
 
开发者ID:equella,项目名称:Equella,代码行数:11,代码来源:ItemResourceImpl.java

示例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();
}
 
开发者ID:equella,项目名称:Equella,代码行数:32,代码来源:StagingResourceImpl.java

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


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