@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);

            LOGGER.debug(String.format("Successfully updated gateway %s: %s", gateway.getName(), gateway)); //$NON-NLS-1$
        } catch (AbstractRestException e) {
            throw e;
        } catch (Exception e) {
            throw new SystemErrorException(e);
        }
    }
@see IGatewayResource#update(java.lang.String, io.apiman.manager.api.beans.gateways.UpdateGatewayBean)
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/GatewayResourceImpl.java