From: James Moger Date: Thu, 13 Mar 2014 01:12:06 +0000 (-0400) Subject: Fix ticket page IOBE when Gitblit is not serving repositories X-Git-Tag: v1.4.1~10^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b236cef19b443aaf91a2ac72a94f70f6ccc228b1;p=gitblit.git Fix ticket page IOBE when Gitblit is not serving repositories --- diff --git a/src/main/java/com/gitblit/wicket/pages/TicketPage.java b/src/main/java/com/gitblit/wicket/pages/TicketPage.java index 80b55766..498a9db6 100644 --- a/src/main/java/com/gitblit/wicket/pages/TicketPage.java +++ b/src/main/java/com/gitblit/wicket/pages/TicketPage.java @@ -64,6 +64,7 @@ import com.gitblit.git.PatchsetReceivePack; import com.gitblit.models.PathModel.PathChangeModel; import com.gitblit.models.RegistrantAccessPermission; import com.gitblit.models.RepositoryModel; +import com.gitblit.models.RepositoryUrl; import com.gitblit.models.SubmoduleModel; import com.gitblit.models.TicketModel; import com.gitblit.models.TicketModel.Change; @@ -79,6 +80,7 @@ import com.gitblit.tickets.TicketIndexer.Lucene; import com.gitblit.tickets.TicketLabel; import com.gitblit.tickets.TicketMilestone; import com.gitblit.tickets.TicketResponsible; +import com.gitblit.utils.ArrayUtils; import com.gitblit.utils.JGitUtils; import com.gitblit.utils.JGitUtils.MergeStatus; import com.gitblit.utils.MarkdownUtils; @@ -732,10 +734,10 @@ public class TicketPage extends TicketBasePage { */ if (currentPatchset == null) { // no patchset available - if (ticket.isOpen() && app().tickets().isAcceptingNewPatchsets(repository)) { + String repoUrl = getRepositoryUrl(user, repository); + if (ticket.isOpen() && app().tickets().isAcceptingNewPatchsets(repository) && !StringUtils.isEmpty(repoUrl)) { // ticket & repo will accept a proposal patchset // show the instructions for proposing a patchset - String repoUrl = getRepositoryUrl(user, repository); Fragment changeIdFrag = new Fragment("patchset", "proposeFragment", this); changeIdFrag.add(new Label("proposeInstructions", MarkdownUtils.transformMarkdown(getString("gb.proposeInstructions"))).setEscapeModelStrings(false)); changeIdFrag.add(new Label("ptWorkflow", MessageFormat.format(getString("gb.proposeWith"), "Barnum"))); @@ -1476,7 +1478,11 @@ public class TicketPage extends TicketBasePage { */ protected String getRepositoryUrl(UserModel user, RepositoryModel repository) { HttpServletRequest req = ((WebRequest) getRequest()).getHttpServletRequest(); - String primaryurl = app().gitblit().getRepositoryUrls(req, user, repository).get(0).url; + List urls = app().gitblit().getRepositoryUrls(req, user, repository); + if (ArrayUtils.isEmpty(urls)) { + return null; + } + String primaryurl = urls.get(0).url; String url = primaryurl; try { url = new URIish(primaryurl).setUser(null).toString();