Search in sources :

Example 1 with GatewayEndpoint

use of io.apiman.gateway.engine.beans.GatewayEndpoint in project apiman by apiman.

the class WarPlatform method getEndpoint.

/**
 * @see io.apiman.gateway.api.rest.impl.IPlatform#getEndpoint()
 */
@Override
public GatewayEndpoint getEndpoint() {
    GatewayEndpoint gatewayEndpoint = new GatewayEndpoint();
    gatewayEndpoint.setEndpoint(getGatewayEndpoint().toString());
    return gatewayEndpoint;
}
Also used : GatewayEndpoint(io.apiman.gateway.engine.beans.GatewayEndpoint)

Example 2 with GatewayEndpoint

use of io.apiman.gateway.engine.beans.GatewayEndpoint in project apiman by apiman.

the class GatewayClient method getGatewayEndpoint.

/**
 * @see ISystemResource#getEndpoint()
 */
public GatewayEndpoint getGatewayEndpoint() throws GatewayAuthenticationException {
    InputStream is = null;
    try {
        @SuppressWarnings("nls") URI uri = new URI(this.endpoint + SYSTEM_ENDPOINT);
        HttpGet get = new HttpGet(uri);
        HttpResponse response = httpClient.execute(get);
        int actualStatusCode = response.getStatusLine().getStatusCode();
        if (actualStatusCode == 401 || actualStatusCode == 403) {
            throw new GatewayAuthenticationException();
        }
        if (actualStatusCode != 200) {
            // $NON-NLS-1$
            throw new RuntimeException("Failed to get the API endpoint: " + actualStatusCode);
        }
        is = response.getEntity().getContent();
        return mapper.reader(GatewayEndpoint.class).readValue(is);
    } catch (GatewayAuthenticationException | RuntimeException e) {
        throw e;
    } catch (Exception e) {
        throw new RuntimeException(e);
    } finally {
        IOUtils.closeQuietly(is);
    }
}
Also used : InputStream(java.io.InputStream) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) GatewayEndpoint(io.apiman.gateway.engine.beans.GatewayEndpoint) URI(java.net.URI) ApiEndpoint(io.apiman.gateway.engine.beans.ApiEndpoint) GatewayEndpoint(io.apiman.gateway.engine.beans.GatewayEndpoint) GatewayAuthenticationException(io.apiman.manager.api.gateway.GatewayAuthenticationException) GatewayAuthenticationException(io.apiman.manager.api.gateway.GatewayAuthenticationException) PublishingException(io.apiman.gateway.engine.beans.exceptions.PublishingException) RegistrationException(io.apiman.gateway.engine.beans.exceptions.RegistrationException)

Example 3 with GatewayEndpoint

use of io.apiman.gateway.engine.beans.GatewayEndpoint in project apiman by apiman.

the class GatewayResourceImpl method getGatewayEndpoint.

/**
 * @see IGatewayResource#getGatewayEndpoint(java.lang.String)
 */
public GatewayEndpointSummaryBean getGatewayEndpoint(String gatewayId) throws GatewayNotFoundException {
    // No permission check is needed
    try {
        GatewayBean gateway = storage.getGateway(gatewayId);
        if (gateway == null) {
            throw ExceptionFactory.gatewayNotFoundException(gatewayId);
        } else {
            // $NON-NLS-1$
            LOGGER.debug(String.format("Got endpoint summary: %s", gateway));
        }
        IGatewayLink link = gatewayLinkFactory.create(gateway);
        GatewayEndpoint endpoint = link.getGatewayEndpoint();
        GatewayEndpointSummaryBean gatewayEndpoint = new GatewayEndpointSummaryBean();
        gatewayEndpoint.setEndpoint(endpoint.getEndpoint());
        return gatewayEndpoint;
    } catch (AbstractRestException e) {
        throw e;
    } catch (Exception e) {
        throw new SystemErrorException(e);
    }
}
Also used : SystemErrorException(io.apiman.manager.api.rest.exceptions.SystemErrorException) GatewayEndpointSummaryBean(io.apiman.manager.api.beans.summary.GatewayEndpointSummaryBean) NewGatewayBean(io.apiman.manager.api.beans.gateways.NewGatewayBean) GatewayBean(io.apiman.manager.api.beans.gateways.GatewayBean) UpdateGatewayBean(io.apiman.manager.api.beans.gateways.UpdateGatewayBean) GatewayEndpoint(io.apiman.gateway.engine.beans.GatewayEndpoint) AbstractRestException(io.apiman.manager.api.rest.exceptions.AbstractRestException) IGatewayLink(io.apiman.manager.api.gateway.IGatewayLink) GatewayAuthenticationException(io.apiman.manager.api.gateway.GatewayAuthenticationException) AbstractRestException(io.apiman.manager.api.rest.exceptions.AbstractRestException) StorageException(io.apiman.manager.api.core.exceptions.StorageException) GatewayNotFoundException(io.apiman.manager.api.rest.exceptions.GatewayNotFoundException) SystemErrorException(io.apiman.manager.api.rest.exceptions.SystemErrorException) GatewayAlreadyExistsException(io.apiman.manager.api.rest.exceptions.GatewayAlreadyExistsException) NotAuthorizedException(io.apiman.manager.api.rest.exceptions.NotAuthorizedException)

