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);
}
}
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;
}
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);
}
}
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);
}
}
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);
}
}
Aggregations