Search in sources :

Example 26 with GenericType

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

the class RestClient method getAllMinions.

public List<OnmsMinion> getAllMinions() {
    GenericType<List<OnmsMinion>> minions = new GenericType<List<OnmsMinion>>() {
    };
    final WebTarget target = getTargetV2().path("minions");
    return getBuilder(target).accept(MediaType.APPLICATION_XML).get(minions);
}
Also used : GenericType(javax.ws.rs.core.GenericType) OnmsMinion(org.opennms.netmgt.model.minion.OnmsMinion) List(java.util.List) WebTarget(javax.ws.rs.client.WebTarget)

Example 27 with GenericType

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

the class RestClient method getNodes.

public List<OnmsNode> getNodes() {
    GenericType<List<OnmsNode>> nodes = new GenericType<List<OnmsNode>>() {
    };
    final WebTarget target = getTarget().path("nodes");
    return getBuilder(target).get(nodes);
}
Also used : GenericType(javax.ws.rs.core.GenericType) OnmsNode(org.opennms.netmgt.model.OnmsNode) List(java.util.List) WebTarget(javax.ws.rs.client.WebTarget)

Example 28 with GenericType

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

the class DefaultRemoteRepository method getReports.

/**
 * {@inheritDoc}
 */
@Override
public List<BasicReportDefinition> getReports() {
    List<BasicReportDefinition> resultReports = new ArrayList<>();
    if (isConfigOk()) {
        WebTarget target = getTarget(m_remoteRepositoryDefintion.getURI() + "reports" + "/" + m_jasperReportsVersion);
        List<RemoteReportSDO> webCallResult = new ArrayList<>();
        try {
            webCallResult = getBuilder(target).get(new GenericType<List<RemoteReportSDO>>() {
            });
        } catch (Exception e) {
            logger.error("Error requesting report template from repository. Error message: '{}' Uri was: '{}'", e.getMessage(), target.getUri());
            e.printStackTrace();
        }
        logger.debug("getReports got '{}' RemoteReportSDOs from uri '{}'", webCallResult.size(), target.getUri());
        resultReports = this.mapSDOListToBasicReportList(webCallResult);
    }
    return resultReports;
}
Also used : RemoteReportSDO(org.opennms.features.reporting.sdo.RemoteReportSDO) GenericType(javax.ws.rs.core.GenericType) ArrayList(java.util.ArrayList) WebTarget(javax.ws.rs.client.WebTarget) BasicReportDefinition(org.opennms.features.reporting.model.basicreport.BasicReportDefinition) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 29 with GenericType

use of javax.ws.rs.core.GenericType in project linuxtools by eclipse.

the class AbstractRegistry method retrieveTagsFromRegistryV1.

/**
 * Retrieves the list of tags for a given repository, assuming that the
 * target registry is a registry v2 instance.
 *
 * @param client
 *            the client to use
 * @param repository
 *            the repository to look-up
 * @return the list of tags for the given repository
 * @throws CancellationException
 *             - if the computation was cancelled
 * @throws ExecutionException
 *             - if the computation threw an exception
 * @throws InterruptedException
 *             - if the current thread was interrupted while waiting
 */
