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


Java UriBuilder类代码示例

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


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

示例1: save

import javax.ws.rs.core.UriBuilder; //导入依赖的package包/类
@Consumes(MediaType.APPLICATION_JSON)
@Path("/{projectName}/statuses/{commit}")
   @POST
   public Response save(@PathParam("projectName") String projectName, @PathParam("commit") String commit, 
   		Map<String, String> commitStatus, @Context UriInfo uriInfo) {

	Project project = getProject(projectName);
   	if (!SecurityUtils.canWrite(project))
   		throw new UnauthorizedException();
   	
   	String state = commitStatus.get("state").toUpperCase();
   	if (state.equals("PENDING"))
   		state = "RUNNING";
   	Verification verification = new Verification(Verification.Status.valueOf(state), 
   			new Date(), commitStatus.get("description"), commitStatus.get("target_url"));
   	String context = commitStatus.get("context");
   	if (context == null)
   		context = "default";
   	verificationManager.saveVerification(project, commit, context, verification);
   	UriBuilder uriBuilder = uriInfo.getAbsolutePathBuilder();
   	uriBuilder.path(context);
   	commitStatus.put("id", "1");
   	
   	return Response.created(uriBuilder.build()).entity(commitStatus).type(RestConstants.JSON_UTF8).build();
   }
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:26,代码来源:CommitStatusResource.java

示例2: shouldCreateASessionFromInputs

