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


Java Response类代码示例

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


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

示例1: getKeysMetadata

import javax.ws.rs.core.Response; //导入依赖的package包/类
@GET
@Path(KMSRESTConstants.KEYS_METADATA_RESOURCE)
@Produces(MediaType.APPLICATION_JSON)
public Response getKeysMetadata(@QueryParam(KMSRESTConstants.KEY)
    List<String> keyNamesList) throws Exception {
  KMSWebApp.getAdminCallsMeter().mark();
  UserGroupInformation user = HttpUserGroupInformation.get();
  final String[] keyNames = keyNamesList.toArray(
      new String[keyNamesList.size()]);
  assertAccess(KMSACLs.Type.GET_METADATA, user, KMSOp.GET_KEYS_METADATA);

  KeyProvider.Metadata[] keysMeta = user.doAs(
      new PrivilegedExceptionAction<KeyProvider.Metadata[]>() {
        @Override
        public KeyProvider.Metadata[] run() throws Exception {
          return provider.getKeysMetadata(keyNames);
        }
      }
  );

  Object json = KMSServerJSONUtils.toJSON(keyNames, keysMeta);
  kmsAudit.ok(user, KMSOp.GET_KEYS_METADATA, "");
  return Response.ok().type(MediaType.APPLICATION_JSON).entity(json).build();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:25,代码来源:KMS.java

示例2: deleteQueue

import javax.ws.rs.core.Response; //导入依赖的package包/类
public Response deleteQueue(String queueName, Boolean ifUnused, Boolean ifEmpty) {
    if (Objects.isNull(ifUnused)) {
        ifUnused = true;
    }

    if (Objects.isNull(ifEmpty)) {
        ifEmpty = true;
    }

    try {
        if (broker.deleteQueue(queueName, ifUnused, ifEmpty)) {
            return Response.ok().build();
        } else {
            throw new NotFoundException("Queue " + queueName + " doesn't exist.");
        }
    } catch (BrokerException e) {
        throw new BadRequestException(e.getMessage(), e);
    }
}
 
开发者ID:wso2,项目名称:message-broker,代码行数:20,代码来源:QueuesApiDelegate.java

示例3: insert

import javax.ws.rs.core.Response; //导入依赖的package包/类
/**
 * Cadastra usuario
 * 
 * @param User
 * @return Response
 */
@PermitAll
@POST
@Path("/")
@Consumes("application/json")
@Produces("application/json")
public Response insert(User user) {

	ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
	builder.expires(new Date());

	try {

		Long idUser = (long) UserDao.getInstance().insertU(user);
		user.setId(idUser);
		builder.status(Response.Status.OK).entity(user);

	} catch (SQLException e) {

		builder.status(Response.Status.INTERNAL_SERVER_ERROR);
	}

	return builder.build();
}
 
开发者ID:mrh3nry,项目名称:Celebino,代码行数:30,代码来源:UserController.java

示例4: testPutLdpResourceContainer

import javax.ws.rs.core.Response; //导入依赖的package包/类
@Test
public void testPutLdpResourceContainer() {
    when(mockLdpRequest.getLink()).thenReturn(fromUri(LDP.Container.getIRIString()).rel("type").build());
    when(mockLdpRequest.getContentType()).thenReturn(TEXT_TURTLE);

    final File entity = new File(getClass().getResource("/simpleTriple.ttl").getFile());
    final PutHandler putHandler = new PutHandler(mockLdpRequest, entity, mockResourceService,
            mockIoService, mockBinaryService, null);

    final Response res = putHandler.setResource(mockResource).build();
    assertEquals(NO_CONTENT, res.getStatusInfo());
    assertTrue(res.getLinks().stream().anyMatch(hasType(LDP.Resource)));
    assertTrue(res.getLinks().stream().anyMatch(hasType(LDP.RDFSource)));
    assertTrue(res.getLinks().stream().anyMatch(hasType(LDP.Container)));
    assertFalse(res.getLinks().stream().anyMatch(hasType(LDP.NonRDFSource)));

    verify(mockBinaryService, never()).setContent(any(IRI.class), any(InputStream.class));
    verify(mockIoService).read(any(InputStream.class), eq(baseUrl + "resource"), eq(TURTLE));
}
 
开发者ID:trellis-ldp,项目名称:trellis,代码行数:20,代码来源:PutHandlerTest.java

示例5: endpoint

import javax.ws.rs.core.Response; //导入依赖的package包/类
@ApiOperation(
        value = "Updates an Manager Connector.  If we are unable to connect to the endpoint(IP) using the credentials provided, this call will fail.",
        notes = "Creates an Manager Connector and sync's it immediately. "
                + "If we are unable to connect to the manager using the credentials provided, this call will fail."
                + "To skip validation of IP and credentials 'skipRemoteValidation' flag can be used.",
        response = BaseJobResponse.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"), @ApiResponse(code = 400,
        message = "In case of any error validating the information",
        response = ErrorCodeDto.class) })
