Skip to content

Commit

Permalink
Merge pull request #36 from oleg-nenashev/JENKINS-36570-AbstractProje…
Browse files Browse the repository at this point in the history
…ct-cleanup

[JENKINS-36570] - Cleanup references to AbstractProject in the core plugin classes
  • Loading branch information
oleg-nenashev committed Jan 17, 2017
2 parents 14df308 + c9bfe6d commit f74d95f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
Expand Up @@ -24,13 +24,14 @@
package jenkins.advancedqueue;

import hudson.Extension;
import hudson.model.AbstractProject;
import hudson.model.Job;
import hudson.security.ACL;
import hudson.util.FormValidation;
import hudson.util.ListBoxModel;

import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import jenkins.advancedqueue.JobGroup.PriorityStrategyHolder;
Expand Down Expand Up @@ -148,24 +149,24 @@ private void updatePriorities(int prevNumberOfPriorities) {
SecurityContext saveCtx = ACL.impersonate(ACL.SYSTEM);
try {
@SuppressWarnings("rawtypes")
List<AbstractProject> allProjects = Jenkins.getInstance().getAllItems(AbstractProject.class);
for (AbstractProject<?, ?> project : allProjects) {
List<Job> allJobs = Jenkins.getInstance().getAllItems(Job.class);
for (Job<?, ?> job : allJobs) {
try {
// Scale any priority on the Job
PriorityJobProperty priorityProperty = project
PriorityJobProperty priorityProperty = job
.getProperty(PriorityJobProperty.class);
if (priorityProperty != null && priorityProperty.getUseJobPriority()) {
int newPriority = PriorityCalculationsUtil.scale(prevNumberOfPriorities,
strategy.getNumberOfPriorities(), priorityProperty.priority);
if (newPriority != priorityProperty.getPriority()) {
project.removeProperty(priorityProperty);
project.addProperty(new PriorityJobProperty(priorityProperty.getUseJobPriority(),
job.removeProperty(priorityProperty);
job.addProperty(new PriorityJobProperty(priorityProperty.getUseJobPriority(),
newPriority));
project.save();
job.save();
}
}
} catch (IOException e) {
LOGGER.warning("Failed to update Advanced Job Priority To " + project.getName());
LOGGER.log(Level.WARNING, "Failed to update Advanced Job Priority To {0}", job.getName());
}
}
//
Expand Down
Expand Up @@ -24,7 +24,7 @@
package jenkins.advancedqueue.jobinclusion.strategy;

import hudson.Extension;
import hudson.model.AbstractProject;
import hudson.model.Job;
import hudson.model.JobProperty;
import hudson.model.JobPropertyDescriptor;
import hudson.util.ListBoxModel;
Expand All @@ -35,7 +35,7 @@
* @author Magnus Sandberg
* @since 3.0
*/
public class JobInclusionJobProperty extends JobProperty<AbstractProject<?, ?>> {
public class JobInclusionJobProperty extends JobProperty<Job<?, ?>> {

private boolean useJobGroup;

Expand Down
Expand Up @@ -50,7 +50,7 @@
* @author Magnus Sandberg
* @since 2.0
*/
public class PriorityJobProperty extends JobProperty<AbstractProject<?, ?>> {
public class PriorityJobProperty extends JobProperty<Job<?, ?>> {

private final static Logger LOGGER = Logger.getLogger(PriorityJobProperty.class.getName());

Expand Down

0 comments on commit f74d95f

Please sign in to comment.