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


Java Request类代码示例

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


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

示例1: testListEventsByCategory

import javax.ws.rs.core.Request; //导入依赖的package包/类
@Test
public void testListEventsByCategory() throws URISyntaxException {
    UriInfo ui = mock(UriInfo.class);
    when(ui.getBaseUriBuilder()).then(new UriBuilderFactory(URI.create("http://mock")));

    Request request = mock(Request.class);

    when(archivist.getEventsForCategory(Event.getCategory("some", "category"), Optional.empty()))
            .thenReturn(Collections.singletonList(new Event(new URI("customer-events/some-category/eventSID"),
                    "some-category", CurrentTime.now())));

    Response response = service.getByCategory(ui, request, "application/hal+json", "some-category", "");
    EventsRepresentation events = (EventsRepresentation) response.getEntity();

    assertEquals(1, events.getEvents().size());
    assertEquals("http://mock/customer-events", events.getSelf().getHref());

    response = service.getByCategory(ui, request, "application/hal+json;no-real-type", "some-category", "");
    assertEquals(415,response.getStatus());
}
 
开发者ID:psd2-in-a-box,项目名称:mid-tier,代码行数:21,代码来源:LocationEventServiceExposureTest.java

示例2: list

import javax.ws.rs.core.Request; //导入依赖的package包/类
@GET
@Produces({"application/hal+json", "application/hal+json;concept=location;v=1"})
@ApiOperation(value = "lists locations", response = LocationsRepresentation.class,
        authorizations = {
                @Authorization(value = "oauth2", scopes = {}),
                @Authorization(value = "oauth2-cc", scopes = {}),
                @Authorization(value = "oauth2-ac", scopes = {}),
                @Authorization(value = "oauth2-rop", scopes = {}),
                @Authorization(value = "Bearer")
        },
        extensions = {@Extension(name = "roles", properties = {
                @ExtensionProperty(name = "advisor", value = "advisors are allowed getting every location"),
                @ExtensionProperty(name = "customer", value = "customer only allowed getting own locations")}
        )},
        produces = "application/hal+json, application/hal+json;concept=locations;v=1",
        notes = "List all locations in a default projection, which is Location version 1" +
                "Supported projections and versions are: " +
                "Locations in version 1 " +
                "The Accept header for the default version is application/hal+json;concept=location;v=1.0.0.... " +
                "The format for the default version is {....}", nickname = "listLocations")
@ApiResponses(value = {
        @ApiResponse(code = 415, message = "Content type not supported.")
    })
public Response list(@Context UriInfo uriInfo, @Context Request request, @HeaderParam("Accept") String accept) {
    return locationsProducers.getOrDefault(accept, this::handleUnsupportedContentType).getResponse(uriInfo, request);
}
 
开发者ID:psd2-in-a-box,项目名称:mid-tier,代码行数:27,代码来源:LocationServiceExposure.java

示例3: list

import javax.ws.rs.core.Request; //导入依赖的package包/类
@GET
@Produces({"application/hal+json", "application/hal+json;concept=customers;v=1"})
@ApiOperation(value = "lists customers", response = CustomersRepresentation.class,
        authorizations = {
                @Authorization(value = "oauth2", scopes = {}),
                @Authorization(value = "oauth2-cc", scopes = {}),
                @Authorization(value = "oauth2-ac", scopes = {}),
                @Authorization(value = "oauth2-rop", scopes = {}),
                @Authorization(value = "Bearer")
        },
        extensions = {@Extension(name = "roles", properties = {
                @ExtensionProperty(name = "advisor", value = "advisors are allowed getting every customer"),
                @ExtensionProperty(name = "customer", value = "customer only allowed getting own information")}
        )},
        produces = "application/hal+json, application/hal+json;concept=customers;v=1",
        notes = "List all customers in a default projection, which is Customers version 1" +
                "Supported projections and versions are: " +
                "Customers in version 1 " +
                "The Accept header for the default version is application/hal+json;concept=customers;v=1.0.0.... " +
                "The format for the default version is {....}", nickname = "listCustomers")
