]> source.dussan.org Git - gitblit.git/commitdiff
Fix ticket page IOBE when Gitblit is not serving repositories 27/27/1
authorJames Moger <james.moger@gitblit.com>
Thu, 13 Mar 2014 01:12:06 +0000 (21:12 -0400)
committerJames Moger <james.moger@gitblit.com>
Thu, 13 Mar 2014 01:12:06 +0000 (21:12 -0400)
src/main/java/com/gitblit/wicket/pages/TicketPage.java

index 80b55766c622a21c51e3648232b12a72686a08c0..498a9db661a4bcf3a39481be89ad9a56b2e7750f 100644 (file)
@@ -64,6 +64,7 @@ import com.gitblit.git.PatchsetReceivePack;
 import com.gitblit.models.PathModel.PathChangeModel;\r
 import com.gitblit.models.RegistrantAccessPermission;\r
 import com.gitblit.models.RepositoryModel;\r
+import com.gitblit.models.RepositoryUrl;\r
 import com.gitblit.models.SubmoduleModel;\r
 import com.gitblit.models.TicketModel;\r
 import com.gitblit.models.TicketModel.Change;\r
@@ -79,6 +80,7 @@ import com.gitblit.tickets.TicketIndexer.Lucene;
 import com.gitblit.tickets.TicketLabel;\r
 import com.gitblit.tickets.TicketMilestone;\r
 import com.gitblit.tickets.TicketResponsible;\r
+import com.gitblit.utils.ArrayUtils;\r
 import com.gitblit.utils.JGitUtils;\r
 import com.gitblit.utils.JGitUtils.MergeStatus;\r
 import com.gitblit.utils.MarkdownUtils;\r
@@ -732,10 +734,10 @@ public class TicketPage extends TicketBasePage {
                 */\r
                if (currentPatchset == null) {\r
                        // no patchset available\r
-                       if (ticket.isOpen() && app().tickets().isAcceptingNewPatchsets(repository)) {\r
+                       String repoUrl = getRepositoryUrl(user, repository);\r
+                       if (ticket.isOpen() && app().tickets().isAcceptingNewPatchsets(repository) && !StringUtils.isEmpty(repoUrl)) {\r
                                // ticket & repo will accept a proposal patchset\r
                                // show the instructions for proposing a patchset\r
-                               String repoUrl = getRepositoryUrl(user, repository);\r
                                Fragment changeIdFrag = new Fragment("patchset", "proposeFragment", this);\r
                                changeIdFrag.add(new Label("proposeInstructions", MarkdownUtils.transformMarkdown(getString("gb.proposeInstructions"))).setEscapeModelStrings(false));\r
                                changeIdFrag.add(new Label("ptWorkflow", MessageFormat.format(getString("gb.proposeWith"), "Barnum")));\r
@@ -1476,7 +1478,11 @@ public class TicketPage extends TicketBasePage {
         */\r
        protected String getRepositoryUrl(UserModel user, RepositoryModel repository) {\r
                HttpServletRequest req = ((WebRequest) getRequest()).getHttpServletRequest();\r
-               String primaryurl = app().gitblit().getRepositoryUrls(req, user, repository).get(0).url;\r
+               List<RepositoryUrl> urls = app().gitblit().getRepositoryUrls(req, user, repository);\r
+               if (ArrayUtils.isEmpty(urls)) {\r
+                       return null;\r
+               }\r
+               String primaryurl = urls.get(0).url;\r
                String url = primaryurl;\r
                try {\r
                        url = new URIish(primaryurl).setUser(null).toString();\r