@Path("/{applianceManagerConnectorId}")
@PUT
public Response updateApplianceManagerConnector(@Context HttpHeaders headers,
                                                @ApiParam(value = "Id of the Appliance Manager Connector",
                                                        required = true) @PathParam("applianceManagerConnectorId") Long amcId,
                                                @ApiParam(required = true) ApplianceManagerConnectorRequest amcRequest) {

    logger.info("Updating Appliance Manager Connector " + amcId);
    this.userContext.setUser(OscAuthFilter.getUsername(headers));

    this.apiUtil.setIdOrThrow(amcRequest, amcId, "Appliance Manager Connector");

    Response responseForBaseRequest = this.apiUtil.getResponseForBaseRequest(this.updateService,
                new DryRunRequest<>(amcRequest, amcRequest.isSkipRemoteValidation()));
    return responseForBaseRequest;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:26,代码来源:ManagerConnectorApis.java

示例6: headFile

import javax.ws.rs.core.Response; //导入依赖的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

示例7: post

import javax.ws.rs.core.Response; //导入依赖的package包/类
@POST
public Response post(Endpoint endpoint) {

    if (validator.check(endpoint)) {

        if (bundle.exists(endpoint))
            bundle.update(endpoint);
        else
            throw new NotFoundException("Endpoint does not exist");

        apixController.bootAttempt(this.getClass().getSimpleName() +
            " POST {Endpoint method:[" + endpoint.getMethod().name() + "] path:[" + endpoint.getPath() + "]}");

    } else
        throw new BadRequestException("Malformed endpoint entity");

    return Response.ok().entity(endpoint).build();
}
 
开发者ID:groovylabs,项目名称:lyre,代码行数:19,代码来源:EndpointService.java

示例8: filter

import javax.ws.rs.core.Response; //导入依赖的package包/类
@Override
public void filter( final ClientRequestContext requestContext, final ClientResponseContext responseContext )
  throws IOException
{
  if ( Response.Status.UNAUTHORIZED.getStatusCode() == responseContext.getStatus() )
  {
    final List<Object> headers = requestContext.getHeaders().get( HttpHeaders.AUTHORIZATION );
    if ( null == headers )
    {
      return;
    }
    for ( final Object header : headers )
    {
      if ( header instanceof String )
      {
        final String headerValue = (String) header;
        if ( headerValue.startsWith( AUTH_HEADER_PREFIX ) )
        {
          final String token = headerValue.substring( AUTH_HEADER_PREFIX.length() );
          _keycloak.invalidate( token );
        }
      }
    }
  }
}
 
开发者ID:realityforge,项目名称:keycloak-jaxrs-client-authfilter,代码行数:26,代码来源:BearerAuthFilter.java

示例9: leave

import javax.ws.rs.core.Response; //导入依赖的package包/类
public int leave(URL lraId, String compensatorUrl) {
    lraTrace(lraId, "leave LRA");

    Transaction transaction = getTransaction(lraId);

    if (!transaction.isActive())
        return Response.Status.PRECONDITION_FAILED.getStatusCode();

    try {
        if (!transaction.forgetParticipant(compensatorUrl))
            if (LRALogger.logger.isInfoEnabled())
                LRALogger.logger.infof("LRAServicve.forget %s failed%n", lraId);

        return Response.Status.OK.getStatusCode();
    } catch (Exception e) {
        return Response.Status.BAD_REQUEST.getStatusCode();
    }
}
 
开发者ID:xstefank,项目名称:lra-service,代码行数:19,代码来源:LRAService.java

示例10: testMultipleErrorsDataModel

import javax.ws.rs.core.Response; //导入依赖的package包/类
@Test
public void testMultipleErrorsDataModel() throws Exception {
    ExecuteRequest req = new ExecuteRequest(create30KString(), create30KString());
    req.setOutputFormat("wrongOutputFormat");
    req.setLocale("wrongLocale");
    req.setTimeZone("wrongTimeZone");

    Response resp = postJSON(req);
    
    assertEquals(200, resp.getStatus());
    ExecuteResponse response = resp.readEntity(ExecuteResponse.class);
    assertNotNull(response.getProblems());
    assertThat(getProblemMessage(response, ExecuteResourceField.TEMPLATE), containsString("limit"));
    assertThat(getProblemMessage(response, ExecuteResourceField.DATA_MODEL), containsString("limit"));
    assertThat(getProblemMessage(response, ExecuteResourceField.OUTPUT_FORMAT), containsString("wrongOutputFormat"));
    assertThat(getProblemMessage(response, ExecuteResourceField.LOCALE), containsString("wrongLocale"));
    assertThat(getProblemMessage(response, ExecuteResourceField.TIME_ZONE), containsString("wrongTimeZone"));
}
 
开发者ID:apache,项目名称:incubator-freemarker-online-tester,代码行数:19,代码来源:ExecuteApiResourceTest.java

示例11: testCanGETJobSummaries

import javax.ws.rs.core.Response; //导入依赖的package包/类
@Test
public void testCanGETJobSummaries() throws IOException {
    final Invocation.Builder builder =
            generateAuthenticatedRequest(RULE, HTTP_JOBS_PATH);

    for (int i = 0; i < 10; i++) {
        builder.post(json(REQUEST_AGAINST_SECOND_SPEC), APIJobCreatedResponse.class);
    }

    final Response jobSummariesResponse =
            generateAuthenticatedRequest(RULE, HTTP_JOBS_PATH).get();

    assertThat(jobSummariesResponse.getStatus()).isEqualTo(OK);

    final APIJobDetailsCollection jobSummaries =
            readJSON(jobSummariesResponse.readEntity(String.class), APIJobDetailsCollection.class);

    assertThat(jobSummaries.getEntries().isEmpty()).isFalse();
}
 
开发者ID:adamkewley,项目名称:jobson,代码行数:20,代码来源:TestJobsAPI.java

示例12: registerUser

import javax.ws.rs.core.Response; //导入依赖的package包/类
private static void registerUser(String url, MediaType mediaType) {
    System.out.println("Registering user via " + url);
    User user = new User(1L, "larrypage");
    Client client = ClientBuilder.newClient();
    WebTarget target = client.target(url);
    Response response = target.request().post(Entity.entity(user, mediaType));

    try {
        if (response.getStatus() != 200) {
            throw new RuntimeException("Failed with HTTP error code : " + response.getStatus());
        }
        System.out.println("Successfully got result: " + response.readEntity(String.class));
    } finally {
        response.close();
        client.close();
    }
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:18,代码来源:RestClient.java

示例13: handleRedirectAnonymousCookieNotMatch

import javax.ws.rs.core.Response; //导入依赖的package包/类
@Test
public void handleRedirectAnonymousCookieNotMatch() throws URISyntaxException {
	SecurityContextHolder.clearContext();

	final SystemUserSetting setting = new SystemUserSetting();
	setting.setLogin(DEFAULT_USER);
	setting.setName(RedirectResource.PREFERRED_HASH);
	setting.setValue("-");
	userSettingRepository.save(setting);
	em.flush();
	em.clear();

	final Response response = resource.handleRedirect(DEFAULT_USER + "|hash");
	Assert.assertNull(response.getCookies().get(RedirectResource.PREFERRED_COOKIE_HASH));
	Assert.assertEquals("http://localhost:8081/external", response.getHeaderString("location"));
}
 
开发者ID:ligoj,项目名称:plugin-redirect,代码行数:17,代码来源:RedirectResourceTest.java

示例14: putPipelineFavorite

import javax.ws.rs.core.Response; //导入依赖的package包/类
@PUT
    @Path("/rest/organizations/{organization}/pipelines/{pipeline}/favorite")
    
    @Produces({ "application/json" })
    @io.swagger.annotations.ApiOperation(value = "", notes = "Favorite/unfavorite a pipeline", response = FavoriteImpl.class, authorizations = {
        @io.swagger.annotations.Authorization(value = "jenkins_auth")
    }, tags={ "blueOcean", })
    @io.swagger.annotations.ApiResponses(value = { 
        @io.swagger.annotations.ApiResponse(code = 200, message = "Successfully favorited/unfavorited a pipeline", response = FavoriteImpl.class),
        
        @io.swagger.annotations.ApiResponse(code = 401, message = "Authentication failed - incorrect username and/or password", response = FavoriteImpl.class),
        
        @io.swagger.annotations.ApiResponse(code = 403, message = "Jenkins requires authentication - please set username and password", response = FavoriteImpl.class) })
    public Response putPipelineFavorite(@ApiParam(value = "Name of the organization",required=true) @PathParam("organization") String organization
,@ApiParam(value = "Name of the pipeline",required=true) @PathParam("pipeline") String pipeline
,@ApiParam(value = "Set JSON string body to {\"favorite\": true} to favorite, set value to false to unfavorite" ,required=true) String body
,@Context SecurityContext securityContext)
    throws NotFoundException {
        return delegate.putPipelineFavorite(organization,pipeline,body,securityContext);
    }
 
开发者ID:cliffano,项目名称:swaggy-jenkins,代码行数:21,代码来源:BlueApi.java

示例15: shouldGetCycle3AttributeRequestDataFromConfiguration

import javax.ws.rs.core.Response; //导入依赖的package包/类
@Test
public void shouldGetCycle3AttributeRequestDataFromConfiguration() throws JsonProcessingException {
    final SessionId sessionId = SessionIdBuilder.aSessionId().build();
    final String rpEntityId = new EidasCycle3DTO(sessionId).getRequestIssuerEntityId();
    final Response sessionCreatedResponse = createSessionInEidasAwaitingCycle3DataState(sessionId);
    assertThat(sessionCreatedResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());

    final MatchingProcessDto cycle3Attribute = new MatchingProcessDto(Optional.of("TUFTY_CLUB_CARD"));
    configStub.setUpStubForEnteringAwaitingCycle3DataState(rpEntityId, cycle3Attribute);
    samlSoapProxyProxyStub.setUpStubForSendHubMatchingServiceRequest(sessionId);

    final Cycle3AttributeRequestData actualResponse = getCycle3Data(sessionId);

    final Cycle3AttributeRequestData expectedResponse = aCycle3AttributeRequestData()
        .withAttributeName(cycle3Attribute.getAttributeName().get())
        .withRequestIssuerId(rpEntityId)
        .build();
    assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:20,代码来源:EidasCycle3DataResourceTest.java


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