@ApiResponses(value = {
        @ApiResponse(code = 415, message = "Content type not supported.")
    })
public Response list(@Context UriInfo uriInfo, @Context Request request, @HeaderParam("Accept") String accept) {
    return customersProducers.getOrDefault(accept, this::handleUnsupportedContentType).getResponse(uriInfo, request);
}
 
开发者ID:psd2-in-a-box,项目名称:mid-tier,代码行数:27,代码来源:CustomerServiceExposure.java

示例4: getCustomerServiceMetadata

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

示例5: getMetadata

import javax.ws.rs.core.Request; //导入依赖的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 account service should be able to listen for and react to. In other words this is the authoritative" +
                "feed for the account service",
        tags = {"events"},
        produces = "application/hal+json,  application/hal+json;concept=metadata;v=1",
        nickname = "getAccountMetadata"
    )
@ApiResponses(value = {
        @ApiResponse(code = 415, message = "Content type not supported.")
    })
public Response getMetadata(@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,代码来源:AccountEventFeedMetadataServiceExposure.java

示例6: listAll

import javax.ws.rs.core.Request; //导入依赖的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 = "listLocationAllEvents"
    )
@ApiResponses(value = {
        @ApiResponse(code = 415, message = "Content type not supported.")
    })
public Response listAll(@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,代码来源:LocationEventServiceExposure.java

示例7: list

import javax.ws.rs.core.Request; //导入依赖的package包/类
@GET
@Produces({"application/hal+json", "application/hal+json;concept=accountoverview;v=1"})
@ApiOperation(value = "lists accounts", response = AccountsRepresentation.class,
        authorizations = {
                @Authorization(value = "oauth2", scopes = {}),
                @Authorization(value = "oauth2-cc", scopes = {}),
                @Authorization(value = "oauth2-ac", scopes = {}),
                @Authorization(value = "oauth2-rop", scopes = {}),
                @Authorization(value = "Bearer")
        },
        extensions = {@Extension(name = "roles", properties = {
                @ExtensionProperty(name = "advisor", value = "advisors are allowed getting every account"),
                @ExtensionProperty(name = "customer", value = "customer only allowed getting own accounts")}
        )},
        produces = "application/hal+json, application/hal+json;concept=accountoverview;v=1",
        notes = "List all accounts in a default projection, which is AccountOverview version 1" +
                "Supported projections and versions are: " +
                "AccountOverview in version 1 " +
                "The Accept header for the default version is application/hal+json;concept=AccountOverview;v=1.0.0.... " +
                "The format for the default version is {....}", nickname = "listAccounts")
@ApiResponses(value = {
        @ApiResponse(code = 415, message = "Content type not supported.")
    })
public Response list(@Context UriInfo uriInfo, @Context Request request, @QueryParam("customer") @DefaultValue("0") String customer, @HeaderParam("Accept") String accept) {
    return accountsProducers.getOrDefault(accept, this::handleUnsupportedContentType).getResponse(uriInfo, request, customer);
}
 
开发者ID:psd2-in-a-box,项目名称:mid-tier,代码行数:27,代码来源:AccountServiceExposure.java

示例8: testGetEvent

import javax.ws.rs.core.Request; //导入依赖的package包/类
@Test
public void testGetEvent() throws URISyntaxException {
    UriInfo ui = mock(UriInfo.class);
    when(ui.getBaseUriBuilder()).then(new UriBuilderFactory(URI.create("http://mock")));

    Request request = mock(Request.class);

    when(archivist.getEvent("5479-123456","eventSID"))
            .thenReturn(new Event(new URI("accounts/5479-1234567/transactions/txSID")));

    Response response = service.getSingle(ui, request, "application/hal+json", "5479-123456", "eventSID");
    EventRepresentation er = (EventRepresentation) response.getEntity();

    assertEquals("http://mock/accounts/5479-1234567/transactions/txSID", er.getOrigin().getHref());
    assertEquals("default", er.getCategory());
    assertEquals("http://mock/account-events/default/" + er.getId(), er.getSelf().getHref());

    response = service.getSingle(ui, request, "application/hal+json;no-real-type", "5479-123456", "eventSID");
    assertEquals(415,response.getStatus());

}
 
开发者ID:psd2-in-a-box,项目名称:mid-tier,代码行数:22,代码来源:EventServiceExposureTest.java

示例9: cacheAwareResponse

import javax.ws.rs.core.Request; //导入依赖的package包/类
private Response cacheAwareResponse(
    Request request, String entity, EntityTag etag, Date lastModified, int maxAge
) {

  final Response.ResponseBuilder builderLastMod = request.evaluatePreconditions(lastModified);
  if (builderLastMod != null) {
    return builderLastMod.build();
  }

  final Response.ResponseBuilder builderEtag = request.evaluatePreconditions(etag);
  if (builderEtag != null) {
    return builderEtag.build();
  }

  final CacheControl cc = new CacheControl();
  cc.setMaxAge(maxAge);

  return Response.ok(entity)
      .tag(etag)
      .lastModified(lastModified)
      .cacheControl(cc)
      .build();
}
 
开发者ID:dehora,项目名称:outland,代码行数:24,代码来源:OpenApiDiscoveryResource.java

示例10: get

import javax.ws.rs.core.Request; //导入依赖的package包/类
@GET
public Response get(@PathParam("id") String id, @Context Request request,
                    @HeaderParam("Range") Optional<String> range,
                    @HeaderParam("If-Range") Optional<String> ifRange) {

  Optional<File> video = videosRepository.findById(id);
  if (!video.isPresent()) return Response.status(NOT_FOUND).build();

  Optional<Response> notModifiedResponse = evaluateRequestPreconditions(video.get(), request);
  if (notModifiedResponse.isPresent()) return notModifiedResponse.get();

  if (range.isPresent() && (!ifRange.isPresent() || ifRangePreconditionMatches(video.get(), ifRange.get())))
    return videoPartResponse(video.get(), range.get());

  return fullVideoResponse(video.get());
}
 
开发者ID:andreschaffer,项目名称:http-progressive-download-examples,代码行数:17,代码来源:VideoResource.java

示例11: query

import javax.ws.rs.core.Request; //导入依赖的package包/类
/**
 * Query via GET.
 *
 * @see <a href="http://www.w3.org/TR/sparql11-protocol/#query-operation">
 * SPARQL 1.1 Protocol
 * </a>
 * @param req JAX-RS {@link Request} object
 * @param uriInfo JAX-RS {@link UriInfo} object
 * @param queryString the "query" query parameter
 * @param defgraphs the "default-graph-uri" query parameter
 * @param namedgraphs the "named-graph-uri" query parameter
 * @param inference the "inference" query parameter
 * @return the result of the SPARQL query
 */
@GET
@Produces({
	RDFMediaType.SPARQL_RESULTS_JSON,
	RDFMediaType.SPARQL_RESULTS_XML,
	RDFMediaType.SPARQL_RESULTS_CSV,
	RDFMediaType.SPARQL_RESULTS_TSV,
	RDFMediaType.RDF_TURTLE,
	RDFMediaType.RDF_YARS,
	RDFMediaType.RDF_NTRIPLES,
	RDFMediaType.RDF_XML,
	RDFMediaType.RDF_JSON
})
public Response query(
		@Context Request req,
		@Context UriInfo uriInfo,
		@QueryParam("query") String queryString,
		@QueryParam("default-graph-uri") List<String> defgraphs,
		@QueryParam("named-graph-uri") List<String> namedgraphs,
		@QueryParam("inference") String inference) {
	return handleQuery(
			req, uriInfo, queryString, defgraphs, namedgraphs, inference);
}
 
开发者ID:lszeremeta,项目名称:neo4j-sparql-extension-yars,代码行数:37,代码来源:SPARQLQuery.java

示例12: testList

import javax.ws.rs.core.Request; //导入依赖的package包/类
@Test
public void testList() {
    Request request = mock(Request.class);

    UriInfo ui = mock(UriInfo.class);
    when(ui.getBaseUriBuilder()).then(new UriBuilderFactory(URI.create("http://mock")));

    when(archivist.listAccounts("0"))
        .thenReturn(Arrays.asList(new Account("5479", "1", "Checking account", "cust-1"),
                new Account("5479", "2", "Savings account", "cust-1")));

    Response response = service.list(ui, request, "0", "application/hal+json");
    AccountsRepresentation accounts = (AccountsRepresentation) response.getEntity();

    assertEquals(2, accounts.getAccounts().size());
    assertEquals("http://mock/accounts", accounts.getSelf().getHref());

    response = service.list(ui, request, "0", "application/hal+json;concept=non.existing;type");
    assertEquals(415,response.getStatus());

}
 
开发者ID:psd2-in-a-box,项目名称:mid-tier,代码行数:22,代码来源:AccountServiceExposureTest.java

示例13: getServiceGeneration1Version1

import javax.ws.rs.core.Request; //导入依赖的package包/类
@LogDuration(limit = 50)
Response getServiceGeneration1Version1(UriInfo uriInfo, Request request, String accountNo) {
    Long no;
    try {
        no = Long.parseLong(accountNo);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.Status.BAD_REQUEST);
    }
    VirtualAccount virtualaccount = archivist.getAccount(no);
    LOGGER.info("Usage - application/hal+json;concept=virtualaccount;v=1");
    return new EntityResponseBuilder<>(virtualaccount, ac -> new VirtualAccountRepresentation(ac, uriInfo))
            .name("virtualaccount")
            .version("1")
            .maxAge(120)
            .build(request);
}
 
