* @param contribution
* @return
*/
private static Item item(Workspace workspace, Contribution contribution) {
String contributionURI = contribution.getURI();
Item item = new Item();
item.setTitle(title(contributionURI));
item.setLink(link(contributionURI));
item.setAlternate(contribution.getLocation());
// List the contribution dependencies in the item contents
final List<String> problems = new ArrayList<String>();
Monitor monitor = new Monitor() {
public void problem(Problem problem) {
problems.add(problem.getMessageId() + " " + problem.getProblemObject().toString());
}
public List<Problem> getProblems() {
return null;
}
public Problem createProblem(String sourceClassName, String bundleName,
Severity severity, Object problemObject, String messageId,
Exception cause) {
return new ProblemImpl(sourceClassName, bundleName, severity,
problemObject, messageId, cause);
}
public Problem createProblem(String sourceClassName, String bundleName,
Severity severity, Object problemObject, String messageId,
Object... messageParams) {
return new ProblemImpl(sourceClassName, bundleName, severity,
problemObject, messageId, messageParams);
}
};
StringBuffer sb = new StringBuffer();
ContributionDependencyBuilderImpl analyzer = new ContributionDependencyBuilderImpl(monitor);
List<Contribution> dependencies = analyzer.buildContributionDependencies(contribution, workspace);
if (dependencies.size() > 1) {
sb.append("Dependencies: <span id=\"dependencies\">");
for (int i = 0, n = dependencies.size(); i < n ; i++) {
if (i > 0) {
sb.append(" ");
}
Contribution dependency = dependencies.get(i);
if (dependency != contribution) {
String dependencyURI = dependency.getURI();
sb.append("<a href=\""+ link(dependencyURI) +"\">" + title(dependencyURI) + "</a>");
}
}
sb.append("</span><br>");
}
// List the deployables
List<Composite> deployables = contribution.getDeployables();
if (!deployables.isEmpty()) {
sb.append("Deployables: <span id=\"deployables\">");
for (int i = 0, n = deployables.size(); i < n ; i++) {
if (i > 0) {
sb.append(" ");
}
Composite deployable = deployables.get(i);
QName qname = deployable.getName();
sb.append("<a href=\""+ compositeSourceLink(contributionURI, qname) +"\">" + compositeSimpleTitle(contributionURI, qname) + "</a>");
}
sb.append("</span><br>");
}
// List the dependency problems
if (contribution.isUnresolved()) {
problems.add("Contribution not found");
}
if (problems.size() > 0) {
sb.append("<span id=\"problems\" style=\"color: red\">");
for (int i = 0, n = problems.size(); i < n ; i++) {
sb.append("Problem: "+ problems.get(i) + "<br>");
}
sb.append("</span>");
}
// Store in the item contents
item.setContents(sb.toString());
return item;
}