@Override public long updateEnvClouds(long envId, List<CmsCIRelation> cloudRels, String userId) { // for now we will handle just new clouds List<CmsCIRelation> existingCloudRels = cmProcessor.getFromCIRelationsNaked(envId, BASE_CONSUMES, ACCOUNT_CLOUD); Set<Long> existingCloudIds = new HashSet<Long>(); for (CmsCIRelation rel : existingCloudRels) { existingCloudIds.add(rel.getToCiId()); } boolean needUpdate = false; for (CmsCIRelation requestRel : cloudRels) { if (!existingCloudIds.contains(requestRel.getToCiId())) { // this is new cloud lets add env->cloud rel cmProcessor.createRelation(requestRel); needUpdate = true; } else { cmProcessor.updateRelation(requestRel); existingCloudIds.remove(requestRel.getToCiId()); } } if (!existingCloudIds.isEmpty()) { // looks like we need to delete some clouds // first lets see if we have any open releases processCloudDeletions(envId, existingCloudIds); } if (needUpdate) { CmsCI env = getEnv(envId); String nsPath = env.getNsPath() + "/" + env.getCiName() + "/manifest"; List<CmsRfcRelation> compOfRels = cmRfcMrgProcessor.getFromCIRelations( envId, MANIFEST_COMPOSED_OF, MANIFEST_PLATFORM, "dj"); for (CmsRfcRelation compOfRel : compOfRels) { CmsRfcCI platform = compOfRel.getToRfcCi(); String platNs = platform.getNsPath(); manifestRfcProcessor.processClouds(env, platform, platNs, nsPath, userId, null, null, null); Set<String> missingSrvs = cloudUtil.getMissingServices(platform.getCiId()); if (missingSrvs.size() > 0) { logger.info( ">>>>> Not all services available for platform: " + platform.getCiName() + ", the missing services: " + missingSrvs.toString()); manifestRfcProcessor.disablePlatform(platform.getCiId(), userId); } logger.info("Done working on platform " + platform.getCiName()); } return populateParentRelease(env, nsPath); } else { return 0; } }