1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package tinlizard.web;
20
21 import tinlizard.model.Codeline;
22 import tinlizard.model.Dependency;
23
24 import tinlizard.util.Messages;
25
26 import java.util.ArrayList;
27 import java.util.Collection;
28 import java.util.HashSet;
29 import java.util.Set;
30
31 import org.codehaus.plexus.util.StringUtils;
32
33 import org.kohsuke.stapler.StaplerRequest;
34 import org.kohsuke.stapler.StaplerResponse;
35
36 /***
37 * Decorate Group for Stapler.
38 */
39 public final class GroupWeb extends DependencyWeb {
40 public GroupWeb(final Dependency c) {
41 super(c);
42
43 if (StringUtils.isBlank(c.getGroupId())) {
44 throw new IllegalStateException(Messages.error_1020());
45 }
46 }
47
48 public String getName() {
49 return getGroupId();
50 }
51
52 public String getArtifactId() {
53 return null;
54 }
55
56 public String getVersion() {
57 return null;
58 }
59
60
61 public Collection<ArtifactWeb> getArtifacts() {
62 Collection<ArtifactWeb> artifacts = new ArrayList<ArtifactWeb>();
63 Set<String> artifactIds = new HashSet<String>();
64
65 artifactIds.addAll(Dependency.findAllArtifactIds(subject.getGroupId()));
66 artifactIds.addAll(Codeline.findAllArtifactIds(subject.getGroupId()));
67
68 for (String artifactIdId : artifactIds) {
69 Dependency dependency = new Dependency();
70 dependency.setGroupId(subject.getGroupId());
71 dependency.setArtifactId(artifactIdId);
72
73 artifacts.add(new ArtifactWeb(dependency));
74 }
75
76 return artifacts;
77 }
78
79 public Object getDynamic(final String token, final StaplerRequest req, final StaplerResponse rsp) {
80 if (StringUtils.isNotBlank(token)) {
81 Dependency dependency = new Dependency();
82 dependency.setGroupId(subject.getGroupId());
83 dependency.setArtifactId(token);
84
85 return new ArtifactWeb(dependency);
86 }
87
88 return null;
89 }
90 }