提交 f74d84fd 编写于 作者: K kohsuke

labels may not contain any Node at given point and still valid

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@18328 71c3de6d-444a-0410-be80-ed276b4c234a
上级 f7ffc67f
......@@ -35,6 +35,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.Collection;
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext;
......@@ -228,22 +229,31 @@ public class Label implements Comparable<Label>, ModelObject {
@Exported
public String getDescription() {
Set<Node> nodes = getNodes();
if(nodes.isEmpty())
return "invalid label";
if(nodes.isEmpty()) {
Set<Cloud> clouds = getClouds();
if(clouds.isEmpty())
return "invalid label";
return toString(clouds, new StringBuilder("Provisioned from "));
}
if(nodes.size()==1) {
return nodes.iterator().next().getNodeDescription();
}
StringBuilder buf = new StringBuilder("group of ");
return toString(nodes,new StringBuilder("group of "));
}
private String toString(Collection<? extends ModelObject> model, StringBuilder buf) {
boolean first=true;
for (Node n : nodes) {
for (ModelObject c : model) {
if(buf.length()>80) {
buf.append(",...");
break;
}
if(!first) buf.append(',');
else first=false;
buf.append(n.getNodeName());
buf.append(c.getDisplayName());
}
return buf.toString();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册