From 284a256a44f37c7b7c082baa1d633654c131316f Mon Sep 17 00:00:00 2001 From: Martin Spielmann Date: Sat, 30 Jul 2016 13:56:29 +0200 Subject: [PATCH] replaced ResourceStreamRequestTarget by ResourceStreamRequestHandler --- .../gitblit/wicket/pages/CommitDiffPage.java | 19 +- .../com/gitblit/wicket/pages/CommitPage.java | 227 +++++++++--------- .../com/gitblit/wicket/pages/TicketsPage.java | 3 +- .../com/gitblit/wicket/pages/TreePage.java | 182 +++++++------- 4 files changed, 222 insertions(+), 209 deletions(-) diff --git a/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java b/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java index 6e301d74..2092bba7 100644 --- a/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java +++ b/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; import org.apache.wicket.request.mapper.parameter.PageParameters; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.link.BookmarkablePageLink; @@ -28,7 +29,6 @@ import org.apache.wicket.markup.html.link.Link; import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.markup.repeater.data.DataView; import org.apache.wicket.markup.repeater.data.ListDataProvider; -import org.apache.wicket.request.target.resource.ResourceStreamRequestTarget; import org.apache.wicket.util.resource.AbstractResourceStreamWriter; import org.apache.wicket.util.resource.IResourceStream; import org.eclipse.jgit.diff.DiffEntry.ChangeType; @@ -61,6 +61,8 @@ import com.gitblit.wicket.panels.RefsPanel; @CacheControl(LastModified.BOOT) public class CommitDiffPage extends RepositoryPage { + private static final long serialVersionUID = 1L; + public CommitDiffPage(PageParameters params) { super(params); @@ -191,8 +193,9 @@ public class CommitDiffPage extends RepositoryPage { } }; - getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream, entry.path)); - }})); + ResourceStreamRequestHandler resourceStreamRequestHandler = new ResourceStreamRequestHandler( + resourceStream, entry.path); + getRequestCycle().scheduleRequestHandlerAfterCurrent(resourceStreamRequestHandler); }})); } else { @@ -240,8 +243,9 @@ public class CommitDiffPage extends RepositoryPage { }; - getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream, entry.path)); - }}); + ResourceStreamRequestHandler resourceStreamRequestHandler = new ResourceStreamRequestHandler( + resourceStream, entry.path); + getRequestCycle().scheduleRequestHandlerAfterCurrent(resourceStreamRequestHandler); }}); item.add(new Link("raw", null) { @@ -264,8 +268,9 @@ public class CommitDiffPage extends RepositoryPage { }; - getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream, entry.path)); - }}); + ResourceStreamRequestHandler resourceStreamRequestHandler = new ResourceStreamRequestHandler( + resourceStream, entry.path); + getRequestCycle().scheduleRequestHandlerAfterCurrent(resourceStreamRequestHandler); }}); } else { item.add(new BookmarkablePageLink("view", BlobPage.class, WicketUtils .newPathParameter(repositoryName, entry.commitId, entry.path)) diff --git a/src/main/java/com/gitblit/wicket/pages/CommitPage.java b/src/main/java/com/gitblit/wicket/pages/CommitPage.java index 6795af29..4b01fbde 100644 --- a/src/main/java/com/gitblit/wicket/pages/CommitPage.java +++ b/src/main/java/com/gitblit/wicket/pages/CommitPage.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; import org.apache.wicket.request.mapper.parameter.PageParameters; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.link.BookmarkablePageLink; @@ -29,7 +30,6 @@ import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.markup.repeater.data.DataView; import org.apache.wicket.markup.repeater.data.ListDataProvider; import org.apache.wicket.model.StringResourceModel; -//import org.apache.wicket.request.target.resource.ResourceStreamRequestTarget; import org.apache.wicket.util.resource.AbstractResourceStreamWriter; import org.apache.wicket.util.resource.IResourceStream; import org.eclipse.jgit.diff.DiffEntry.ChangeType; @@ -58,6 +58,8 @@ import com.gitblit.wicket.panels.RefsPanel; @CacheControl(LastModified.BOOT) public class CommitPage extends RepositoryPage { + private static final long serialVersionUID = 1L; + public CommitPage(PageParameters params) { super(params); @@ -76,11 +78,10 @@ public class CommitPage extends RepositoryPage { add(new Label("parentLink", "none")); add(new Label("commitdiffLink", getString("gb.commitdiff"))); } else { - add(new LinkPanel("parentLink", null, getShortObjectId(parents.get(0)), - CommitPage.class, newCommitParameter(parents.get(0)))); - add(new LinkPanel("commitdiffLink", null, new StringResourceModel("gb.commitdiff", - this, null), CommitDiffPage.class, WicketUtils.newObjectParameter( - repositoryName, objectId))); + add(new LinkPanel("parentLink", null, getShortObjectId(parents.get(0)), CommitPage.class, + newCommitParameter(parents.get(0)))); + add(new LinkPanel("commitdiffLink", null, new StringResourceModel("gb.commitdiff", this, null), + CommitDiffPage.class, WicketUtils.newObjectParameter(repositoryName, objectId))); } add(new BookmarkablePageLink("patchLink", PatchPage.class, WicketUtils.newObjectParameter(repositoryName, objectId))); @@ -91,18 +92,17 @@ public class CommitPage extends RepositoryPage { // author add(createPersonPanel("commitAuthor", c.getAuthorIdent(), Constants.SearchType.AUTHOR)); - add(WicketUtils.createTimestampLabel("commitAuthorDate", c.getAuthorIdent().getWhen(), - getTimeZone(), getTimeUtils())); + add(WicketUtils.createTimestampLabel("commitAuthorDate", c.getAuthorIdent().getWhen(), getTimeZone(), + getTimeUtils())); // committer add(createPersonPanel("commitCommitter", c.getCommitterIdent(), Constants.SearchType.COMMITTER)); - add(WicketUtils.createTimestampLabel("commitCommitterDate", - c.getCommitterIdent().getWhen(), getTimeZone(), getTimeUtils())); + add(WicketUtils.createTimestampLabel("commitCommitterDate", c.getCommitterIdent().getWhen(), getTimeZone(), + getTimeUtils())); add(new Label("commitId", c.getName())); - add(new LinkPanel("commitTree", "list", c.getTree().getName(), TreePage.class, - newCommitParameter())); + add(new LinkPanel("commitTree", "list", c.getTree().getName(), TreePage.class, newCommitParameter())); add(new BookmarkablePageLink("treeLink", TreePage.class, newCommitParameter())); final String baseUrl = WicketUtils.getGitblitURL(getRequest()); @@ -116,12 +116,9 @@ public class CommitPage extends RepositoryPage { @Override public void populateItem(final Item item) { String entry = item.getModelObject(); - item.add(new LinkPanel("commitParent", "list", entry, CommitPage.class, - newCommitParameter(entry))); - item.add(new BookmarkablePageLink("view", CommitPage.class, - newCommitParameter(entry))); - item.add(new BookmarkablePageLink("diff", CommitDiffPage.class, - newCommitParameter(entry))); + item.add(new LinkPanel("commitParent", "list", entry, CommitPage.class, newCommitParameter(entry))); + item.add(new BookmarkablePageLink("view", CommitPage.class, newCommitParameter(entry))); + item.add(new BookmarkablePageLink("diff", CommitDiffPage.class, newCommitParameter(entry))); } }; add(parentsView); @@ -138,13 +135,13 @@ public class CommitPage extends RepositoryPage { public void populateItem(final Item item) { GitNote entry = item.getModelObject(); item.add(new RefsPanel("refName", repositoryName, Arrays.asList(entry.notesRef))); - item.add(createPersonPanel("authorName", entry.notesRef.getAuthorIdent(), - Constants.SearchType.AUTHOR)); + item.add(createPersonPanel("authorName", entry.notesRef.getAuthorIdent(), Constants.SearchType.AUTHOR)); item.add(new AvatarImage("noteAuthorAvatar", entry.notesRef.getAuthorIdent())); - item.add(WicketUtils.createTimestampLabel("authorDate", entry.notesRef - .getAuthorIdent().getWhen(), getTimeZone(), getTimeUtils())); - item.add(new Label("noteContent", bugtraqProcessor().processPlainCommitMessage(getRepository(), repositoryName, - entry.content)).setEscapeModelStrings(false)); + item.add(WicketUtils.createTimestampLabel("authorDate", entry.notesRef.getAuthorIdent().getWhen(), + getTimeZone(), getTimeUtils())); + item.add(new Label("noteContent", + bugtraqProcessor().processPlainCommitMessage(getRepository(), repositoryName, entry.content)) + .setEscapeModelStrings(false)); } }; add(notesView.setVisible(notes.size() > 0)); @@ -170,22 +167,21 @@ public class CommitPage extends RepositoryPage { @Override public void populateItem(final Item item) { final PathChangeModel entry = item.getModelObject(); - + Label changeType = new Label("changeType", ""); WicketUtils.setChangeTypeCssClass(changeType, entry.changeType); setChangeTypeTooltip(changeType, entry.changeType); item.add(changeType); item.add(new DiffStatPanel("diffStat", entry.insertions, entry.deletions, true)); item.add(WicketUtils.setHtmlTooltip(new Label("filestore", ""), getString("gb.filestore")) - .setVisible(entry.isFilestoreItem())); + .setVisible(entry.isFilestoreItem())); boolean hasSubmodule = false; String submodulePath = null; if (entry.isTree()) { // tree item.add(new LinkPanel("pathName", null, entry.path, TreePage.class, - WicketUtils - .newPathParameter(repositoryName, entry.commitId, entry.path))); + WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path))); } else if (entry.isSubmodule()) { // submodule String submoduleId = entry.objectId; @@ -193,9 +189,9 @@ public class CommitPage extends RepositoryPage { submodulePath = submodule.gitblitPath; hasSubmodule = submodule.hasSubmodule; - item.add(new LinkPanel("pathName", "list", entry.path + " @ " + - getShortObjectId(submoduleId), TreePage.class, - WicketUtils.newPathParameter(submodulePath, submoduleId, "")).setEnabled(hasSubmodule)); + item.add(new LinkPanel("pathName", "list", entry.path + " @ " + getShortObjectId(submoduleId), + TreePage.class, WicketUtils.newPathParameter(submodulePath, submoduleId, "")) + .setEnabled(hasSubmodule)); } else { // blob String displayPath = entry.path; @@ -204,125 +200,132 @@ public class CommitPage extends RepositoryPage { path = JGitUtils.getStringContent(getRepository(), getCommit().getTree(), path); displayPath = entry.path + " -> " + path; } - + if (entry.isFilestoreItem()) { item.add(new LinkPanel("pathName", "list", entry.path, new Link("link", null) { - + private static final long serialVersionUID = 1L; @Override - public void onClick() { - - IResourceStream resourceStream = new AbstractResourceStreamWriter() { - + public void onClick() { + + IResourceStream resourceStream = new AbstractResourceStreamWriter() { + private static final long serialVersionUID = 1L; - @Override - public void write(OutputStream output) { - UserModel user = GitBlitWebSession.get().getUser(); - user = user == null ? UserModel.ANONYMOUS : user; - - app().filestore().downloadBlob(entry.getFilestoreOid(), user, getRepositoryModel(), output); - } - }; - - - getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream, entry.path)); - }})); - - + @Override + public void write(OutputStream output) { + UserModel user = GitBlitWebSession.get().getUser(); + user = user == null ? UserModel.ANONYMOUS : user; + + app().filestore().downloadBlob(entry.getFilestoreOid(), user, + getRepositoryModel(), output); + } + }; + + ResourceStreamRequestHandler resourceStreamRequestHandler = new ResourceStreamRequestHandler( + resourceStream, entry.path); + getRequestCycle().scheduleRequestHandlerAfterCurrent(resourceStreamRequestHandler); + } + })); + } else { item.add(new LinkPanel("pathName", "list", displayPath, BlobPage.class, - WicketUtils.newPathParameter(repositoryName, entry.commitId, path))); + WicketUtils.newPathParameter(repositoryName, entry.commitId, path))); } } - // quick links if (entry.isSubmodule()) { item.add(new ExternalLink("raw", "").setEnabled(false)); // submodule - item.add(new BookmarkablePageLink("diff", BlobDiffPage.class, WicketUtils - .newPathParameter(repositoryName, entry.commitId, entry.path)) - .setEnabled(!entry.changeType.equals(ChangeType.ADD))); - item.add(new BookmarkablePageLink("view", CommitPage.class, WicketUtils - .newObjectParameter(submodulePath, entry.objectId)).setEnabled(hasSubmodule)); + item.add(new BookmarkablePageLink("diff", BlobDiffPage.class, + WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path)) + .setEnabled(!entry.changeType.equals(ChangeType.ADD))); + item.add(new BookmarkablePageLink("view", CommitPage.class, + WicketUtils.newObjectParameter(submodulePath, entry.objectId)).setEnabled(hasSubmodule)); item.add(new ExternalLink("blame", "").setEnabled(false)); - item.add(new BookmarkablePageLink("history", HistoryPage.class, WicketUtils - .newPathParameter(repositoryName, entry.commitId, entry.path)) - .setEnabled(!entry.changeType.equals(ChangeType.ADD))); + item.add(new BookmarkablePageLink("history", HistoryPage.class, + WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path)) + .setEnabled(!entry.changeType.equals(ChangeType.ADD))); } else { // tree or blob - item.add(new BookmarkablePageLink("diff", BlobDiffPage.class, WicketUtils - .newPathParameter(repositoryName, entry.commitId, entry.path)) - .setEnabled(!entry.changeType.equals(ChangeType.ADD) - && !entry.changeType.equals(ChangeType.DELETE))); - + item.add(new BookmarkablePageLink("diff", BlobDiffPage.class, + WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path)) + .setEnabled(!entry.changeType.equals(ChangeType.ADD) + && !entry.changeType.equals(ChangeType.DELETE))); + if (entry.isFilestoreItem()) { item.add(new Link("view", null) { - + private static final long serialVersionUID = 1L; @Override - public void onClick() { - - IResourceStream resourceStream = new AbstractResourceStreamWriter() { - + public void onClick() { + + IResourceStream resourceStream = new AbstractResourceStreamWriter() { + private static final long serialVersionUID = 1L; - @Override - public void write(OutputStream output) { - UserModel user = GitBlitWebSession.get().getUser(); - user = user == null ? UserModel.ANONYMOUS : user; - - app().filestore().downloadBlob(entry.getFilestoreOid(), user, getRepositoryModel(), output); - } - }; - - - getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream, entry.path)); - }}); - + @Override + public void write(OutputStream output) { + UserModel user = GitBlitWebSession.get().getUser(); + user = user == null ? UserModel.ANONYMOUS : user; + + app().filestore().downloadBlob(entry.getFilestoreOid(), user, + getRepositoryModel(), output); + } + }; + + ResourceStreamRequestHandler resourceStreamRequestHandler = new ResourceStreamRequestHandler( + resourceStream, entry.path); + getRequestCycle().scheduleRequestHandlerAfterCurrent(resourceStreamRequestHandler); + } + }); + item.add(new Link("raw", null) { - + private static final long serialVersionUID = 1L; @Override - public void onClick() { - - IResourceStream resourceStream = new AbstractResourceStreamWriter() { - + public void onClick() { + + IResourceStream resourceStream = new AbstractResourceStreamWriter() { + private static final long serialVersionUID = 1L; - @Override - public void write(OutputStream output) { - UserModel user = GitBlitWebSession.get().getUser(); - user = user == null ? UserModel.ANONYMOUS : user; - - app().filestore().downloadBlob(entry.getFilestoreOid(), user, getRepositoryModel(), output); - } - }; - - - getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream, entry.path)); - }}); - + @Override + public void write(OutputStream output) { + UserModel user = GitBlitWebSession.get().getUser(); + user = user == null ? UserModel.ANONYMOUS : user; + + app().filestore().downloadBlob(entry.getFilestoreOid(), user, + getRepositoryModel(), output); + } + }; + + ResourceStreamRequestHandler resourceStreamRequestHandler = new ResourceStreamRequestHandler( + resourceStream, entry.path); + getRequestCycle().scheduleRequestHandlerAfterCurrent(resourceStreamRequestHandler); + } + }); + } else { - item.add(new BookmarkablePageLink("view", BlobPage.class, WicketUtils - .newPathParameter(repositoryName, entry.commitId, entry.path)) - .setEnabled(!entry.changeType.equals(ChangeType.DELETE))); + item.add(new BookmarkablePageLink("view", BlobPage.class, + WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path)) + .setEnabled(!entry.changeType.equals(ChangeType.DELETE))); String rawUrl = RawServlet.asLink(getContextUrl(), repositoryName, entry.commitId, entry.path); item.add(new ExternalLink("raw", rawUrl) .setEnabled(!entry.changeType.equals(ChangeType.DELETE))); } - item.add(new BookmarkablePageLink("blame", BlamePage.class, WicketUtils - .newPathParameter(repositoryName, entry.commitId, entry.path)) - .setEnabled(!entry.changeType.equals(ChangeType.ADD) - && !entry.changeType.equals(ChangeType.DELETE))); - item.add(new BookmarkablePageLink("history", HistoryPage.class, WicketUtils - .newPathParameter(repositoryName, entry.commitId, entry.path)) - .setEnabled(!entry.changeType.equals(ChangeType.ADD))); + item.add(new BookmarkablePageLink("blame", BlamePage.class, + WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path)) + .setEnabled(!entry.changeType.equals(ChangeType.ADD) + && !entry.changeType.equals(ChangeType.DELETE))); + item.add(new BookmarkablePageLink("history", HistoryPage.class, + WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path)) + .setEnabled(!entry.changeType.equals(ChangeType.ADD))); } WicketUtils.setAlternatingBackground(item, counter); diff --git a/src/main/java/com/gitblit/wicket/pages/TicketsPage.java b/src/main/java/com/gitblit/wicket/pages/TicketsPage.java index ed0ed63e..15dfe0e8 100644 --- a/src/main/java/com/gitblit/wicket/pages/TicketsPage.java +++ b/src/main/java/com/gitblit/wicket/pages/TicketsPage.java @@ -27,6 +27,7 @@ import java.util.TreeSet; import org.apache.wicket.AttributeModifier; import org.apache.wicket.Component; import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.wicket.util.string.StringValue; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.link.BookmarkablePageLink; import org.apache.wicket.markup.html.panel.Fragment; @@ -87,7 +88,7 @@ public class TicketsPage extends RepositoryPage { UserModel user = GitBlitWebSession.get().getUser(); boolean isAuthenticated = user != null && user.isAuthenticated; - final String [] statiiParam = params.getStringArray(Lucene.status.name()); + final String [] statiiParam = (String[]) params.getValues(Lucene.status.name()).stream().map(StringValue::toString).toArray(); final String assignedToParam = params.get(Lucene.responsible.name()).toString(null); final String milestoneParam = params.get(Lucene.milestone.name()).toString(null); final String queryParam = params.get("q").toString(null); diff --git a/src/main/java/com/gitblit/wicket/pages/TreePage.java b/src/main/java/com/gitblit/wicket/pages/TreePage.java index c1adf6e1..79b7460e 100644 --- a/src/main/java/com/gitblit/wicket/pages/TreePage.java +++ b/src/main/java/com/gitblit/wicket/pages/TreePage.java @@ -18,6 +18,7 @@ package com.gitblit.wicket.pages; import java.io.OutputStream; import java.util.List; +import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler; import org.apache.wicket.request.mapper.parameter.PageParameters; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.link.BookmarkablePageLink; @@ -27,7 +28,6 @@ import org.apache.wicket.markup.html.panel.Fragment; import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.markup.repeater.data.DataView; import org.apache.wicket.markup.repeater.data.ListDataProvider; -//import org.apache.wicket.request.target.resource.ResourceStreamRequestTarget; import org.apache.wicket.util.resource.AbstractResourceStreamWriter; import org.apache.wicket.util.resource.IResourceStream; import org.eclipse.jgit.lib.FileMode; @@ -53,6 +53,8 @@ import com.gitblit.wicket.panels.PathBreadcrumbsPanel; @CacheControl(LastModified.BOOT) public class TreePage extends RepositoryPage { + private static final long serialVersionUID = 1L; + public TreePage(PageParameters params) { super(params); @@ -65,8 +67,8 @@ public class TreePage extends RepositoryPage { // tree page links add(new BookmarkablePageLink("historyLink", HistoryPage.class, WicketUtils.newPathParameter(repositoryName, objectId, path))); - add(new CompressedDownloadsPanel("compressedLinks", GitBlitRequestUtils - .getRelativePathPrefixToContextRoot(), repositoryName, objectId, path)); + add(new CompressedDownloadsPanel("compressedLinks", GitBlitRequestUtils.getRelativePathPrefixToContextRoot(), + repositoryName, objectId, path)); add(new CommitHeaderPanel("commitHeader", repositoryName, commit)); @@ -84,7 +86,7 @@ public class TreePage extends RepositoryPage { } final String id = getBestCommitId(commit); - + final ByteFormat byteFormat = new ByteFormat(); final String baseUrl = WicketUtils.getGitblitURL(getRequest()); @@ -97,10 +99,10 @@ public class TreePage extends RepositoryPage { @Override public void populateItem(final Item item) { final PathModel entry = item.getModelObject(); - + item.add(new Label("pathPermissions", JGitUtils.getPermissionsFromMode(entry.mode))); item.add(WicketUtils.setHtmlTooltip(new Label("filestore", ""), getString("gb.filestore")) - .setVisible(entry.isFilestoreItem())); + .setVisible(entry.isFilestoreItem())); if (entry.isParentPath) { // parent .. path @@ -115,19 +117,16 @@ public class TreePage extends RepositoryPage { item.add(WicketUtils.newImage("pathIcon", "folder_16x16.png")); item.add(new Label("pathSize", "")); item.add(new LinkPanel("pathName", "list", entry.name, TreePage.class, - WicketUtils.newPathParameter(repositoryName, id, - entry.path))); + WicketUtils.newPathParameter(repositoryName, id, entry.path))); // links Fragment links = new Fragment("pathLinks", "treeLinks", this); links.add(new BookmarkablePageLink("tree", TreePage.class, - WicketUtils.newPathParameter(repositoryName, id, - entry.path))); + WicketUtils.newPathParameter(repositoryName, id, entry.path))); links.add(new BookmarkablePageLink("history", HistoryPage.class, - WicketUtils.newPathParameter(repositoryName, id, - entry.path))); - links.add(new CompressedDownloadsPanel("compressedLinks", baseUrl, - repositoryName, objectId, entry.path)); + WicketUtils.newPathParameter(repositoryName, id, entry.path))); + links.add(new CompressedDownloadsPanel("compressedLinks", baseUrl, repositoryName, objectId, + entry.path)); item.add(links); } else if (entry.isSubmodule()) { @@ -141,21 +140,20 @@ public class TreePage extends RepositoryPage { item.add(WicketUtils.newImage("pathIcon", "git-orange-16x16.png")); item.add(new Label("pathSize", "")); - item.add(new LinkPanel("pathName", "list", entry.name + " @ " + - getShortObjectId(submoduleId), TreePage.class, - WicketUtils.newPathParameter(submodulePath, submoduleId, "")).setEnabled(hasSubmodule)); + item.add(new LinkPanel("pathName", "list", entry.name + " @ " + getShortObjectId(submoduleId), + TreePage.class, WicketUtils.newPathParameter(submodulePath, submoduleId, "")) + .setEnabled(hasSubmodule)); Fragment links = new Fragment("pathLinks", "submoduleLinks", this); links.add(new BookmarkablePageLink("view", SummaryPage.class, WicketUtils.newRepositoryParameter(submodulePath)).setEnabled(hasSubmodule)); links.add(new BookmarkablePageLink("tree", TreePage.class, - WicketUtils.newPathParameter(submodulePath, submoduleId, - "")).setEnabled(hasSubmodule)); + WicketUtils.newPathParameter(submodulePath, submoduleId, "")).setEnabled(hasSubmodule)); links.add(new BookmarkablePageLink("history", HistoryPage.class, - WicketUtils.newPathParameter(repositoryName, id, - entry.path))); - links.add(new CompressedDownloadsPanel("compressedLinks", baseUrl, - submodulePath, submoduleId, "").setEnabled(hasSubmodule)); + WicketUtils.newPathParameter(repositoryName, id, entry.path))); + links.add( + new CompressedDownloadsPanel("compressedLinks", baseUrl, submodulePath, submoduleId, "") + .setEnabled(hasSubmodule)); item.add(links); } else { // blob link @@ -167,101 +165,107 @@ public class TreePage extends RepositoryPage { } item.add(WicketUtils.getFileImage("pathIcon", entry.name)); item.add(new Label("pathSize", byteFormat.format(entry.size))); - + // links Fragment links = new Fragment("pathLinks", "blobLinks", this); - + if (entry.isFilestoreItem()) { item.add(new LinkPanel("pathName", "list", displayPath, new Link("link", null) { - + private static final long serialVersionUID = 1L; @Override - public void onClick() { - - IResourceStream resourceStream = new AbstractResourceStreamWriter() { - + public void onClick() { + + IResourceStream resourceStream = new AbstractResourceStreamWriter() { + private static final long serialVersionUID = 1L; - @Override - public void write(OutputStream output) { - UserModel user = GitBlitWebSession.get().getUser(); - user = user == null ? UserModel.ANONYMOUS : user; - - app().filestore().downloadBlob(entry.getFilestoreOid(), user, getRepositoryModel(), output); - } - }; - - - getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream, entry.path)); - }})); - + @Override + public void write(OutputStream output) { + UserModel user = GitBlitWebSession.get().getUser(); + user = user == null ? UserModel.ANONYMOUS : user; + + app().filestore().downloadBlob(entry.getFilestoreOid(), user, + getRepositoryModel(), output); + } + }; + + ResourceStreamRequestHandler resourceStreamRequestHandler = new ResourceStreamRequestHandler( + resourceStream, entry.path); + getRequestCycle().scheduleRequestHandlerAfterCurrent(resourceStreamRequestHandler); + + } + })); + links.add(new Link("view", null) { - + private static final long serialVersionUID = 1L; @Override - public void onClick() { - - IResourceStream resourceStream = new AbstractResourceStreamWriter() { - + public void onClick() { + + IResourceStream resourceStream = new AbstractResourceStreamWriter() { + private static final long serialVersionUID = 1L; - @Override - public void write(OutputStream output) { - UserModel user = GitBlitWebSession.get().getUser(); - user = user == null ? UserModel.ANONYMOUS : user; - - app().filestore().downloadBlob(entry.getFilestoreOid(), user, getRepositoryModel(), output); - } - }; - - - getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream, entry.path)); - }}); - + @Override + public void write(OutputStream output) { + UserModel user = GitBlitWebSession.get().getUser(); + user = user == null ? UserModel.ANONYMOUS : user; + + app().filestore().downloadBlob(entry.getFilestoreOid(), user, + getRepositoryModel(), output); + } + }; + + ResourceStreamRequestHandler resourceStreamRequestHandler = new ResourceStreamRequestHandler( + resourceStream, entry.path); + getRequestCycle().scheduleRequestHandlerAfterCurrent(resourceStreamRequestHandler); + } + }); + links.add(new Link("raw", null) { - + private static final long serialVersionUID = 1L; @Override - public void onClick() { - - IResourceStream resourceStream = new AbstractResourceStreamWriter() { - + public void onClick() { + + IResourceStream resourceStream = new AbstractResourceStreamWriter() { + private static final long serialVersionUID = 1L; - @Override - public void write(OutputStream output) { - UserModel user = GitBlitWebSession.get().getUser(); - user = user == null ? UserModel.ANONYMOUS : user; - - app().filestore().downloadBlob(entry.getFilestoreOid(), user, getRepositoryModel(), output); - } - }; - - - getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(resourceStream, entry.path)); - }}); - + @Override + public void write(OutputStream output) { + UserModel user = GitBlitWebSession.get().getUser(); + user = user == null ? UserModel.ANONYMOUS : user; + + app().filestore().downloadBlob(entry.getFilestoreOid(), user, + getRepositoryModel(), output); + } + }; + + ResourceStreamRequestHandler resourceStreamRequestHandler = new ResourceStreamRequestHandler( + resourceStream, entry.path); + getRequestCycle().scheduleRequestHandlerAfterCurrent(resourceStreamRequestHandler); + } + }); + } else { item.add(new LinkPanel("pathName", "list", displayPath, BlobPage.class, - WicketUtils.newPathParameter(repositoryName, id, - path))); - + WicketUtils.newPathParameter(repositoryName, id, path))); + links.add(new BookmarkablePageLink("view", BlobPage.class, - WicketUtils.newPathParameter(repositoryName, id, - path))); + WicketUtils.newPathParameter(repositoryName, id, path))); String rawUrl = RawServlet.asLink(getContextUrl(), repositoryName, id, path); links.add(new ExternalLink("raw", rawUrl)); } - + links.add(new BookmarkablePageLink("blame", BlamePage.class, - WicketUtils.newPathParameter(repositoryName, id, - path))); + WicketUtils.newPathParameter(repositoryName, id, path))); links.add(new BookmarkablePageLink("history", HistoryPage.class, - WicketUtils.newPathParameter(repositoryName, id, - path))); + WicketUtils.newPathParameter(repositoryName, id, path))); item.add(links); } } -- 2.39.5