org.cloudfoundry.multiapps.controller.process.jobs.ConfigurationSubscriptionCleaner Maven / Gradle / Ivy
package org.cloudfoundry.multiapps.controller.process.jobs;
import java.text.MessageFormat;
import java.util.List;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import org.cloudfoundry.multiapps.controller.core.auditlogging.MtaConfigurationPurgerAuditLog;
import org.cloudfoundry.multiapps.controller.core.cf.OAuthClientFactory;
import org.cloudfoundry.multiapps.controller.core.util.ApplicationConfiguration;
import org.cloudfoundry.multiapps.controller.persistence.model.ConfigurationSubscription;
import org.cloudfoundry.multiapps.controller.persistence.services.ConfigurationSubscriptionService;
import org.springframework.core.annotation.Order;
/*
* This cleaner is heavy because it scans for deleted space events for every configuration subscription.
* Annotations are commented because this cleaner is not necessary to be executed.
* Uncomment these annotations in case it exists garbage and cleaner should be executed.
*/
//@Named()
//@Order(40)
public class ConfigurationSubscriptionCleaner extends OrphanedDataCleaner {
private final ConfigurationSubscriptionService configurationSubscriptionService;
@Inject
public ConfigurationSubscriptionCleaner(ApplicationConfiguration applicationConfiguration,
ConfigurationSubscriptionService configurationSubscriptionService,
OAuthClientFactory oAuthClientFactory,
MtaConfigurationPurgerAuditLog mtaConfigurationPurgerAuditLog) {
super(applicationConfiguration, oAuthClientFactory, mtaConfigurationPurgerAuditLog);
this.configurationSubscriptionService = configurationSubscriptionService;
}
@Override
protected String getStartCleanupLogMessage() {
return "Deleting orphaned configuration subscriptions...";
}
@Override
protected String getEndCleanupLogMessage(int deletedSubscriptionsCount) {
return MessageFormat.format("Orphaned configuration subscriptions deleted {0}", deletedSubscriptionsCount);
}
@Override
protected List getConfigurationData() {
return configurationSubscriptionService.createQuery()
.list();
}
@Override
protected String getSpaceId(ConfigurationSubscription configurationData) {
return configurationData.getSpaceId();
}
@Override
protected int deleteConfigurationDataBySpaceId(String spaceId) {
getMtaConfigurationPurgerAuditLog().logDeleteSubscription(spaceId);
return configurationSubscriptionService.createQuery()
.deleteAll(spaceId);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy