From f11592770694e9d0a391a31fa23f455bc05756c1 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Fri, 31 Oct 2014 09:22:01 -0400
Subject: [PATCH] Merged #212 "Gracefully handle missing integration branch in ticket page"

---
 src/main/java/com/gitblit/wicket/panels/TicketListPanel.java |   39 +++++++++++++++++++++++++++++----------
 1 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/src/main/java/com/gitblit/wicket/panels/TicketListPanel.java b/src/main/java/com/gitblit/wicket/panels/TicketListPanel.java
index 1ca483c..2ac33d5 100644
--- a/src/main/java/com/gitblit/wicket/panels/TicketListPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/TicketListPanel.java
@@ -64,11 +64,10 @@
 			@Override
 			protected void populateItem(Item<QueryResult> item) {
 				final QueryResult ticket = item.getModelObject();
-				final RepositoryModel repository = app().repositories().getRepositoryModel(ticket.repository);
 
 				if (showSwatch) {
 					// set repository color
-					String color = StringUtils.getColor(StringUtils.stripDotGit(repository.name));
+					String color = StringUtils.getColor(StringUtils.stripDotGit(ticket.repository));
 					WicketUtils.setCssStyle(item, MessageFormat.format("border-left: 2px solid {0};", color));
 				}
 
@@ -84,7 +83,10 @@
 					item.add(new Label("ticketsLink").setVisible(false));
 				}
 
-				item.add(TicketsUI.getStateIcon("state", ticket.type, ticket.status));
+				Label icon = TicketsUI.getStateIcon("state", ticket.type, ticket.status, ticket.severity);
+				WicketUtils.addCssClass(icon, TicketsUI.getSeverityClass(ticket.severity));
+				item.add(icon);
+
 				item.add(new Label("id", "" + ticket.number));
 				UserModel creator = app().users().getUserModel(ticket.createdBy);
 				if (creator != null) {
@@ -121,13 +123,25 @@
 
 					@Override
 					public void populateItem(final Item<String> labelItem) {
-						BugtraqProcessor btp  = new BugtraqProcessor(app().settings());
-						Repository db = app().repositories().getRepository(repository.name);
-						String content = btp.processText(db, repository.name, labelItem.getModelObject());
-						db.close();
-						Label label = new Label("label", content);
-						label.setEscapeModelStrings(false);
-						TicketLabel tLabel = app().tickets().getLabel(repository, labelItem.getModelObject());
+						RepositoryModel repository = app().repositories().getRepositoryModel(ticket.repository);
+						Label label;
+						TicketLabel tLabel;
+						if (repository == null) {
+							label = new Label("label", labelItem.getModelObject());
+							tLabel = new TicketLabel(labelItem.getModelObject());
+						} else {
+							Repository db = app().repositories().getRepository(repository.name);
+							BugtraqProcessor btp  = new BugtraqProcessor(app().settings());
+							String content = btp.processText(db, repository.name, labelItem.getModelObject());
+							String safeContent = app().xssFilter().relaxed(content);
+							db.close();
+
+							label = new Label("label", safeContent);
+							label.setEscapeModelStrings(false);
+
+							tLabel = app().tickets().getLabel(repository, labelItem.getModelObject());
+						}
+
 						String background = MessageFormat.format("background-color:{0};", tLabel.color);
 						label.add(new SimpleAttributeModifier("style", background));
 						labelItem.add(label);
@@ -156,6 +170,11 @@
 				// watching indicator
 				item.add(new Label("watching").setVisible(ticket.isWatching(GitBlitWebSession.get().getUsername())));
 
+				// priority indicator
+				Label priorityIcon = TicketsUI.getPriorityIcon("priority", ticket.priority);
+				WicketUtils.addCssClass(priorityIcon, TicketsUI.getPriorityClass(ticket.priority));
+				item.add(priorityIcon.setVisible(true));
+
 				// status indicator
 				String css = TicketsUI.getLozengeClass(ticket.status, true);
 				Label l = new Label("status", ticket.status.toString());

--
Gitblit v1.9.1