當前位置: 首頁>>代碼示例>>Java>>正文


Java UriInfo類代碼示例

本文整理匯總了Java中javax.ws.rs.core.UriInfo的典型用法代碼示例。如果您正苦於以下問題:Java UriInfo類的具體用法?Java UriInfo怎麽用?Java UriInfo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


UriInfo類屬於javax.ws.rs.core包,在下文中一共展示了UriInfo類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: save

import javax.ws.rs.core.UriInfo; //導入依賴的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: listAllCustomerEvents

import javax.ws.rs.core.UriInfo; //導入依賴的package包/類
@GET
@Produces({"application/hal+json", "application/hal+json;concept=events;v=1"})
@ApiOperation(
        value = "obtain all events emitted by the customer-event service", response = EventsRepresentation.class,
        notes = " the events are signalled by this resource as this this is the authoritative resource for all events that " +
                "subscribers to the customers service should be able to listen for and react to. In other words this is the authoritative" +
                "feed for the customers service",
        authorizations = {
                @Authorization(value = "oauth2", scopes = {}),
                @Authorization(value = "oauth2-cc", scopes = {}),
                @Authorization(value = "oauth2-ac", scopes = {}),
                @Authorization(value = "oauth2-rop", scopes = {}),
                @Authorization(value = "Bearer")
        },
        tags = {"interval", "events"},
        produces = "application/hal+json,  application/hal+json;concept=events;v=1",
        nickname = "listAllCustomerEvents"
    )
@ApiResponses(value = {
        @ApiResponse(code = 415, message = "Content type not supported.")
    })
public Response listAllCustomerEvents(@Context UriInfo uriInfo, @Context Request request,
                        @HeaderParam("Accept") String accept, @QueryParam("interval") String interval) {
    return eventsProducers.getOrDefault(accept, this::handleUnsupportedContentType)
            .getResponse(uriInfo, request, interval);
}
 
開發者ID:psd2-in-a-box,項目名稱:mid-tier,代碼行數:27,代碼來源:CustomerEventServiceExposure.java

示例3: getCustomerServiceMetadata

import javax.ws.rs.core.UriInfo; //導入依賴的package包/類
@GET
@Produces({"application/hal+json", "application/hal+json;concept=metadata;v=1"})
@ApiOperation(
        value = "metadata for the events endpoint", response = EventsMetadataRepresentation.class,
        authorizations = {
                @Authorization(value = "oauth2", scopes = {}),
                @Authorization(value = "oauth2-cc", scopes = {}),
                @Authorization(value = "oauth2-ac", scopes = {}),
                @Authorization(value = "oauth2-rop", scopes = {}),
                @Authorization(value = "Bearer")
        },
        notes = " the events are signalled by this resource as this this is the authoritative resource for all events that " +
                "subscribers to the customer service should be able to listen for and react to. In other words this is the authoritative" +
                "feed for the customer service",
        tags = {"events"},
        produces = "application/hal+json,  application/hal+json;concept=metadata;v=1",
        nickname = "getCustomerMetadata"
    )
@ApiResponses(value = {
        @ApiResponse(code = 415, message = "Content type not supported.")
    })
public Response getCustomerServiceMetadata(@Context UriInfo uriInfo, @Context Request request, @HeaderParam("Accept") String accept) {
    return eventMetadataProducers.getOrDefault(accept, this::handleUnsupportedContentType).getResponse(uriInfo, request);
}
 
開發者ID:psd2-in-a-box,項目名稱:mid-tier,代碼行數:25,代碼來源:CustomerEventFeedMetadataServiceExposure.java

示例4: beforeCreate_Normal_type_unitmaster

import javax.ws.rs.core.UriInfo; //導入依賴的package包/類
/**
 * Test beforeCreate().
 * normal.
 * Type is UnitMaster.
 * @throws Exception Unintended exception in test
 */
