Search in sources :

Example 66 with UriInfo

use of javax.ws.rs.core.UriInfo in project ORCID-Source by ORCID.

the class T1OrcidApiServiceImplLatestMetricsTest method testSearchByQueryJSONResultsReturned.

@Test
public void testSearchByQueryJSONResultsReturned() {
    UriInfo uriInfo = mock(UriInfo.class);
    t1OrcidApiService.setUriInfo(uriInfo);
    MultivaluedMap<String, String> queryMaps = queryParams();
    when(uriInfo.getQueryParameters()).thenReturn(queryMaps);
    when(mockServiceDelegator.publicSearchByQuery(queryMaps)).thenReturn(orcidWithMultipleResults());
    Response response = t1OrcidApiService.searchByQueryJSON("orcid");
    assertEquals(200, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 67 with UriInfo

use of javax.ws.rs.core.UriInfo in project ORCID-Source by ORCID.

the class T1OrcidApiServiceImplLatestMetricsTest method testSearchByQueryXML.

@Test
public void testSearchByQueryXML() {
    UriInfo uriInfo = mock(UriInfo.class);
    t1OrcidApiService.setUriInfo(uriInfo);
    MultivaluedMap<String, String> queryMaps = queryParams();
    when(uriInfo.getQueryParameters()).thenReturn(queryMaps);
    when(mockServiceDelegator.publicSearchByQuery(queryMaps)).thenReturn(successResponse);
    Response response = t1OrcidApiService.searchByQueryXML("orcid");
    assertEquals(200, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 68 with UriInfo

use of javax.ws.rs.core.UriInfo in project ORCID-Source by ORCID.

the class T1OrcidApiServiceImplLatestMetricsTest method testSearchByQueryJSON.

@Test
public void testSearchByQueryJSON() {
    UriInfo uriInfo = mock(UriInfo.class);
    t1OrcidApiService.setUriInfo(uriInfo);
    MultivaluedMap<String, String> queryMaps = queryParams();
    when(uriInfo.getQueryParameters()).thenReturn(queryMaps);
    when(mockServiceDelegator.publicSearchByQuery(queryMaps)).thenReturn(successResponse);
    Response response = t1OrcidApiService.searchByQueryJSON("orcid");
    assertEquals(200, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 69 with UriInfo

use of javax.ws.rs.core.UriInfo in project opennms by OpenNMS.

the class StatusRestService method getBusinessServices.

@GET
@Path("/business-services")
public Response getBusinessServices(@Context final UriInfo uriInfo) {
    final QueryParameters queryParameters = QueryParametersBuilder.buildFrom(uriInfo);
    final SeverityFilter severityFilter = getSeverityFilter(uriInfo);
    final Query query = new Query(queryParameters, severityFilter);
    final List<StatusEntity<BusinessService>> services = businessServiceStatusService.getStatus(query);
    final int totalCount = businessServiceStatusService.count(query);
    final int offset = queryParameters.getOffset();
    final List<BusinessServiceDTO> statusEntities = services.stream().map(bs -> {
        BusinessServiceDTO statusDTO = new BusinessServiceDTO();
        statusDTO.setId(bs.getEntity().getId().intValue());
        statusDTO.setName(bs.getEntity().getName());
        statusDTO.setSeverity(bs.getStatus());
        return statusDTO;
    }).collect(Collectors.toList());
    final BusinessServiceDTOList list = new BusinessServiceDTOList(statusEntities);
    list.setOffset(queryParameters.getOffset());
    list.setTotalCount(totalCount);
    return createResponse(list, offset, totalCount);
}
Also used : Arrays(java.util.Arrays) PathParam(javax.ws.rs.PathParam) QueryParameters(org.opennms.web.utils.QueryParameters) NodeStatusCalculationStrategy(org.opennms.features.status.api.node.strategy.NodeStatusCalculationStrategy) Produces(javax.ws.rs.Produces) BusinessServiceDTO(org.opennms.web.rest.v2.status.model.BusinessServiceDTO) GET(javax.ws.rs.GET) NodeDTO(org.opennms.web.rest.v2.status.model.NodeDTO) Path(javax.ws.rs.Path) Autowired(org.springframework.beans.factory.annotation.Autowired) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) JaxbListWrapper(org.opennms.core.config.api.JaxbListWrapper) ApplicationStatusService(org.opennms.features.status.api.application.ApplicationStatusService) Strings(com.google.common.base.Strings) MediaType(javax.ws.rs.core.MediaType) StatusSummary(org.opennms.features.status.api.StatusSummary) BusinessServiceStatusService(org.opennms.features.status.api.bsm.BusinessServiceStatusService) Map(java.util.Map) NodeQuery(org.opennms.features.status.api.node.NodeQuery) QueryParametersBuilder(org.opennms.web.utils.QueryParametersBuilder) OnmsNode(org.opennms.netmgt.model.OnmsNode) ApplicationDTO(org.opennms.web.rest.v2.status.model.ApplicationDTO) SeverityFilter(org.opennms.features.status.api.SeverityFilter) Context(javax.ws.rs.core.Context) NodeDTOList(org.opennms.web.rest.v2.status.model.NodeDTOList) Query(org.opennms.features.status.api.Query) NodeStatusService(org.opennms.features.status.api.node.NodeStatusService) Collectors(java.util.stream.Collectors) StatusEntity(org.opennms.features.status.api.StatusEntity) List(java.util.List) Component(org.springframework.stereotype.Component) Response(javax.ws.rs.core.Response) BusinessServiceDTOList(org.opennms.web.rest.v2.status.model.BusinessServiceDTOList) OnmsApplication(org.opennms.netmgt.model.OnmsApplication) ApplicationDTOList(org.opennms.web.rest.v2.status.model.ApplicationDTOList) UriInfo(javax.ws.rs.core.UriInfo) Comparator(java.util.Comparator) OnmsSeverity(org.opennms.netmgt.model.OnmsSeverity) SeverityFilter(org.opennms.features.status.api.SeverityFilter) NodeQuery(org.opennms.features.status.api.node.NodeQuery) Query(org.opennms.features.status.api.Query) BusinessServiceDTOList(org.opennms.web.rest.v2.status.model.BusinessServiceDTOList) BusinessServiceDTO(org.opennms.web.rest.v2.status.model.BusinessServiceDTO) QueryParameters(org.opennms.web.utils.QueryParameters) StatusEntity(org.opennms.features.status.api.StatusEntity) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 70 with UriInfo

use of javax.ws.rs.core.UriInfo in project jersey by jersey.

the class JsonWithPaddingInterceptor method getCallbackName.

/**
     * Returns a JavaScript callback name to wrap the JSON entity into. The callback name is determined from the {@link JSONP}
     * annotation.
     *
     * @param jsonp {@link JSONP} annotation to determine the callback name from.
     * @return a JavaScript callback name.
     */
private String getCallbackName(final JSONP jsonp) {
    String callback = jsonp.callback();
    if (!"".equals(jsonp.queryParam())) {
        final ContainerRequest containerRequest = containerRequestProvider.get();
        final UriInfo uriInfo = containerRequest.getUriInfo();
        final MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters();
        final List<String> queryParameter = queryParameters.get(jsonp.queryParam());
        callback = (queryParameter != null && !queryParameter.isEmpty()) ? queryParameter.get(0) : callback;
    }
    return callback;
}
Also used : ContainerRequest(org.glassfish.jersey.server.ContainerRequest) UriInfo(javax.ws.rs.core.UriInfo)

Aggregations

UriInfo (javax.ws.rs.core.UriInfo)105 Response (javax.ws.rs.core.Response)50 Test (org.junit.Test)49 URI (java.net.URI)32 Test (org.testng.annotations.Test)21 Map (java.util.Map)15 MediaType (javax.ws.rs.core.MediaType)15 HttpServletRequest (javax.servlet.http.HttpServletRequest)12 GET (javax.ws.rs.GET)12 Path (javax.ws.rs.Path)12 Context (javax.ws.rs.core.Context)12 Request (org.apache.atlas.catalog.Request)12 ResourceProvider (org.apache.atlas.catalog.ResourceProvider)12 TaxonomyResourceProvider (org.apache.atlas.catalog.TaxonomyResourceProvider)12 MetadataService (org.apache.atlas.services.MetadataService)12 AtlasTypeDefStore (org.apache.atlas.store.AtlasTypeDefStore)12 PathParam (javax.ws.rs.PathParam)11 ArrayList (java.util.ArrayList)10 Api (io.swagger.annotations.Api)8 ApiOperation (io.swagger.annotations.ApiOperation)8