开发者ID:psd2-in-a-box,项目名称:mid-tier,代码行数:17,代码来源:VirtualAccountServiceExposure.java

示例14: testCreate

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

    VirtualAccountUpdateRepresentation account = mock(VirtualAccountUpdateRepresentation.class);
    when(account.getVaNumber()).thenReturn("34");
    when(account.getTotalBalance()).thenReturn("9890");
    when(account.getCommittedBalance()).thenReturn("5123");
    when(account.getUnCommittedBalance()).thenReturn("4767");

    when(archivist.findAccountByAccountNumber(34L)).thenReturn(Optional.empty());

    VirtualAccountRepresentation resp = (VirtualAccountRepresentation) service.createOrUpdate(ui, request,
            "34", account).getEntity();
    assertEquals("34", resp.getVaNumber());
    assertEquals("9890", account.getTotalBalance());
    assertEquals("5123", account.getCommittedBalance());
    assertEquals("4767", account.getUnCommittedBalance());
    assertEquals("http://mock/virtualaccounts/" + resp.getVaNumber(), resp.getSelf().getHref());
}
 
开发者ID:psd2-in-a-box,项目名称:mid-tier,代码行数:24,代码来源:VirtualAccountServiceExposureTest.java

示例15: testUpdate

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

    VirtualAccount account = new VirtualAccount(1L, new BigDecimal(10), new BigDecimal(20), new BigDecimal(30));

    VirtualAccountUpdateRepresentation accountlocationUpdate = mock(VirtualAccountUpdateRepresentation.class);
    when(accountlocationUpdate.getVaNumber()).thenReturn("55");
    when(accountlocationUpdate.getUnCommittedBalance()).thenReturn("5555");

    when(archivist.findAccountByAccountNumber(55L)).thenReturn(Optional.of(account));

    VirtualAccountRepresentation resp = ( VirtualAccountRepresentation) service.createOrUpdate(ui, request,
            "55", accountlocationUpdate).getEntity();

    assertEquals(account.getVaNumber().toString(), resp.getVaNumber());
    assertEquals(account.getTotalBalance().toString(), resp.getTotalBalance());
    assertEquals(account.getComittedBalance().toString(), resp.getCommittedBalance());
    assertEquals(account.getUnCommittedBalance().toString(), resp.getUncommittedBalance());

    assertEquals("http://mock/virtualaccounts/" + resp.getVaNumber(), resp.getSelf().getHref());
}
 
开发者ID:psd2-in-a-box,项目名称:mid-tier,代码行数:26,代码来源:VirtualAccountServiceExposureTest.java


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