Search in sources :

Example 1 with GatewayNotFoundException

use of io.apiman.manager.api.rest.exceptions.GatewayNotFoundException in project apiman by apiman.

the class GatewayResourceImpl method get.

/**
 * @see IGatewayResource#get(java.lang.String)
 */
@Override
public GatewayBean get(String gatewayId) throws GatewayNotFoundException, NotAuthorizedException {
    securityContext.checkAdminPermissions();
    try {
        GatewayBean gateway = storage.getGateway(gatewayId);
        if (gateway == null) {
            throw ExceptionFactory.gatewayNotFoundException(gatewayId);
        }
        decryptPasswords(gateway);
        // $NON-NLS-1$
        LOGGER.debug(String.format("Successfully fetched gateway %s: %s", gateway.getName(), gateway));
        return gateway;
    } catch (AbstractRestException e) {
        throw e;
    } catch (Exception e) {
        throw new SystemErrorException(e);
    }
}
Also used : SystemErrorException(io.apiman.manager.api.rest.exceptions.SystemErrorException) NewGatewayBean(io.apiman.manager.api.beans.gateways.NewGatewayBean) GatewayBean(io.apiman.manager.api.beans.gateways.GatewayBean) UpdateGatewayBean(io.apiman.manager.api.beans.gateways.UpdateGatewayBean) AbstractRestException(io.apiman.manager.api.rest.exceptions.AbstractRestException) 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 2 with GatewayNotFoundException

use of io.apiman.manager.api.rest.exceptions.GatewayNotFoundException 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 3 with GatewayNotFoundException

use of io.apiman.manager.api.rest.exceptions.GatewayNotFoundException 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 GatewayNotFoundException

use of io.apiman.manager.api.rest.exceptions.GatewayNotFoundException in project apiman by apiman.

the class GatewayResourceImpl method update.

/**
 * @see IGatewayResource#update(java.lang.String, io.apiman.manager.api.beans.gateways.UpdateGatewayBean)
 */
@Override
public void update(String gatewayId, UpdateGatewayBean gatewayToUpdate) throws GatewayNotFoundException, NotAuthorizedException {
    securityContext.checkAdminPermissions();
    try {
        Date now = new Date();
        GatewayBean gateway = storage.getGateway(gatewayId);
        if (gateway == null) {
            throw ExceptionFactory.gatewayNotFoundException(gatewayId);
        }
        gateway.setModifiedBy(securityContext.getCurrentUser());
        gateway.setModifiedOn(now);
        if (gatewayToUpdate.getDescription() != null)
            gateway.setDescription(gatewayToUpdate.getDescription());
        if (gatewayToUpdate.getType() != null)
            gateway.setType(gatewayToUpdate.getType());
        if (gatewayToUpdate.getConfiguration() != null)
            gateway.setConfiguration(gatewayToUpdate.getConfiguration());
        encryptPasswords(gateway);
        storage.updateGateway(gateway);
        // $NON-NLS-1$
        LOGGER.debug(String.format("Successfully updated gateway %s: %s", gateway.getName(), gateway));
    } catch (AbstractRestException e) {
        throw e;
    } catch (Exception e) {
        throw new SystemErrorException(e);
    }
}
Also used : SystemErrorException(io.apiman.manager.api.rest.exceptions.SystemErrorException) NewGatewayBean(io.apiman.manager.api.beans.gateways.NewGatewayBean) GatewayBean(io.apiman.manager.api.beans.gateways.GatewayBean) UpdateGatewayBean(io.apiman.manager.api.beans.gateways.UpdateGatewayBean) AbstractRestException(io.apiman.manager.api.rest.exceptions.AbstractRestException) Date(java.util.Date) 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 5 with GatewayNotFoundException

use of io.apiman.manager.api.rest.exceptions.GatewayNotFoundException in project apiman by apiman.

the class GatewayResourceImpl method delete.

/**
 * @see IGatewayResource#delete(java.lang.String)
 */
@Override
public void delete(String gatewayId) throws GatewayNotFoundException, NotAuthorizedException {
    securityContext.checkAdminPermissions();
    try {
        GatewayBean gateway = storage.getGateway(gatewayId);
        if (gateway == null) {
            throw ExceptionFactory.gatewayNotFoundException(gatewayId);
        }
        storage.deleteGateway(gateway);
        // $NON-NLS-1$
        LOGGER.debug(String.format("Successfully deleted gateway %s: %s", gateway.getName(), gateway));
    } catch (AbstractRestException e) {
        throw e;
    } catch (Exception e) {
        throw new SystemErrorException(e);
    }
}
Also used : SystemErrorException(io.apiman.manager.api.rest.exceptions.SystemErrorException) NewGatewayBean(io.apiman.manager.api.beans.gateways.NewGatewayBean) GatewayBean(io.apiman.manager.api.beans.gateways.GatewayBean) UpdateGatewayBean(io.apiman.manager.api.beans.gateways.UpdateGatewayBean) AbstractRestException(io.apiman.manager.api.rest.exceptions.AbstractRestException) 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)

Aggregations

GatewayBean (io.apiman.manager.api.beans.gateways.GatewayBean)7 GatewayNotFoundException (io.apiman.manager.api.rest.exceptions.GatewayNotFoundException)7 SystemErrorException (io.apiman.manager.api.rest.exceptions.SystemErrorException)6 StorageException (io.apiman.manager.api.core.exceptions.StorageException)5 NotAuthorizedException (io.apiman.manager.api.rest.exceptions.NotAuthorizedException)5 NewGatewayBean (io.apiman.manager.api.beans.gateways.NewGatewayBean)4 UpdateGatewayBean (io.apiman.manager.api.beans.gateways.UpdateGatewayBean)4 GatewayAuthenticationException (io.apiman.manager.api.gateway.GatewayAuthenticationException)4 IGatewayLink (io.apiman.manager.api.gateway.IGatewayLink)4 AbstractRestException (io.apiman.manager.api.rest.exceptions.AbstractRestException)4 GatewayAlreadyExistsException (io.apiman.manager.api.rest.exceptions.GatewayAlreadyExistsException)4 ApiGatewayBean (io.apiman.manager.api.beans.apis.ApiGatewayBean)3 ApiEndpoint (io.apiman.gateway.engine.beans.ApiEndpoint)2 ApiVersionEndpointSummaryBean (io.apiman.manager.api.beans.summary.ApiVersionEndpointSummaryBean)2 GatewayEndpoint (io.apiman.gateway.engine.beans.GatewayEndpoint)1 PublishingException (io.apiman.gateway.engine.beans.exceptions.PublishingException)1 GatewayEndpointSummaryBean (io.apiman.manager.api.beans.summary.GatewayEndpointSummaryBean)1 ActionException (io.apiman.manager.api.rest.exceptions.ActionException)1 ApiVersionNotFoundException (io.apiman.manager.api.rest.exceptions.ApiVersionNotFoundException)1 ClientVersionNotFoundException (io.apiman.manager.api.rest.exceptions.ClientVersionNotFoundException)1