Search in sources :

Example 1 with ApiVersionEndpointSummaryBean

use of io.apiman.manager.api.beans.summary.ApiVersionEndpointSummaryBean in project apiman by apiman.

the class ApiService method getApiVersionEndpointInfoFromStorage.

private ApiVersionEndpointSummaryBean getApiVersionEndpointInfoFromStorage(ApiVersionBean apiVersion, String organizationId, String apiId, String version) throws GatewayNotFoundException, GatewayAuthenticationException, StorageException {
    Set<ApiGatewayBean> gateways = apiVersion.getGateways();
    if (gateways.isEmpty()) {
        // $NON-NLS-1$
        throw new SystemErrorException("No Gateways for published API!");
    }
    GatewayBean gateway = storage.getGateway(gateways.iterator().next().getGatewayId());
    if (gateway == null) {
        throw new GatewayNotFoundException();
    } else {
        // $NON-NLS-1$
        LOGGER.debug(String.format("Got endpoint summary: %s", gateway));
    }
    IGatewayLink link = gatewayLinkFactory.create(gateway);
    ApiEndpoint endpoint = link.getApiEndpoint(organizationId, apiId, version);
    ApiVersionEndpointSummaryBean rval = new ApiVersionEndpointSummaryBean();
    rval.setManagedEndpoint(endpoint.getEndpoint());
    return rval;
}
Also used : SystemErrorException(io.apiman.manager.api.rest.exceptions.SystemErrorException) ApiVersionEndpointSummaryBean(io.apiman.manager.api.beans.summary.ApiVersionEndpointSummaryBean) ApiGatewayBean(io.apiman.manager.api.beans.apis.ApiGatewayBean) ApiGatewayBean(io.apiman.manager.api.beans.apis.ApiGatewayBean) GatewayBean(io.apiman.manager.api.beans.gateways.GatewayBean) ApiEndpoint(io.apiman.gateway.engine.beans.ApiEndpoint) GatewayNotFoundException(io.apiman.manager.api.rest.exceptions.GatewayNotFoundException) IGatewayLink(io.apiman.manager.api.gateway.IGatewayLink)

Example 2 with ApiVersionEndpointSummaryBean

use of io.apiman.manager.api.beans.summary.ApiVersionEndpointSummaryBean in project apiman by apiman.

the class OrganizationResourceImpl method getApiVersionEndpointInfo.

/**
 * @see IOrganizationResource#getApiVersionEndpointInfo(java.lang.String, java.lang.String, java.lang.String)
 */
