Search in sources :

Example 1 with DEFAULT_DELETED

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT_DELETED in project cloudbreak by hortonworks.

the class BlueprintLoaderService method deleteOldDefaults.

public void deleteOldDefaults(Set<Blueprint> blueprintsInDatabase) {
    List<Blueprint> deletableDefaults = blueprintsInDatabase.stream().filter(blueprint -> blueprint.getStatus().equals(DEFAULT)).filter(blueprint -> !defaultBlueprintCache.defaultBlueprints().containsKey(blueprint.getName())).filter(blueprint -> clusterTemplateService.getTemplatesByBlueprint(blueprint).isEmpty()).collect(Collectors.toList());
    LOGGER.info("Put old default blueprints to DEFAULT_DELETED: " + deletableDefaults);
    for (Blueprint blueprint : deletableDefaults) {
        blueprint.setStatus(DEFAULT_DELETED);
    }
    blueprintService.pureSaveAll(deletableDefaults);
}
Also used : BiFunction(java.util.function.BiFunction) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) USER_MANAGED(com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.USER_MANAGED) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ThreadBasedUserCrnProvider(com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider) Service(org.springframework.stereotype.Service) ClusterTemplateService(com.sequenceiq.cloudbreak.service.template.ClusterTemplateService) Map(java.util.Map) BlueprintUpgradeOption(com.sequenceiq.cloudbreak.domain.BlueprintUpgradeOption) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Logger(org.slf4j.Logger) BlueprintFile(com.sequenceiq.cloudbreak.domain.BlueprintFile) DEFAULT_DELETED(com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT_DELETED) Collection(java.util.Collection) Set(java.util.Set) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) DEFAULT(com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT) List(java.util.List) Entry(java.util.Map.Entry) Optional(java.util.Optional) BlueprintService(com.sequenceiq.cloudbreak.service.blueprint.BlueprintService) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint)

Aggregations

Sets (com.google.common.collect.Sets)1 DEFAULT (com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT)1 DEFAULT_DELETED (com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT_DELETED)1 USER_MANAGED (com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.USER_MANAGED)1 ThreadBasedUserCrnProvider (com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider)1 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)1 BlueprintFile (com.sequenceiq.cloudbreak.domain.BlueprintFile)1 BlueprintUpgradeOption (com.sequenceiq.cloudbreak.domain.BlueprintUpgradeOption)1 BlueprintService (com.sequenceiq.cloudbreak.service.blueprint.BlueprintService)1 ClusterTemplateService (com.sequenceiq.cloudbreak.service.template.ClusterTemplateService)1 Workspace (com.sequenceiq.cloudbreak.workspace.model.Workspace)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Optional (java.util.Optional)1 Set (java.util.Set)1 BiFunction (java.util.function.BiFunction)1