private List<IRepositoryTag> retrieveTagsFromRegistryV1(final Client client, final String repository) throws InterruptedException, ExecutionException {
    final GenericType<Map<String, String>> REPOSITORY_TAGS_RESULT_LIST = new GenericType<Map<String, String>>() {
    };
    final WebTarget queryTagsResource = client.target(getHTTPServerAddress()).path(// $NON-NLS-1$
    "v1").path("repositories").path(repository).path(// $NON-NLS-1$ //$NON-NLS-2$
    "tags");
    return queryTagsResource.request(APPLICATION_JSON_TYPE).async().method(GET, REPOSITORY_TAGS_RESULT_LIST).get().entrySet().stream().map(e -> new RepositoryTag(e.getKey(), e.getValue())).collect(Collectors.toList());
}
Also used : GET(javax.ws.rs.HttpMethod.GET) ClientConfig(org.glassfish.jersey.client.ClientConfig) Client(javax.ws.rs.client.Client) TimeoutException(java.util.concurrent.TimeoutException) ArrayList(java.util.ArrayList) RepositoryTag(org.eclipse.linuxtools.internal.docker.core.RepositoryTag) ClientBuilder(javax.ws.rs.client.ClientBuilder) ImageSearchResultV1(org.eclipse.linuxtools.internal.docker.core.ImageSearchResultV1) Map(java.util.Map) Status(javax.ws.rs.core.Response.Status) ObjectMapperProvider(com.spotify.docker.client.ObjectMapperProvider) CancellationException(java.util.concurrent.CancellationException) NLS(org.eclipse.osgi.util.NLS) JacksonFeature(org.glassfish.jersey.jackson.JacksonFeature) Collectors(java.util.stream.Collectors) ImageSearchResultV2(org.eclipse.linuxtools.internal.docker.core.ImageSearchResultV2) BearerTokenResponse(org.eclipse.linuxtools.internal.docker.core.OAuth2Utils.BearerTokenResponse) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) GenericType(javax.ws.rs.core.GenericType) List(java.util.List) ImageSearchResult(com.spotify.docker.client.messages.ImageSearchResult) Response(javax.ws.rs.core.Response) DockerImageSearchResult(org.eclipse.linuxtools.internal.docker.core.DockerImageSearchResult) RepositoryTagV2(org.eclipse.linuxtools.internal.docker.core.RepositoryTagV2) APPLICATION_JSON_TYPE(javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE) WebTarget(javax.ws.rs.client.WebTarget) OAuth2Utils(org.eclipse.linuxtools.internal.docker.core.OAuth2Utils) GenericType(javax.ws.rs.core.GenericType) RepositoryTag(org.eclipse.linuxtools.internal.docker.core.RepositoryTag) WebTarget(javax.ws.rs.client.WebTarget) Map(java.util.Map)

Example 30 with GenericType

use of javax.ws.rs.core.GenericType in project linuxtools by eclipse.

the class AbstractRegistry method retrieveTagsFromRegistryV2.

/**
 * Retrieves the list of tags for a given repository, assuming that the
 * target registry is a registry v1 instance.
 *
 * @param client
 *            the client to use
 * @param repository
 *            the repository to look-up
 * @return the list of tags for the given repository
 * @throws CancellationException
 *             - if the computation was cancelled
 * @throws ExecutionException
 *             - if the computation threw an exception
 * @throws InterruptedException
 *             - if the current thread was interrupted while waiting
 */
private List<IRepositoryTag> retrieveTagsFromRegistryV2(final Client client, final String repository) throws InterruptedException, ExecutionException {
    final GenericType<RepositoryTagV2> REPOSITORY_TAGS_RESULT_LIST = new GenericType<RepositoryTagV2>() {
    };
    final WebTarget queryTagsResource = client.target(getHTTPServerAddress()).path(// $NON-NLS-1$
    "v2").path(repository).path("tags").path(// $NON-NLS-1$ //$NON-NLS-2$
    "list");
    final RepositoryTagV2 crts = queryTagsResource.request(APPLICATION_JSON_TYPE).async().method(GET, REPOSITORY_TAGS_RESULT_LIST).get();
    return crts.getTags();
}
Also used : GenericType(javax.ws.rs.core.GenericType) WebTarget(javax.ws.rs.client.WebTarget) RepositoryTagV2(org.eclipse.linuxtools.internal.docker.core.RepositoryTagV2)

Aggregations

GenericType (javax.ws.rs.core.GenericType)71 WebTarget (javax.ws.rs.client.WebTarget)42 List (java.util.List)35 Test (org.junit.Test)35 Response (javax.ws.rs.core.Response)24 ArrayList (java.util.ArrayList)15 GenericEntity (javax.ws.rs.core.GenericEntity)15 Collection (java.util.Collection)12 WebClient (org.apache.cxf.jaxrs.client.WebClient)9 JerseyTest (org.glassfish.jersey.test.JerseyTest)9 Queue (java.util.Queue)8 GET (javax.ws.rs.GET)7 Produces (javax.ws.rs.Produces)7 MediaType (javax.ws.rs.core.MediaType)7 Type (java.lang.reflect.Type)6 HashSet (java.util.HashSet)6 ExecutionException (java.util.concurrent.ExecutionException)6 Path (javax.ws.rs.Path)6 JAXBElement (javax.xml.bind.JAXBElement)6 Comparator (java.util.Comparator)5