/** * Generates a valid document ID for a api referenced by a contract, used to * retrieve the api from ES. * @param contract */ protected String getApiId(Contract contract) { return getApiId(contract.getApiOrgId(), contract.getApiId(), contract.getApiVersion()); }
/** * Generates a valid document ID for a api referenced by a contract, used to * retrieve the api from ES. * @param contract */ private String getApiId(Contract contract) { return getApiId(contract.getApiOrgId(), contract.getApiId(), contract.getApiVersion()); }
/** * Generates a valid document ID for a api referenced by a contract, used to * retrieve the api from ES. * @param contract */ protected String getApiId(Contract contract) { return getApiId(contract.getApiOrgId(), contract.getApiId(), contract.getApiVersion()); }
/** * Generates a valid document ID for a api referenced by a contract, used to * retrieve the api from ES. * @param contract */ private String getApiId(Contract contract) { return getApiId(contract.getApiOrgId(), contract.getApiId(), contract.getApiVersion()); }
/** * @see io.apiman.gateway.engine.IRegistry#registerClient(io.apiman.gateway.engine.beans.Client, io.apiman.gateway.engine.async.IAsyncResultHandler) */ @Override public void registerClient(Client client, IAsyncResultHandler<Void> handler) { Exception error = null; synchronized (mutex) { // Validate the client first - we need to be able to resolve all the contracts. for (Contract contract : client.getContracts()) { String apiIdx = getApiIndex(contract.getApiOrgId(), contract.getApiId(), contract.getApiVersion()); if (!getMap().containsKey(apiIdx)) { error = new ApiNotFoundException(Messages.i18n.format("InMemoryRegistry.ApiNotFoundInOrg", //$NON-NLS-1$ contract.getApiId(), contract.getApiOrgId())); break; } } if (error == null) { // Unregister the client (if it exists) unregisterClientInternal(client, true); // Now, register the client. String clientIdx = getClientIndex(client); getMap().put(clientIdx, client); getMap().put(client.getApiKey(), client); handler.handle(AsyncResultImpl.create((Void) null)); } else { handler.handle(AsyncResultImpl.create(error, Void.class)); } } }
/** * @see io.apiman.gateway.engine.IRegistry#registerClient(io.apiman.gateway.engine.beans.Client, io.apiman.gateway.engine.async.IAsyncResultHandler) */ @Override public void registerClient(Client client, IAsyncResultHandler<Void> handler) { Exception error = null; synchronized (mutex) { // Validate the client first - we need to be able to resolve all the contracts. for (Contract contract : client.getContracts()) { String apiIdx = getApiIndex(contract.getApiOrgId(), contract.getApiId(), contract.getApiVersion()); if (!getMap().containsKey(apiIdx)) { error = new ApiNotFoundException(Messages.i18n.format("InMemoryRegistry.ApiNotFoundInOrg", //$NON-NLS-1$ contract.getApiId(), contract.getApiOrgId())); break; } } if (error == null) { // Unregister the client (if it exists) unregisterClientInternal(client, true); // Now, register the client. String clientIdx = getClientIndex(client); getMap().put(clientIdx, client); getMap().put(client.getApiKey(), client); handler.handle(AsyncResultImpl.create((Void) null)); } else { handler.handle(AsyncResultImpl.create(error, Void.class)); } } }
/** * Ensures that the api referenced by the Contract actually exists (is published). * @param contract * @param connection * @throws RegistrationException */ private void validateContract(final Contract contract, Connection connection) throws RegistrationException { QueryRunner run = new QueryRunner(); try { Api api = run.query(connection, "SELECT bean FROM gw_apis WHERE org_id = ? AND id = ? AND version = ?", //$NON-NLS-1$ Handlers.API_HANDLER, contract.getApiOrgId(), contract.getApiId(), contract.getApiVersion()); if (api == null) { String apiId = contract.getApiId(); String orgId = contract.getApiOrgId(); throw new ApiNotFoundException(Messages.i18n.format("JdbcRegistry.ApiNotFoundInOrg", apiId, orgId)); //$NON-NLS-1$ } } catch (SQLException e) { throw new RegistrationException(Messages.i18n.format("JdbcRegistry.ErrorValidatingApp"), e); //$NON-NLS-1$ } }
Future future = Future.future(); futures.add(future); String apiIndex = getApiIndex(contract.getApiOrgId(), contract.getApiId(), contract.getApiVersion()); objectMap.get(apiIndex, future.completer());
/** * Ensures that the api referenced by the Contract actually exists (is published). * @param contract * @param connection * @throws RegistrationException */ private void validateContract(final Contract contract, Connection connection) throws RegistrationException { QueryRunner run = new QueryRunner(); try { Api api = run.query(connection, "SELECT bean FROM gw_apis WHERE org_id = ? AND id = ? AND version = ?", //$NON-NLS-1$ Handlers.API_HANDLER, contract.getApiOrgId(), contract.getApiId(), contract.getApiVersion()); if (api == null) { String apiId = contract.getApiId(); String orgId = contract.getApiOrgId(); throw new ApiNotFoundException(Messages.i18n.format("JdbcRegistry.ApiNotFoundInOrg", apiId, orgId)); //$NON-NLS-1$ } } catch (SQLException e) { throw new RegistrationException(Messages.i18n.format("JdbcRegistry.ErrorValidatingApp"), e); //$NON-NLS-1$ } }
Future future = Future.future(); futures.add(future); String apiIndex = getApiIndex(contract.getApiOrgId(), contract.getApiId(), contract.getApiVersion()); objectMap.get(apiIndex, future.completer());
ApiVersionBean svb = storage.getApiVersion(contract.getApiOrgId(), contract.getApiId(), contract.getApiVersion()); Set<ApiGatewayBean> gateways = svb.getGateways(); if (gateways == null) {
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) {
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) {