@Override
    public GatewayBean create(NewGatewayBean gatewayToInsert) throws GatewayAlreadyExistsException {
        securityContext.checkAdminPermissions();

        Date now = new Date();

        GatewayBean gateway = new GatewayBean();
        gateway.setId(BeanUtils.idFromName(gatewayToInsert.getName()));
        gateway.setName(gatewayToInsert.getName());
        gateway.setDescription(gatewayToInsert.getDescription());
        gateway.setType(gatewayToInsert.getType());
        gateway.setConfiguration(gatewayToInsert.getConfiguration());
        gateway.setCreatedBy(securityContext.getCurrentUser());
        gateway.setCreatedOn(now);
        gateway.setModifiedBy(securityContext.getCurrentUser());
        gateway.setModifiedOn(now);
        try {
            if (storage.getGateway(gateway.getId()) != null) {
                throw ExceptionFactory.gatewayAlreadyExistsException(gateway.getName());
            }
            // Store/persist the new gateway
            encryptPasswords(gateway);
            storage.createGateway(gateway);
        } catch (AbstractRestException e) {
            throw e;
        } catch (Exception e) {
            throw new SystemErrorException(e);
        }
        decryptPasswords(gateway);

        LOGGER.debug(String.format("Successfully created new gateway %s: %s", gateway.getName(), gateway)); //$NON-NLS-1$
        return gateway;
    }
@see IGatewayResource#create(io.apiman.manager.api.beans.gateways.NewGatewayBean)
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/GatewayResourceImpl.java