import javax.ws.rs.core.UriBuilder; //导入依赖的package包/类
@Test
public void shouldCreateASessionFromInputs() {
    // Given
    SamlResponseWithAuthnRequestInformationDto samlResponse = aSamlResponseWithAuthnRequestInformationDto().build();
    URI assertionConsumerServiceUri = UriBuilder.fromUri(UUID.randomUUID().toString()).build();

    final SessionId sessionId = SessionIdBuilder.aSessionId().with("coffee-pasta").build();

    givenSamlEngineTranslatesRequest(samlResponse);
    givenConfigReturnsAssertionConsumerServiceURLFor(samlResponse, assertionConsumerServiceUri);
    givenSessionIsCreated(samlResponse, assertionConsumerServiceUri, sessionId, false);

    // When
    SessionId result = service.create(requestDto);

    // Then
    assertThat(result, is(sessionId));
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:19,代码来源:SessionServiceTest.java

示例3: webSocketsStatusTest

import javax.ws.rs.core.UriBuilder; //导入依赖的package包/类
/**
 * Ensures that CDI event is relayed over the webSocket status endpoint.
 *
 * @throws Exception when the test has failed
 */
@Test
public void webSocketsStatusTest() throws Exception {
    //given
    UUID uuid = UUID.randomUUID();
    WebSocketContainer container = ContainerProvider.getWebSocketContainer();
    URI uri = UriBuilder.fromUri(deploymentUrl).scheme("ws").path("status").path(uuid.toString()).build();
    container.connectToServer(endpoint, uri);

    //when
    Thread.sleep(200);
    testEvent.fire(new StatusMessageEvent(uuid, StatusEventType.GITHUB_CREATE,
                                          singletonMap(EXTRA_DATA_KEY, "http://github.com/dummy-project-location")));
    endpoint.getLatch().await(1, TimeUnit.SECONDS);

    //then
    assertNotNull("a status message should have been send", endpoint.getMessage());
    assertTrue(endpoint.getMessage().contains(EXTRA_DATA_KEY));
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:24,代码来源:MissionControlStatusEndpointIT.java

示例4: shouldGetACountryAuthnRequestWithOverriddenSsoUrl

import javax.ws.rs.core.UriBuilder; //导入依赖的package包/类
@Test
public void shouldGetACountryAuthnRequestWithOverriddenSsoUrl() throws Exception {
    // Given
    SessionId sessionId = createNewSessionId();
    when(sessionRepository.sessionExists(sessionId)).thenReturn(true);
    when(sessionRepository.isSessionInState(sessionId, CountrySelectedState.class)).thenReturn(true);
    AuthnRequestFromHub authnRequestFromHub = anAuthnRequestFromHub().withSsoUrl(URI.create("/theSsoUri")).build();
    when(authnRequestHandler.getIdaAuthnRequestFromHub(sessionId)).thenReturn(authnRequestFromHub);
    URI ssoUri = UriBuilder.fromUri(UUID.randomUUID().toString()).build();
    SamlRequestDto samlRequest = new SamlRequestDto("samlRequest", ssoUri);
    when(samlEngineProxy.generateCountryAuthnRequestFromHub(any(IdaAuthnRequestFromHubDto.class))).thenReturn(samlRequest);

    // When
    AuthnRequestFromHubContainerDto countryAuthnRequest = service.getIdpAuthnRequest(sessionId);

    // Then
    AuthnRequestFromHubContainerDto expected = new AuthnRequestFromHubContainerDto(samlRequest.getSamlRequest(), ssoUri, authnRequestFromHub.getRegistering());
    assertThat(countryAuthnRequest).isEqualToComparingFieldByField(expected);

    ArgumentCaptor<IdaAuthnRequestFromHubDto> requestFromHubDtoArgumentCaptor = ArgumentCaptor.forClass(IdaAuthnRequestFromHubDto.class);
    verify(samlEngineProxy).generateCountryAuthnRequestFromHub(requestFromHubDtoArgumentCaptor.capture());
    assertThat(requestFromHubDtoArgumentCaptor.getValue().getOverriddenSsoUrl(), notNullValue());
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:24,代码来源:SessionServiceTest.java

示例5: filter_QueryParametersPassing_WhenRequestUrlContainsQueryParameters

import javax.ws.rs.core.UriBuilder; //导入依赖的package包/类
@Test
public void filter_QueryParametersPassing_WhenRequestUrlContainsQueryParameters()
    throws Exception {

  // Arrange
  String queryPart = "test=123";
  URI uri = URI.create("http://" + DBEERPEDIA.ORG_HOST + "/beer?" + queryPart);
  when(uriInfo.getRequestUriBuilder()).thenReturn(UriBuilder.fromUri(uri));

  // Act
  hostPreMatchingRequestFilter.filter(containerRequestContext);

  // Assert
  ArgumentCaptor<URI> capture = ArgumentCaptor.forClass(URI.class);
  verify(containerRequestContext).setRequestUri(capture.capture());

  assertEquals(queryPart, capture.getValue().getQuery());
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:19,代码来源:HostPreMatchingRequestFilterTest.java

示例6: addTenantId

import javax.ws.rs.core.UriBuilder; //导入依赖的package包/类
/**
 * Creates a tenant with the given tenant identifier.
 *
 * @param stream TenantId JSON stream
 * @return status of the request - CREATED if the JSON is correct,
 * BAD_REQUEST if the JSON is invalid
 * @onos.rsModel TenantId
 */
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response addTenantId(InputStream stream) {
    try {
        final TenantId tid = getTenantIdFromJsonStream(stream);
        vnetAdminService.registerTenantId(tid);
        final TenantId resultTid = getExistingTenantId(vnetAdminService, tid);
        UriBuilder locationBuilder = uriInfo.getBaseUriBuilder()
                .path("tenants")
                .path(resultTid.id());
        return Response
                .created(locationBuilder.build())
                .build();
    } catch (IOException e) {
        throw new IllegalArgumentException(e);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:TenantWebResource.java

示例7: shouldReturnOkWhenGeneratingIdpAuthnRequestFromHubIsSuccessfulOnRegistration

import javax.ws.rs.core.UriBuilder; //导入依赖的package包/类
@Test
public void shouldReturnOkWhenGeneratingIdpAuthnRequestFromHubIsSuccessfulOnRegistration() throws Exception {
    // Given
    SessionId sessionId = aSessionIsCreated();
    anIdpIsSelectedForRegistration(sessionId, idpEntityId);

    final SamlRequestDto samlRequestDto = new SamlRequestDto("coffee-pasta", idpSsoUri);
    final AuthnRequestFromHubContainerDto expectedResult = anAuthnRequestFromHubContainerDtoWithRegistering(samlRequestDto, true);

    samlEngineStub.setupStubForIdpAuthnRequestGenerate(samlRequestDto);

    // When
    AuthnRequestFromHubContainerDto result = getEntity(UriBuilder.fromPath(Urls.PolicyUrls
            .IDP_AUTHN_REQUEST_RESOURCE).build
            (sessionId), AuthnRequestFromHubContainerDto.class);

    //Then
    assertThat(result).isEqualToComparingFieldByField(expectedResult);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:20,代码来源:SessionResourceIntegrationTest.java

示例8: getConnectorQueriesForItem

import javax.ws.rs.core.UriBuilder; //导入依赖的package包/类
/**
 * Provided the user has at least the basic CONNECTOR privilege, get a list
 * of all connectors, and from that list exclude any of those Connectors for
 * which the user lacks the PRIV_VIEWCONTENT_VIA_CONNECTOR privilege.
 * 
 * @param uuid Item uuid, not relevant to the query per se, but used in
 *            composing result set
 * @param version Item version, not relevant to the query per se, but used
 *            in composing result set
 * @return
 */
@GET
@Path("/{uuid}/{version}")
@ApiOperation(value = "List of connectors and usage links")
public List<ConnectorBean> getConnectorQueriesForItem(@ApiParam("Item UUID") @PathParam("uuid") String uuid,
	@ApiParam("Item version") @PathParam("version") int version)
{
	List<ConnectorBean> connectorBeans = Lists.newArrayList();
	Iterable<BaseEntityLabel> connectorDescriptors = connectorService.listForViewing();
	UriBuilder uriBuilder = urlLinkService.getMethodUriBuilder(getClass(), "getUsagesOfItemForConnector");
	for( BaseEntityLabel bent : connectorDescriptors )
	{
		Connector connector = connectorService.get(bent.getId());
		ConnectorBean bean = serializer.serialize(connector, null, true);
		Map<String, URI> links = Maps.newHashMap();
		URI uri = uriBuilder.build(uuid, version, bent.getUuid());
		links.put("usage", uri);
		bean.set("links", links);
		connectorBeans.add(bean);
	}
	return connectorBeans;
}
 
开发者ID:equella,项目名称:Equella,代码行数:33,代码来源:ConnectorResource.java

示例9: setUp

import javax.ws.rs.core.UriBuilder; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    idpEntityId = "idpEntityId";
    rpEntityId = "rpEntityId";
    msaEntityId = "msaEntityId";
    translatedAuthnRequest = SamlResponseWithAuthnRequestInformationDtoBuilder.aSamlResponseWithAuthnRequestInformationDto().withIssuer(rpEntityId).build();
    rpSamlRequest = SamlAuthnRequestContainerDtoBuilder.aSamlAuthnRequestContainerDto().build();
    idpSsoUri = UriBuilder.fromPath("idpSsoUri").build();
    
    configStub.reset();
    configStub.setupStubForEnabledIdps(asList(idpEntityId));
    configStub.setUpStubForLevelsOfAssurance(rpEntityId);
    configStub.setUpStubForMatchingServiceEntityId(rpEntityId, msaEntityId);
    configStub.setupStubForEidasEnabledForTransaction(rpEntityId, false);
    eventSinkStub.setupStubForLogging();
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:17,代码来源:MatchingServiceResourcesIntegrationTest.java

示例10: shouldReturnOkWhenAMatchingServiceFailureResponseIsReceived

import javax.ws.rs.core.UriBuilder; //导入依赖的package包/类
@Test
public void shouldReturnOkWhenAMatchingServiceFailureResponseIsReceived() throws Exception {
    SessionId sessionId = aSessionIsCreated();
    anIdpIsSelectedForRegistration(sessionId, idpEntityId);
    anIdpAuthnRequestWasGenerated(sessionId);
    anAuthnResponseFromIdpWasReceivedAndMatchingRequestSent(sessionId);

    URI uri = UriBuilder.fromPath(Urls.PolicyUrls.MATCHING_SERVICE_REQUEST_FAILURE_RESOURCE).build(sessionId);
    Response response = postResponse(policy.uri(uri.toASCIIString()), null);

    assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    assertThat(getSessionStateName(sessionId)).isEqualTo(MatchingServiceRequestErrorState.class.getName());

    // check that the state has been updated
    uri = UriBuilder.fromPath(Urls.PolicyUrls.RESPONSE_PROCESSING_DETAILS_RESOURCE).build(sessionId);
    response = getResponse(policy.uri(uri.toASCIIString()));

    assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    ResponseProcessingDetails responseProcessingDetails = response.readEntity(ResponseProcessingDetails.class);
    assertThat(responseProcessingDetails.getResponseProcessingStatus()).isEqualTo(ResponseProcessingStatus.SHOW_MATCHING_ERROR_PAGE);
    assertThat(responseProcessingDetails.getSessionId()).isEqualTo(sessionId);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:23,代码来源:MatchingServiceResourcesIntegrationTest.java

示例11: journeyWithFailedAccountCreation

import javax.ws.rs.core.UriBuilder; //导入依赖的package包/类
@Test
public void journeyWithFailedAccountCreation() throws Exception {
    final SessionId sessionId = aSessionIsCreated();
    anIdpIsSelectedForRegistration(sessionId, idpEntityId);
    anIdpAuthnRequestWasGenerated(sessionId);
    anAuthnResponseFromIdpWasReceivedAndMatchingRequestSent(sessionId);
    aNoMatchResponseWasReceivedFromTheMSAForCycle01_withCycle3Enabled(sessionId);
    configStub.setUpStubForEnteringAwaitingCycle3DataState(rpEntityId);
    aCycle3AttributeHasBeenSentToPolicyFromTheUser(sessionId, "#1");
    aNoMatchResponseHasBeenReceivedAndUserAccountCreationIsEnabled(sessionId);
    aUserAccountCreationResponseIsReceived(sessionId, MatchingServiceIdaStatus.UserAccountCreationFailed);

    URI uri = UriBuilder.fromPath(Urls.PolicyUrls.RESPONSE_PROCESSING_DETAILS_RESOURCE).build(sessionId);
    Response response = getResponse(policy.uri(uri.toASCIIString()));

    assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    ResponseProcessingDetails responseProcessingDetails = response.readEntity(ResponseProcessingDetails.class);
    assertThat(responseProcessingDetails.getResponseProcessingStatus()).isEqualTo(ResponseProcessingStatus.USER_ACCOUNT_CREATION_FAILED);
    assertThat(responseProcessingDetails.getSessionId()).isEqualTo(sessionId);
    assertThat(getSessionStateName(sessionId)).isEqualTo(UserAccountCreationFailedState.class.getName());
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:22,代码来源:MatchingServiceResourcesIntegrationTest.java

示例12: isResponseFromHubReady_shouldReturnFailedStatusWhenAProblemHasOccurredWhilstMatchingCycle1

import javax.ws.rs.core.UriBuilder; //导入依赖的package包/类
@Test
public void isResponseFromHubReady_shouldReturnFailedStatusWhenAProblemHasOccurredWhilstMatchingCycle1() throws Exception {
    final SessionId sessionId = aSessionIsCreated();
    anIdpIsSelectedForRegistration(sessionId, idpEntityId);
    anIdpAuthnRequestWasGenerated(sessionId);
    anAuthnResponseFromIdpWasReceivedAndMatchingRequestSent(sessionId);
    aMatchingServiceFailureResponseHasBeenReceived(sessionId);

    URI uri = UriBuilder.fromPath(Urls.PolicyUrls.RESPONSE_PROCESSING_DETAILS_RESOURCE).build(sessionId);
    Response response = getResponse(policy.uri(uri.toASCIIString()));

    assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    ResponseProcessingDetails responseProcessingDetails = response.readEntity(ResponseProcessingDetails.class);
    assertThat(responseProcessingDetails.getResponseProcessingStatus()).isEqualTo(ResponseProcessingStatus.SHOW_MATCHING_ERROR_PAGE);
    assertThat(responseProcessingDetails.getSessionId()).isEqualTo(sessionId);
    assertThat(getSessionStateName(sessionId)).isEqualTo(MatchingServiceRequestErrorState.class.getName());
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:18,代码来源:MatchingServiceResourcesIntegrationTest.java

示例13: getCycle3AttributeRequestData_shouldReturnExpectedAttributeData

import javax.ws.rs.core.UriBuilder; //导入依赖的package包/类
@Test
public void getCycle3AttributeRequestData_shouldReturnExpectedAttributeData() throws Exception {
    final SessionId sessionId = aSessionIsCreated();
    anIdpIsSelectedForRegistration(sessionId, idpEntityId);
    anIdpAuthnRequestWasGenerated(sessionId);
    anAuthnResponseFromIdpWasReceivedAndMatchingRequestSent(sessionId);
    final String cycle3Attribute = aNoMatchResponseWasReceivedFromTheMSAForCycle01_withCycle3Enabled(sessionId);

    URI uri = UriBuilder.fromPath(Urls.PolicyUrls.CYCLE_3_REQUEST_RESOURCE).build(sessionId);
    Response response = getResponse(policy.uri(uri.toASCIIString()));

    assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());

    final Cycle3AttributeRequestData attributeData = response.readEntity(Cycle3AttributeRequestData.class);
    assertThat(attributeData.getAttributeName()).isEqualTo(cycle3Attribute);
    assertThat(attributeData.getRequestIssuerId()).isEqualTo(rpEntityId);
    assertThat(getSessionStateName(sessionId)).isEqualTo(AwaitingCycle3DataState.class.getName());
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:19,代码来源:MatchingServiceResourcesIntegrationTest.java

示例14: doRoleCommand

import javax.ws.rs.core.UriBuilder; //导入依赖的package包/类
private void doRoleCommand(String serviceName, String roleName, RoleCommand roleCommand) {
  URI uri = UriBuilder.fromUri(serverHostname)
      .path("api")
      .path(API_VERSION)
      .path("clusters")
      .path(clusterName)
      .path("services")
      .path(serviceName)
      .path("roleCommands")
      .path(roleCommand.toString())
      .build();
  String body = "{ \"items\": [ \"" + roleName + "\" ] }";
  LOG.info("Executing POST against " + uri + " with body " + body + "...");
  ClientResponse response = client.resource(uri)
      .type(MediaType.APPLICATION_JSON)
      .post(ClientResponse.class, body);

  int statusCode = response.getStatus();
  if (statusCode != Response.Status.OK.getStatusCode()) {
    throw new HTTPException(statusCode);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:RESTApiClusterManager.java

示例15: generateSamlRequestWithOverriddenSsoUri

import javax.ws.rs.core.UriBuilder; //导入依赖的package包/类
@Test
public void generateSamlRequestWithOverriddenSsoUri() {
    // Given
    String theCountryEntityId = "theCountryEntityId";
    URI overriddenSsoURI = URI.create("http://overridden.foo.bar");
    IdaAuthnRequestFromHubDto dto = new IdaAuthnRequestFromHubDto("1", null, Optional.of(false), null, theCountryEntityId, false, overriddenSsoURI);

    URI ssoUri = UriBuilder.fromPath("/the-sso-uri").build();
    String samlRequest = "samlRequest";

    when(eidasAuthnRequestFromHubStringTransformer.apply(any())).thenReturn(samlRequest);
    when(eidasAuthnRequestTranslator.getEidasAuthnRequestFromHub(dto, ssoUri, HUB_ENTITY_ID)).thenReturn(null);

    // When
    final SamlRequestDto output = service.generateSaml(dto);

    // Then
    assertThat(output.getSamlRequest()).isEqualTo(samlRequest);
    assertThat(output.getSsoUri()).isEqualTo(overriddenSsoURI);

    verifyNoMoreInteractions(countrySingleSignOnServiceHelper);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:23,代码来源:CountryAuthnRequestGeneratorServiceTest.java


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