// Called for each page load of administration public void load() { /* In case plugin is uncheck */ // List all jobs List<String> allJobsName = new ArrayList<String>(); // List all the jobs that use the plugin (with at least one resource) List<String> allExclusionJobs = new ArrayList<String>(); // Check all projects for (Project<?, ?> p : Hudson.getInstance().getProjects()) { // Add all jobs names to the list allJobsName.add(p.getName()); // We want to retrieve all components BuildWrappers Map<Descriptor<BuildWrapper>, BuildWrapper> buildWrappers = p.getBuildWrappers(); // For each of them for (Iterator i = buildWrappers.keySet().iterator(); i.hasNext(); ) { Descriptor<BuildWrapper> key = (Descriptor<BuildWrapper>) i.next(); // We check if the descriptor is "org.jvnet.hudson.plugins.exclusion.IdAllocator $ // DescriptorImpl" if (buildWrappers .get(key) .getDescriptor() .toString() .split("@")[0] .equals("org.jvnet.hudson.plugins.exclusion.IdAllocator$DescriptorImpl")) { // No duplicates if (!allExclusionJobs.contains(p.getName())) { allExclusionJobs.add(p.getName()); } } } } // We delete each job that is in the global list and not in the list of exclusions for (String jobName : allJobsName) { if (!allExclusionJobs.contains(jobName)) { IdAllocator.deleteList(jobName); } } // Set all builds to false (build = currently used) for (RessourcesMonitor rm : listRessources) { rm.setBuild(false); } // For each resource Job, set build to true if a resource is used for (Iterator i = IdAllocationManager.ids.keySet().iterator(); i.hasNext(); ) { String resource = (String) i.next(); IdAllocator.updateBuild( IdAllocationManager.ids.get(resource).getProject().getName(), resource, true); } list = new ArrayList<RessourcesMonitor>(); // Local copy of the list for (RessourcesMonitor rm : listRessources) { list.add(new RessourcesMonitor(rm.getJobName(), rm.getRessource(), rm.getBuild())); } }