@Test
public void beforeCreate_Normal_type_unitmaster() throws Exception {
    // Test method args
    OEntityWrapper oEntityWrapper = PowerMockito.mock(OEntityWrapper.class);

    // Mock settings
    UriInfo uriInfo = mock(UriInfo.class);
    URI uri = new URI("");
    doReturn(uri).when(uriInfo).getBaseUri();
    AccessContext accessContext = PowerMockito.mock(AccessContext.class);
    unitCtlResource = spy(new UnitCtlResource(accessContext, uriInfo));

    doReturn(accessContext).when(unitCtlResource).getAccessContext();
    doReturn(AccessContext.TYPE_UNIT_MASTER).when(accessContext).getType();

    // Expected result
    // None.

    // Run method
    unitCtlResource.beforeCreate(oEntityWrapper);

    // Confirm result
    // None.
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:31,代碼來源:UnitCtlResourceTest.java

示例5: messages

import javax.ws.rs.core.UriInfo; //導入依賴的package包/類
/**
 * メッセージ送信API.
 * @param version PCSバージョン
 * @param uriInfo UriInfo
 * @param reader リクエストボディ
 * @return レスポンス
 */
@WriteAPI
@POST
@Path("send")
public Response messages(
        @HeaderParam(PersoniumCoreUtils.HttpHeaders.X_PERSONIUM_VERSION) final String version,
        @Context final UriInfo uriInfo,
        final Reader reader) {
    // アクセス製禦
    this.davRsCmp.checkAccessContext(this.accessContext, CellPrivilege.MESSAGE);

    // データ登録
    PersoniumODataProducer producer = ModelFactory.ODataCtl.cellCtl(this.accessContext.getCell());
    MessageODataResource moResource = new MessageODataResource(this, producer, SentMessagePort.EDM_TYPE_NAME);
    moResource.setVersion(version);
    Response respose = moResource.createMessage(uriInfo, reader);
    return respose;
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:25,代碼來源:MessageResource.java

示例6: postNoBody

import javax.ws.rs.core.UriInfo; //導入依賴的package包/類
/**
 * Build a response for POST create namespace with no properties specified.
 * @param message value not used.
 * @param headers value not used.
 * @return response code.
 */
@POST
public Response postNoBody(final byte[] message,
    final @Context UriInfo uriInfo, final @Context HttpHeaders headers) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("POST " + uriInfo.getAbsolutePath());
  }
  servlet.getMetrics().incrementRequests(1);
  try{
    NamespacesInstanceModel model = new NamespacesInstanceModel(namespace);
    return processUpdate(model, false, uriInfo);
  }catch(IOException ioe){
    servlet.getMetrics().incrementFailedPutRequests(1);
    throw new RuntimeException("Cannot retrieve info for '" + namespace + "'.");
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:22,代碼來源:NamespacesInstanceResource.java

示例7: testCreate

import javax.ws.rs.core.UriInfo; //導入依賴的package包/類
@Test
public void testCreate() throws Exception {
    Request request = mock(Request.class);
    UriInfo ui = mock(UriInfo.class);
    when(ui.getBaseUriBuilder()).then(new UriBuilderFactory(URI.create("http://mock")));
    when(ui.getPath()).thenReturn("http://mock");

    AccountUpdateRepresentation accountUpdate = mock(AccountUpdateRepresentation.class);
    when(accountUpdate.getName()).thenReturn("new Account");
    when(accountUpdate.getRegNo()).thenReturn("5479");
    when(accountUpdate.getAccountNo()).thenReturn("12345678");
    when(accountUpdate.getCustomer()).thenReturn("cust-1");

    when(archivist.findAccount("5479", "12345678")).thenReturn(Optional.empty());

    AccountRepresentation resp = (AccountRepresentation) service.createOrUpdate(ui, request, "5479", "12345678", accountUpdate).getEntity();

    assertEquals("new Account", resp.getName());
    assertEquals("5479", resp.getRegNo());
    assertEquals("12345678", resp.getAccountNo());
    assertEquals("http://mock/accounts/5479-12345678", resp.getSelf().getHref());
}
 
開發者ID:psd2-in-a-box,項目名稱:mid-tier,代碼行數:23,代碼來源:AccountServiceExposureTest.java

示例8: deleteZNode

import javax.ws.rs.core.UriInfo; //導入依賴的package包/類
@DELETE
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
        MediaType.APPLICATION_XML, MediaType.APPLICATION_OCTET_STREAM })
public void deleteZNode(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @Context UriInfo ui) throws InterruptedException, KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    zk.delete(path, version);
}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:21,代碼來源:ZNodeResource.java

示例9: getUiPageRequestSimpleSort

