Skip to content
Permalink
Browse files
Merge pull request #53 from oleg-nenashev/bug/JENKINS-28881-column-fo…
…lder-info

[JENKINS-28881] - Job Ownership Column should display info for folders
  • Loading branch information
oleg-nenashev committed Sep 15, 2016
2 parents 2550b23 + 5c4c19f commit d042fce3c1a60a9087cc8b0053d445aa0fe03145
Showing 1 changed file with 25 additions and 4 deletions.
@@ -24,11 +24,19 @@
package com.synopsys.arc.jenkins.plugins.ownership.jobs;

import com.synopsys.arc.jenkins.plugins.ownership.Messages;
import com.synopsys.arc.jenkins.plugins.ownership.OwnershipDescription;
import com.synopsys.arc.jenkins.plugins.ownership.util.AbstractOwnershipHelper;
import org.kohsuke.stapler.DataBoundConstructor;
import hudson.Extension;
import hudson.model.Item;
import hudson.model.Job;
import hudson.model.TopLevelItem;
import hudson.model.User;
import hudson.views.ListViewColumnDescriptor;
import hudson.views.ListViewColumn;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import org.jenkinsci.plugins.ownership.model.OwnershipHelperLocator;

/**
* Provides Ownership column for the list view.
@@ -42,12 +50,25 @@ public JobOwnerColumn() {
super();
}

public String getJobOwner(@SuppressWarnings("rawtypes") Job job) {
return JobOwnerHelper.Instance.getOwner(job);
@Nonnull
public String getJobOwner(Item item) {
final OwnershipDescription description = getDescription(item);
return description != null ? description.getPrimaryOwnerId() : User.getUnknown().getId();
}

public boolean isOwnerExists(@SuppressWarnings("rawtypes") Job job) {
return JobOwnerHelper.Instance.isOwnerExists(job);
public boolean isOwnerExists(Item item) {
final OwnershipDescription description = getDescription(item);
return description != null ? description.hasPrimaryOwner(): false;
}

@CheckForNull
private OwnershipDescription getDescription(Item item) {
AbstractOwnershipHelper<Item> helper = OwnershipHelperLocator.locate(item);
if (helper == null) {
// We cannot retrieve helper for the object => keep moving
return null;
}
return helper.getOwnershipDescription(item);
}

@Extension

0 comments on commit d042fce

Please sign in to comment.