Skip to content
Permalink
Browse files
[JENKINS-31162] The service is now under View instead of View + ItemG…
…roupMixin
  • Loading branch information
recena committed Mar 22, 2016
1 parent 5ad9303 commit 213cf1032beaf8b7744d8c0f4f58564c890eacf3
Showing 3 changed files with 27 additions and 47 deletions.
@@ -29,14 +29,8 @@
import hudson.security.AccessControlled;
import hudson.util.CopyOnWriteMap;
import hudson.util.Function1;
import jenkins.model.item_category.Categories;
import jenkins.model.item_category.Category;
import jenkins.model.item_category.ItemCategory;
import jenkins.model.Jenkins;
import jenkins.util.xml.XMLUtils;
import org.acegisecurity.Authentication;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

@@ -50,10 +44,6 @@
import java.io.FileFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -338,39 +328,6 @@ public synchronized TopLevelItem createProject( TopLevelItemDescriptor type, Str
return item;
}

/**
* Populate a {@link Categories} object from a specific {@link ItemGroup}.
*
* @return A object that represents a set of {@link Category}
*/
@Restricted(NoExternalUse.class)
public static Categories getCategories(Authentication a, ItemGroup c) {
Categories categories = new Categories();
int weight = 0;
for (TopLevelItemDescriptor descriptor : DescriptorVisibilityFilter.apply(c, Items.all(a, c))) {
ItemCategory ic = ItemCategory.getCategory(descriptor);
Map<String, Serializable> metadata = new HashMap<String, Serializable>();

// Information about Item.
metadata.put("class", descriptor.getId());
metadata.put("weight", ++weight);
metadata.put("displayName", descriptor.getDisplayName());
metadata.put("description", descriptor.getDescription());
metadata.put("iconFilePathPattern", descriptor.getIconFilePathPattern());

Category category = categories.getItem(ic.getId());
if (category != null) {
category.getItems().add(metadata);
} else {
List<Map<String, Serializable>> temp = new ArrayList<Map<String, Serializable>>();
temp.add(metadata);
category = new Category(ic.getId(), ic.getDisplayName(), ic.getDescription(), ic.getWeight() , ic.getMinToShow(), temp);
categories.getItems().add(category);
}
}
return categories;
}

/**
* Pointless wrapper to avoid HotSpot problem. See JENKINS-5756
*/
@@ -57,6 +57,8 @@
import jenkins.model.item_category.Categories;
import jenkins.model.Jenkins;
import jenkins.model.ModelObjectWithChildren;
import jenkins.model.item_category.Category;
import jenkins.model.item_category.ItemCategory;
import jenkins.util.ProgressiveRendering;
import jenkins.util.xml.XMLUtils;

@@ -86,6 +88,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Serializable;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
@@ -1011,7 +1014,30 @@ public synchronized void doDoDelete(StaplerRequest req, StaplerResponse rsp) thr
*/
@Restricted(DoNotUse.class)
public Categories doCategories(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
return ItemGroupMixIn.getCategories(Jenkins.getAuthentication(), getOwnerItemGroup());
Categories categories = new Categories();
int weight = 0;
for (TopLevelItemDescriptor descriptor : DescriptorVisibilityFilter.apply(getOwnerItemGroup(), Items.all(Jenkins.getAuthentication(), getOwnerItemGroup()))) {
ItemCategory ic = ItemCategory.getCategory(descriptor);
Map<String, Serializable> metadata = new HashMap<String, Serializable>();

// Information about Item.
metadata.put("class", descriptor.getId());
metadata.put("weight", ++weight);
metadata.put("displayName", descriptor.getDisplayName());
metadata.put("description", descriptor.getDescription());
metadata.put("iconFilePathPattern", descriptor.getIconFilePathPattern());

Category category = categories.getItem(ic.getId());
if (category != null) {
category.getItems().add(metadata);
} else {
List<Map<String, Serializable>> temp = new ArrayList<Map<String, Serializable>>();
temp.add(metadata);
category = new Category(ic.getId(), ic.getDisplayName(), ic.getDescription(), ic.getWeight() , ic.getMinToShow(), temp);
categories.getItems().add(category);
}
}
return categories;
}

public void doRssAll( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
@@ -3,13 +3,10 @@
import hudson.Extension;
import hudson.ExtensionList;
import hudson.ExtensionPoint;
import hudson.model.ModelObject;
import hudson.model.TopLevelItemDescriptor;
import jenkins.model.Messages;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import java.util.Collection;

/**
* A category for {@link hudson.model.Item}s.

0 comments on commit 213cf10

Please sign in to comment.