當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。