private void registerClients() throws StorageException {
        logger.info(Messages.i18n.format("StorageExporter.RegisteringClients")); //$NON-NLS-1$

        for (EntityInfo info : clientsToRegister) {
            logger.info(Messages.i18n.format("StorageExporter.RegisteringClient", info)); //$NON-NLS-1$
            ClientVersionBean versionBean = storage.getClientVersion(info.organizationId, info.id, info.version);
            Iterator<ContractBean> contractBeans = storage.getAllContracts(info.organizationId, info.id, info.version);

            Client client = new Client();
            client.setOrganizationId(versionBean.getClient().getOrganization().getId());
            client.setClientId(versionBean.getClient().getId());
            client.setVersion(versionBean.getVersion());
            client.setApiKey(versionBean.getApikey());

            Set<Contract> contracts = new HashSet<>();
            while (contractBeans.hasNext()) {
                ContractBean contractBean = contractBeans.next();
                EntityInfo apiInfo = new EntityInfo(
                        contractBean.getApi().getApi().getOrganization().getId(),
                        contractBean.getApi().getApi().getId(),
                        contractBean.getApi().getVersion());
                if (apisToPublish.contains(apiInfo)) {
                    Contract contract = new Contract();
                    contract.setPlan(contractBean.getPlan().getPlan().getId());
                    contract.setApiId(contractBean.getApi().getApi().getId());
                    contract.setApiOrgId(contractBean.getApi().getApi().getOrganization().getId());
                    contract.setApiVersion(contractBean.getApi().getVersion());
                    contract.getPolicies().addAll(aggregateContractPolicies(contractBean, info));
                    contracts.add(contract);
                }
            }
            client.setContracts(contracts);

            // Next, register the client with *all* relevant gateways.  This is done by
            // looking up all referenced apis and getting the gateway information for them.
            // Each of those gateways must be told about the client.
            Map<String, IGatewayLink> links = new HashMap<>();
            for (Contract contract : client.getContracts()) {
                ApiVersionBean svb = storage.getApiVersion(contract.getApiOrgId(), contract.getApiId(), contract.getApiVersion());
                Set<ApiGatewayBean> gateways = svb.getGateways();
                if (gateways == null) {
                    throw new PublishingException("No gateways specified for api: " + svb.getApi().getName()); //$NON-NLS-1$
                }
                for (ApiGatewayBean apiGatewayBean : gateways) {
                    String gatewayId = apiGatewayBean.getGatewayId();
                    if (!links.containsKey(gatewayId)) {
                        IGatewayLink gatewayLink = createGatewayLink(gatewayId);
                        links.put(gatewayId, gatewayLink);
                    }
                }
            }
            for (IGatewayLink gatewayLink : links.values()) {
                try {
                    gatewayLink.registerClient(client);
                } catch (Exception e) {
                    throw new StorageException(e);
                }
            }
        }
    }
private void registerClients ( ) throws StorageException { logger . info ( Messages . i18n . format ( "StorageExporter.RegisteringClients" ) ) ; for ( EntityInfo info : clientsToRegister ) { logger . info ( Messages . i18n . format ( "StorageExporter.RegisteringClient" , info ) ) ; ClientVersionBean versionBean = storage . getClientVersion ( info . organizationId , info . id , info . version ) ; Iterator < ContractBean > contractBeans = storage . getAllContracts ( info . organizationId , info . id , info . version ) ; Client client = new Client ( ) ; client . setOrganizationId ( versionBean . getClient ( ) . getOrganization ( ) . getId ( ) ) ; client . setClientId ( versionBean . getClient ( ) . getId ( ) ) ; client . setVersion ( versionBean . getVersion ( ) ) ; client . setApiKey ( versionBean . getApikey ( ) ) ; Set < Contract > contracts = new HashSet < > ( ) ; while ( contractBeans . hasNext ( ) ) { ContractBean contractBean = contractBeans . next ( ) ; EntityInfo apiInfo = new EntityInfo ( contractBean . getApi ( ) . getApi ( ) . getOrganization ( ) . getId ( ) , contractBean . getApi ( ) . getApi ( ) . getId ( ) , contractBean . getApi ( ) . getVersion ( ) ) ; if ( apisToPublish . contains ( apiInfo ) ) { Contract contract = new Contract ( ) ; contract . setPlan ( contractBean . getPlan ( ) . getPlan ( ) . getId ( ) ) ; contract . setApiId ( contractBean . getApi ( ) . getApi ( ) . getId ( ) ) ; contract . setApiOrgId ( contractBean . getApi ( ) . getApi ( ) . getOrganization ( ) . getId ( ) ) ; contract . setApiVersion ( contractBean . getApi ( ) . getVersion ( ) ) ; contract . getPolicies ( ) . addAll ( aggregateContractPolicies ( contractBean , info ) ) ; contracts . add ( contract ) ; } } client . setContracts ( contracts ) ; Map < String , IGatewayLink > links = new HashMap < > ( ) ; for ( Contract contract : client . getContracts ( ) ) { ApiVersionBean svb = storage . getApiVersion ( contract . getApiOrgId ( ) , contract . getApiId ( ) , contract . getApiVersion ( ) ) ; Set < ApiGatewayBean > gateways = svb . getGateways ( ) ; if ( gateways == null ) { throw new PublishingException ( "No gateways specified for api: " + svb . getApi ( ) . getName ( ) ) ; } for ( ApiGatewayBean apiGatewayBean : gateways ) { String gatewayId = apiGatewayBean . getGatewayId ( ) ; if ( ! links . containsKey ( gatewayId ) ) { IGatewayLink gatewayLink = createGatewayLink ( gatewayId ) ; links . put ( gatewayId , gatewayLink ) ; } } } for ( IGatewayLink gatewayLink : links . values ( ) ) { try { gatewayLink . registerClient ( client ) ; } catch ( Exception e ) { throw new StorageException ( e ) ; } } } }
Registers any clients that were imported in the "Registered" state.
@throws StorageException