Search in sources :

Example 1 with UpdateGatewayBean

use of io.apiman.manager.api.beans.gateways.UpdateGatewayBean 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)

Aggregations

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 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 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 Date (java.util.Date)1