Skip to content

Commit

Permalink
[JENKINS-31162] The service is now under View instead of View + ItemG…
Browse files Browse the repository at this point in the history
…roupMixin
  • Loading branch information
recena committed Mar 22, 2016
1 parent 5ad9303 commit 213cf10
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 47 deletions.
43 changes: 0 additions & 43 deletions core/src/main/java/hudson/model/ItemGroupMixIn.java
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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
*/
Expand Down
28 changes: 27 additions & 1 deletion core/src/main/java/hudson/model/View.java
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
Expand Up @@ -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.
Expand Down

0 comments on commit 213cf10

Please sign in to comment.