Example 4 with GatewayEndpoint

use of io.apiman.gateway.engine.beans.GatewayEndpoint in project apiman by apiman.

the class SystemResourceImpl method getEndpoint.

@Override
public GatewayEndpoint getEndpoint() {
    EndpointHelper endpointHelper = new EndpointHelper(apimanConfig);
    String endpoint = endpointHelper.getGatewayEndpoint();
    GatewayEndpoint endpointObj = new GatewayEndpoint();
    endpointObj.setEndpoint(endpoint);
    return endpointObj;
}
Also used : EndpointHelper(io.apiman.gateway.platforms.vertx3.helpers.EndpointHelper) GatewayEndpoint(io.apiman.gateway.engine.beans.GatewayEndpoint)

Example 5 with GatewayEndpoint

use of io.apiman.gateway.engine.beans.GatewayEndpoint in project apiman by apiman.

the class GatewayMicroServicePlatform method getEndpoint.

/**
 * @see io.apiman.gateway.api.rest.impl.IPlatform#getEndpoint()
 */
@Override
public GatewayEndpoint getEndpoint() {
    GatewayEndpoint gatewayEndpoint = new GatewayEndpoint();
    gatewayEndpoint.setEndpoint(getGatewayEndpoint().toString());
    return gatewayEndpoint;
}
Also used : GatewayEndpoint(io.apiman.gateway.engine.beans.GatewayEndpoint)

Aggregations

GatewayEndpoint (io.apiman.gateway.engine.beans.GatewayEndpoint)5 GatewayAuthenticationException (io.apiman.manager.api.gateway.GatewayAuthenticationException)2 ApiEndpoint (io.apiman.gateway.engine.beans.ApiEndpoint)1 PublishingException (io.apiman.gateway.engine.beans.exceptions.PublishingException)1 RegistrationException (io.apiman.gateway.engine.beans.exceptions.RegistrationException)1 EndpointHelper (io.apiman.gateway.platforms.vertx3.helpers.EndpointHelper)1 GatewayBean (io.apiman.manager.api.beans.gateways.GatewayBean)1 NewGatewayBean (io.apiman.manager.api.beans.gateways.NewGatewayBean)1 UpdateGatewayBean (io.apiman.manager.api.beans.gateways.UpdateGatewayBean)1 GatewayEndpointSummaryBean (io.apiman.manager.api.beans.summary.GatewayEndpointSummaryBean)1 StorageException (io.apiman.manager.api.core.exceptions.StorageException)1 IGatewayLink (io.apiman.manager.api.gateway.IGatewayLink)1 AbstractRestException (io.apiman.manager.api.rest.exceptions.AbstractRestException)1 GatewayAlreadyExistsException (io.apiman.manager.api.rest.exceptions.GatewayAlreadyExistsException)1 GatewayNotFoundException (io.apiman.manager.api.rest.exceptions.GatewayNotFoundException)1 NotAuthorizedException (io.apiman.manager.api.rest.exceptions.NotAuthorizedException)1 SystemErrorException (io.apiman.manager.api.rest.exceptions.SystemErrorException)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 HttpResponse (org.apache.http.HttpResponse)1