private void processCloudDeletions(long envId, Set<Long> cloudsToRemove) { // looks like we need to delete some clouds // first lets see if we have any open releases CmsCI env = getEnv(envId); String manifestNsPath = env.getNsPath() + "/" + env.getCiName() + "/manifest"; String bomNsPath = env.getNsPath() + "/" + env.getCiName() + "/bom"; List<CmsRelease> manifestOpenReleases = rfcProcessor.getReleaseBy3(manifestNsPath, null, RELEASE_STATE_OPEN); if (manifestOpenReleases.size() > 0) { // throw exception on open release throw new TransistorException( CmsError.TRANSISTOR_OPEN_MANIFEST_RELEASE, "There is open release in this environment, you have to commit or discard before deleteing the clouds!"); } List<CmsRelease> bomOpenReleases = rfcProcessor.getReleaseBy3(bomNsPath, null, RELEASE_STATE_OPEN); if (bomOpenReleases.size() > 0) { // throw exception on open release throw new TransistorException( CmsError.TRANSISTOR_OPEN_BOM_RELEASE, "There is open BOM release in this environment, you have to deploy or discard before deleteing the clouds!"); } // if we still here lets check if there are any boms deployed to the clouds that user tries to // remove for (long cloidId : cloudsToRemove) { long deployedToRelsCount = cmProcessor.getCountToCIRelationsByNS( cloidId, BASE_DEPLOYED_TO, null, null, bomNsPath, true); if (deployedToRelsCount > 0) { // throw exception that there are active boms throw new TransistorException( CmsError.TRANSISTOR_BOM_INSTANCES_EXIST, "There are deployed instances in the cloud, please put the cloud in offline mode for every platform and deploy!"); } } // if everything cool, let remove Consumes relations from platforms and env for (long cloidId : cloudsToRemove) { List<CmsCIRelation> platformRels = cmProcessor.getFromCIRelationsNaked(envId, MANIFEST_COMPOSED_OF, MANIFEST_PLATFORM); for (CmsCIRelation platRel : platformRels) { List<CmsCIRelation> platformCloudRels = cmProcessor.getFromToCIRelations(platRel.getToCiId(), BASE_CONSUMES, cloidId); for (CmsCIRelation platCloudRel : platformCloudRels) { cmProcessor.deleteRelation(platCloudRel.getCiRelationId()); } } // now lets remove env consumes rel List<CmsCIRelation> envCloudRels = cmProcessor.getFromToCIRelations(envId, BASE_CONSUMES, cloidId); for (CmsCIRelation cloudRel : envCloudRels) { cmProcessor.deleteRelation(cloudRel.getCiRelationId()); } } }