package org.alien4cloud.secret.services;

import java.util.List;

import com.google.common.collect.Lists;
import org.springframework.stereotype.Component;

import alien4cloud.plugin.AbstractPluginLinker;
import alien4cloud.plugin.model.PluginUsage;
import org.alien4cloud.secret.ISecretProvider;

@Component
public class SecretProviderRegistry extends AbstractPluginLinker<ISecretProvider> {

    @Override
    public List<PluginUsage> usage(String pluginId) {
        // TODO how to determine plugin usage
        return null;
    }
}

@@ -46,465 +46,1394 @@
 ort 
-java.util.Lis
+alien4cloud.dao.IGenericSearchDAO;%0Aimport alien4cloud.dao.model.GetMultipleDataResul
 t;%0A
-%0A
 import 
-com.google.common.collect.Lists;%0Aimport org.springframework.stereotype.Component;%0A%0Aimport alien4cloud.plugin.AbstractPluginLinker;%0Aimport alien4cloud.plugin.model.PluginUsage;%0Aimport org.alien4cloud.secret.ISecretProvider;%0A%0A@Component%0Apublic class SecretProviderRegistry extends AbstractPluginLinker%3CISecretProvider%3E %7B%0A%0A    @Override%0A    public List%3CPluginUsage%3E usage(String pluginId) %7B%0A        // TODO how to determine plugin usage
+alien4cloud.model.orchestrators.locations.Location;%0Aimport alien4cloud.model.secret.SecretProviderConfiguration;%0Aimport alien4cloud.plugin.AbstractPluginLinker;%0Aimport alien4cloud.plugin.model.PluginUsage;%0Aimport com.google.common.collect.Lists;%0Aimport org.alien4cloud.secret.ISecretProvider;%0Aimport org.springframework.stereotype.Component;%0A%0Aimport javax.annotation.Resource;%0Aimport java.util.List;%0A%0A@Component%0Apublic class SecretProviderRegistry extends AbstractPluginLinker%3CISecretProvider%3E %7B%0A    @Resource(name = %22alien-es-dao%22)%0A    private IGenericSearchDAO alienDAO;%0A%0A    @Override%0A    public List%3CPluginUsage%3E usage(String pluginId) %7B%0A        GetMultipleDataResult%3CLocation%3E locationData = alienDAO.buildQuery(Location.class).prepareSearch().search(0, Integer.MAX_VALUE);%0A%0A        List%3CPluginUsage%3E usages = Lists.newArrayList();%0A        for (Location location : locationData.getData()) %7B%0A            SecretProviderConfiguration locationSecretProviderConfiguration = location.getSecretProviderConfiguration();%0A            if (locationSecretProviderConfiguration != null && locationSecretProviderConfiguration.getPluginName().equals(pluginId)) %7B%0A                usages.add(new PluginUsage(location.getId(), location.getName(), Location.class.getSimpleName()));%0A%0A            %7D%0A        %7D%0A
 %0A   
@@ -1444,20 +1444,22 @@
  return 
-null
+usages
 ;%0A    %7D%0A

Check vault plugins usage before delete/disable it