@Override
public ApiVersionEndpointSummaryBean getApiVersionEndpointInfo(String organizationId, String apiId, String version) throws ApiVersionNotFoundException, InvalidApiStatusException {
    // No permission check is needed, because this would break All APIs UI
    try {
        storage.beginTx();
        ApiVersionBean apiVersion = getApiVersionFromStorage(organizationId, apiId, version);
        if (apiVersion.getStatus() != ApiStatus.Published) {
            // $NON-NLS-1$
            throw new InvalidApiStatusException(Messages.i18n.format("ApiNotPublished"));
        }
        ApiVersionEndpointSummaryBean rval = getApiVersionEndpointInfoFromStorage(apiVersion, organizationId, apiId, version);
        storage.commitTx();
        return rval;
    } catch (AbstractRestException e) {
        storage.rollbackTx();
        throw e;
    } catch (Exception e) {
        storage.rollbackTx();
        throw new SystemErrorException(e);
    }
}
Also used : SystemErrorException(io.apiman.manager.api.rest.exceptions.SystemErrorException) ApiVersionEndpointSummaryBean(io.apiman.manager.api.beans.summary.ApiVersionEndpointSummaryBean) InvalidApiStatusException(io.apiman.manager.api.rest.exceptions.InvalidApiStatusException) AbstractRestException(io.apiman.manager.api.rest.exceptions.AbstractRestException) ApiVersionBean(io.apiman.manager.api.beans.apis.ApiVersionBean) UpdateApiVersionBean(io.apiman.manager.api.beans.apis.UpdateApiVersionBean) NewApiVersionBean(io.apiman.manager.api.beans.apis.NewApiVersionBean) ClientAlreadyExistsException(io.apiman.manager.api.rest.exceptions.ClientAlreadyExistsException) ApiVersionAlreadyExistsException(io.apiman.manager.api.rest.exceptions.ApiVersionAlreadyExistsException) GatewayNotFoundException(io.apiman.manager.api.rest.exceptions.GatewayNotFoundException) InvalidVersionException(io.apiman.manager.api.rest.exceptions.InvalidVersionException) OrganizationAlreadyExistsException(io.apiman.manager.api.rest.exceptions.OrganizationAlreadyExistsException) EntityStillActiveException(io.apiman.manager.api.rest.exceptions.EntityStillActiveException) PolicyNotFoundException(io.apiman.manager.api.rest.exceptions.PolicyNotFoundException) PlanAlreadyExistsException(io.apiman.manager.api.rest.exceptions.PlanAlreadyExistsException) ApiAlreadyExistsException(io.apiman.manager.api.rest.exceptions.ApiAlreadyExistsException) NotAuthorizedException(io.apiman.manager.api.rest.exceptions.NotAuthorizedException) UserNotFoundException(io.apiman.manager.api.rest.exceptions.UserNotFoundException) GatewayAuthenticationException(io.apiman.manager.api.gateway.GatewayAuthenticationException) AbstractRestException(io.apiman.manager.api.rest.exceptions.AbstractRestException) PlanVersionNotFoundException(io.apiman.manager.api.rest.exceptions.PlanVersionNotFoundException) RoleNotFoundException(io.apiman.manager.api.rest.exceptions.RoleNotFoundException) InvalidNameException(io.apiman.manager.api.rest.exceptions.InvalidNameException) ClientVersionNotFoundException(io.apiman.manager.api.rest.exceptions.ClientVersionNotFoundException) IOException(java.io.IOException) InvalidApiStatusException(io.apiman.manager.api.rest.exceptions.InvalidApiStatusException) ApiNotFoundException(io.apiman.manager.api.rest.exceptions.ApiNotFoundException) ContractAlreadyExistsException(io.apiman.manager.api.rest.exceptions.ContractAlreadyExistsException) InvalidClientStatusException(io.apiman.manager.api.rest.exceptions.InvalidClientStatusException) ApiVersionNotFoundException(io.apiman.manager.api.rest.exceptions.ApiVersionNotFoundException) StorageException(io.apiman.manager.api.core.exceptions.StorageException) ClientVersionAlreadyExistsException(io.apiman.manager.api.rest.exceptions.ClientVersionAlreadyExistsException) InvalidPlanStatusException(io.apiman.manager.api.rest.exceptions.InvalidPlanStatusException) SystemErrorException(io.apiman.manager.api.rest.exceptions.SystemErrorException) ContractNotFoundException(io.apiman.manager.api.rest.exceptions.ContractNotFoundException) InvalidParameterException(io.apiman.manager.api.rest.exceptions.InvalidParameterException) ClientNotFoundException(io.apiman.manager.api.rest.exceptions.ClientNotFoundException) PlanNotFoundException(io.apiman.manager.api.rest.exceptions.PlanNotFoundException) InvalidMetricCriteriaException(io.apiman.manager.api.rest.exceptions.InvalidMetricCriteriaException) MalformedURLException(java.net.MalformedURLException) PlanVersionAlreadyExistsException(io.apiman.manager.api.rest.exceptions.PlanVersionAlreadyExistsException) PolicyDefinitionNotFoundException(io.apiman.manager.api.rest.exceptions.PolicyDefinitionNotFoundException) OrganizationNotFoundException(io.apiman.manager.api.rest.exceptions.OrganizationNotFoundException) ApiDefinitionNotFoundException(io.apiman.manager.api.rest.exceptions.ApiDefinitionNotFoundException)

Example 3 with ApiVersionEndpointSummaryBean

use of io.apiman.manager.api.beans.summary.ApiVersionEndpointSummaryBean in project apiman by apiman.

the class OrganizationResourceImpl method getApiVersionEndpointInfoFromStorage.

private ApiVersionEndpointSummaryBean getApiVersionEndpointInfoFromStorage(ApiVersionBean apiVersion, String organizationId, String apiId, String version) throws GatewayNotFoundException, GatewayAuthenticationException, StorageException {
    Set<ApiGatewayBean> gateways = apiVersion.getGateways();
    if (gateways.isEmpty()) {
        // $NON-NLS-1$
        throw new SystemErrorException("No Gateways for published API!");
    }
    GatewayBean gateway = storage.getGateway(gateways.iterator().next().getGatewayId());
    if (gateway == null) {
        throw new GatewayNotFoundException();
    } else {
        // $NON-NLS-1$
        log.debug(String.format("Got endpoint summary: %s", gateway));
    }
    IGatewayLink link = gatewayLinkFactory.create(gateway);
    ApiEndpoint endpoint = link.getApiEndpoint(organizationId, apiId, version);
    ApiVersionEndpointSummaryBean rval = new ApiVersionEndpointSummaryBean();
    rval.setManagedEndpoint(endpoint.getEndpoint());
    return rval;
}
Also used : SystemErrorException(io.apiman.manager.api.rest.exceptions.SystemErrorException) ApiVersionEndpointSummaryBean(io.apiman.manager.api.beans.summary.ApiVersionEndpointSummaryBean) ApiGatewayBean(io.apiman.manager.api.beans.apis.ApiGatewayBean) ApiGatewayBean(io.apiman.manager.api.beans.apis.ApiGatewayBean) GatewayBean(io.apiman.manager.api.beans.gateways.GatewayBean) ApiEndpoint(io.apiman.gateway.engine.beans.ApiEndpoint) GatewayNotFoundException(io.apiman.manager.api.rest.exceptions.GatewayNotFoundException) IGatewayLink(io.apiman.manager.api.gateway.IGatewayLink)

Aggregations

ApiVersionEndpointSummaryBean (io.apiman.manager.api.beans.summary.ApiVersionEndpointSummaryBean)3 GatewayNotFoundException (io.apiman.manager.api.rest.exceptions.GatewayNotFoundException)3 SystemErrorException (io.apiman.manager.api.rest.exceptions.SystemErrorException)3 ApiEndpoint (io.apiman.gateway.engine.beans.ApiEndpoint)2 ApiGatewayBean (io.apiman.manager.api.beans.apis.ApiGatewayBean)2 GatewayBean (io.apiman.manager.api.beans.gateways.GatewayBean)2 IGatewayLink (io.apiman.manager.api.gateway.IGatewayLink)2 ApiVersionBean (io.apiman.manager.api.beans.apis.ApiVersionBean)1 NewApiVersionBean (io.apiman.manager.api.beans.apis.NewApiVersionBean)1 UpdateApiVersionBean (io.apiman.manager.api.beans.apis.UpdateApiVersionBean)1 StorageException (io.apiman.manager.api.core.exceptions.StorageException)1 GatewayAuthenticationException (io.apiman.manager.api.gateway.GatewayAuthenticationException)1 AbstractRestException (io.apiman.manager.api.rest.exceptions.AbstractRestException)1 ApiAlreadyExistsException (io.apiman.manager.api.rest.exceptions.ApiAlreadyExistsException)1 ApiDefinitionNotFoundException (io.apiman.manager.api.rest.exceptions.ApiDefinitionNotFoundException)1 ApiNotFoundException (io.apiman.manager.api.rest.exceptions.ApiNotFoundException)1 ApiVersionAlreadyExistsException (io.apiman.manager.api.rest.exceptions.ApiVersionAlreadyExistsException)1 ApiVersionNotFoundException (io.apiman.manager.api.rest.exceptions.ApiVersionNotFoundException)1 ClientAlreadyExistsException (io.apiman.manager.api.rest.exceptions.ClientAlreadyExistsException)1 ClientNotFoundException (io.apiman.manager.api.rest.exceptions.ClientNotFoundException)1