/** * Generates an in-memory key for an application, used to index the app for later quick * retrieval. * @param app an application * @return an application key */ private String getApplicationKey(Application app) { return app.getOrganizationId() + "|" + app.getApplicationId() + "|" + app.getVersion(); //$NON-NLS-1$ //$NON-NLS-2$ } }
throw new UserException("Query Parse Exception , expecting /rest/apimanager/applications/{organizationId}/{applicationId}/{version}"); Application application = new Application(); application.setOrganizationId(pathSegment[3]); application.setApplicationId(pathSegment[4]); application.setVersion(pathSegment[5]); engine.getRegistry().unregisterApplication(application, voidHandler); } else {
for (Contract contract : application.getContracts()) { String svcKey = getServiceKey(contract.getServiceOrgId(), contract.getServiceId(), contract.getServiceVersion()); ServiceContract sc = new ServiceContract(contract.getApiKey(), services.get(svcKey), application, contract.getPolicies());
/** * @see io.apiman.gateway.engine.IRegistry#unregisterApplication(io.apiman.gateway.engine.beans.Application, io.apiman.gateway.engine.async.IAsyncResultHandler) */ @Override public synchronized void unregisterApplication(Application application, IAsyncResultHandler<Void> handler) { try { String applicationKey = getApplicationKey(application); if (applications.containsKey(applicationKey)) { Application removed = applications.remove(applicationKey); for (Contract contract : removed.getContracts()) { if (contracts.containsKey(contract.getApiKey())) { contracts.remove(contract.getApiKey()); } } } else { throw new RegistrationException(Messages.i18n.format("InMemoryRegistry.AppNotFound")); //$NON-NLS-1$ } save(); handler.handle(AsyncResultImpl.create((Void) null)); } catch (Throwable t) { handler.handle(AsyncResultImpl.create(t, Void.class)); } }
/** * @see io.apiman.manager.api.gateway.IGatewayLink#unregisterApplication(io.apiman.gateway.engine.beans.Application) */ @Override public void unregisterApplication(Application application) throws RegistrationException { if (!isGatewayUp()) { throw new RegistrationException(Messages.i18n.format("RestGatewayLink.GatewayNotRunning")); //$NON-NLS-1$ } getClient().unregister(application.getOrganizationId(), application.getApplicationId(), application.getVersion()); }
try { for (Contract contract : application.getContracts()) { if (contracts.containsKey(contract.getApiKey())) { throw new RegistrationException(Messages.i18n.format("InMemoryRegistry.ContractAlreadyPublished", //$NON-NLS-1$ for (Contract contract : application.getContracts()) { String svcKey = getServiceKey(contract.getServiceOrgId(), contract.getServiceId(), contract.getServiceVersion()); ServiceContract sc = new ServiceContract(contract.getApiKey(), services.get(svcKey), application, contract.getPolicies());