import javax.ws.rs.core.UriInfo; //導入依賴的package包/類
/**
 * Simple page request with default values but sorted column.
 */
@Test
public void getUiPageRequestSimpleSort() {
	// create a mock URI info with pagination informations
	final UriInfo uriInfo = newUriInfo();
	uriInfo.getQueryParameters().add("sidx", "colX");
	final UiPageRequest pageRequest = paginationJson.getUiPageRequest(uriInfo);
	Assert.assertNotNull(pageRequest);
	Assert.assertEquals(1, pageRequest.getPage());
	Assert.assertEquals(10, pageRequest.getPageSize());
	Assert.assertNotNull(pageRequest.getUiFilter());
	Assert.assertNull(pageRequest.getUiFilter().getGroupOp());
	Assert.assertNull(pageRequest.getUiFilter().getRules());
	Assert.assertNotNull(pageRequest.getUiSort());
	Assert.assertEquals("colX", pageRequest.getUiSort().getColumn());
	Assert.assertEquals(Direction.ASC, pageRequest.getUiSort().getDirection());
}
 
開發者ID:ligoj,項目名稱:bootstrap,代碼行數:20,代碼來源:PaginationJsonTest.java

示例10: list

import javax.ws.rs.core.UriInfo; //導入依賴的package包/類
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiImplicitParams({
    @ApiImplicitParam(
        name = "sort", value = "Sort the result list according to the given field value",
        paramType = "query", dataType = "string"),
    @ApiImplicitParam(
        name = "direction", value = "Sorting direction when a 'sort' field is provided. Can be 'asc' " +
        "(ascending) or 'desc' (descending)", paramType = "query", dataType = "string"),
    @ApiImplicitParam(
        name = "page", value = "Page number to return", paramType = "query", dataType = "integer", defaultValue = "1"),
    @ApiImplicitParam(
        name = "per_page", value = "Number of records per page", paramType = "query", dataType = "integer", defaultValue = "20"),
    @ApiImplicitParam(
        name = "query", value = "The search query to filter results on", paramType = "query", dataType = "string"),

})
default ListResult<T> list(@Context UriInfo uriInfo) {
    Class<T> clazz = resourceKind().getModelClass();
    return getDataManager().fetchAll(
        clazz,
        new ReflectiveFilterer<>(clazz, new FilterOptionsFromQueryParams(uriInfo).getFilters()),
        new ReflectiveSorter<>(clazz, new SortOptionsFromQueryParams(uriInfo)),
        new PaginationFilter<>(new PaginationOptionsFromQueryParams(uriInfo))
    );
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:27,代碼來源:Lister.java

示例11: thrownErrorWithMDC

import javax.ws.rs.core.UriInfo; //導入依賴的package包/類
@Test
public void thrownErrorWithMDC() {

    MDC.put(MDCKeys.REQUEST_ID, "abc");
    MDC.put(MDCKeys.HOST, "localhost");
    MDC.put(MDCKeys.REQUEST_URI, "http://hello");
    MDC.put(MDCKeys.JWT_ID, "def");
    final ErrorResponse response = new ErrorResponse(new IOException("ahem"), mock(UriInfo.class), true);
    assertNotNull(response.getStackTrace());
    assertNull(response.getCause());
    assertEquals(URI.create("http://hello"), response.getRequestUri());
    assertEquals("abc", response.getRequestId());
    assertEquals("def", response.getJwtId());
    assertEquals("localhost", response.getHost());

}
 
開發者ID:trajano,項目名稱:app-ms,代碼行數:17,代碼來源:ErrorResponseTest.java

示例12: getPageRequestNoMappingOrder

import javax.ws.rs.core.UriInfo; //導入依賴的package包/類
/**
 * Sorted direction with ordering but no mapping provided.
 */
@Test
public void getPageRequestNoMappingOrder() {
	// create a mock URI info with pagination informations
	final UriInfo uriInfo = newUriInfo();
	uriInfo.getQueryParameters().add(DataTableAttributes.PAGE_LENGTH, "100");
	uriInfo.getQueryParameters().add(DataTableAttributes.SORTED_COLUMN, "2");
	uriInfo.getQueryParameters().add("columns[2][data]", "col1");
	uriInfo.getQueryParameters().add(DataTableAttributes.SORT_DIRECTION, "asc");
	final PageRequest pageRequest = paginationJson.getPageRequest(uriInfo, null);
	Assert.assertNotNull(pageRequest);
	Assert.assertFalse(pageRequest.getSort().isSorted());
	Assert.assertEquals(0, pageRequest.getOffset());
	Assert.assertEquals(0, pageRequest.getPageNumber());
	Assert.assertEquals(100, pageRequest.getPageSize());
}
 
開發者ID:ligoj,項目名稱:bootstrap,代碼行數:19,代碼來源:PaginationJsonTest.java

示例13: getOneComment

import javax.ws.rs.core.UriInfo; //導入依賴的package包/類
@GET
@Path("/{uuid}/{version}/comment/{commentuuid}")
@ApiOperation(value = "Retrieve a single comment for an item by ID.")
CommentBean getOneComment(
	@Context 
		UriInfo info,
	@ApiParam(APIDOC_ITEMUUID) 
	@PathParam("uuid") 
		String uuid,
	@ApiParam(APIDOC_ITEMVERSION) 
	@PathParam("version") 
		int version,
	@ApiParam(required = true) 
	@PathParam("commentuuid") 
		String commentUuid
	);
 
開發者ID:equella,項目名稱:Equella,代碼行數:17,代碼來源:EquellaItemResource.java

示例14: testUpdate

import javax.ws.rs.core.UriInfo; //導入依賴的package包/類
@Test
public void testUpdate() throws Exception {
    Request request = mock(Request.class);
    UriInfo ui = mock(UriInfo.class);
    when(ui.getBaseUriBuilder()).then(new UriBuilderFactory(URI.create("http://mock")));
    when(ui.getPath()).thenReturn("http://mock");

    Account existingAcc = new Account("5479", "12345678", "Savings account", "cust-1");
    when(archivist.findAccount("5479", "12345678")).thenReturn(Optional.of(existingAcc));

    AccountUpdateRepresentation accountUpdate = mock(AccountUpdateRepresentation.class);
    when(accountUpdate.getName()).thenReturn("new name");
    when(accountUpdate.getRegNo()).thenReturn("5479");
    when(accountUpdate.getAccountNo()).thenReturn("12345678");

    AccountRepresentation resp = (AccountRepresentation) service.createOrUpdate(ui, request, "5479", "12345678", accountUpdate).getEntity();

    //name of the existing account should be updated
    assertEquals("new name", existingAcc.getName());
    assertEquals("new name", resp.getName());
    assertEquals("5479", resp.getRegNo());
    assertEquals("12345678", resp.getAccountNo());
    assertEquals("0", existingAcc.getBalance().toString());
    assertEquals("0", resp.getBalance().toString());
    assertEquals("http://mock/accounts/5479-12345678", resp.getSelf().getHref());
}
 
開發者ID:psd2-in-a-box,項目名稱:mid-tier,代碼行數:27,代碼來源:AccountServiceExposureTest.java

示例15: filter

import javax.ws.rs.core.UriInfo; //導入依賴的package包/類
@Override
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException {
    System.out.println("Response = " + requestContext + " " + responseContext);
    Long start = concurrentRequests.get(requestContext);
    concurrentRequests.remove(requestContext);
    long duration = (System.nanoTime() - start);
    System.out.println("Duration: " + duration);
    UriInfo uriInfo = requestContext.getUriInfo();

    String ipv4 = extractIpAddress(uriInfo);
    System.out.println("ipv4 = " + ipv4);
    String serviceName = extractServiceName(uriInfo);
    System.out.println("serviceName = " + serviceName);
    String spanName = extractSpanName(uriInfo);
    System.out.println("spanName = " + spanName);
    Optional<String> traceId = extractTraceId(requestContext);
    String spanId = traceId.map(id -> this.tracee.saveChildSpan(id, spanName, serviceName, ipv4, 0)).
            orElseGet(() -> this.tracee.saveParentSpan(spanName, serviceName, ipv4, duration));
    System.out.println("Storing span id: " + spanId);
    storeSpandId(responseContext, spanId);
}
 
開發者ID:AdamBien,項目名稱:SpanEE,代碼行數:22,代碼來源:SpanEEContainerRequestFilter.java


注:本文中的javax.ws.rs.core.UriInfo類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。