From bc586ef3e273240806f13201f2055333481f01e2 Mon Sep 17 00:00:00 2001 From: Martin Spielmann Date: Sat, 30 Jul 2016 14:24:42 +0200 Subject: [PATCH] fixed last compile errors in pages --- .../com/gitblit/wicket/GitBlitWebApp.java | 3 +- .../com/gitblit/wicket/pages/BasePage.java | 37 ++++++++++++------- .../com/gitblit/wicket/pages/BlobPage.java | 6 +-- .../wicket/pages/ChangePasswordPage.java | 4 +- .../wicket/pages/EditRepositoryPage.java | 3 +- .../gitblit/wicket/pages/EditTeamPage.java | 1 - .../gitblit/wicket/pages/EditUserPage.java | 1 - .../wicket/pages/EmptyRepositoryPage.java | 2 + .../wicket/pages/ExportTicketPage.java | 23 +++++++----- .../wicket/pages/ImageDiffHandler.java | 9 ++--- .../com/gitblit/wicket/pages/LogoutPage.java | 1 - .../gitblit/wicket/pages/MyTicketsPage.java | 8 ++-- .../wicket/pages/NewRepositoryPage.java | 1 - .../com/gitblit/wicket/pages/RawPage.java | 22 +++++++---- .../com/gitblit/wicket/pages/RootSubPage.java | 3 +- .../com/gitblit/wicket/pages/UserPage.java | 1 - 16 files changed, 72 insertions(+), 53 deletions(-) diff --git a/src/main/java/com/gitblit/wicket/GitBlitWebApp.java b/src/main/java/com/gitblit/wicket/GitBlitWebApp.java index 34024911..662daa7b 100644 --- a/src/main/java/com/gitblit/wicket/GitBlitWebApp.java +++ b/src/main/java/com/gitblit/wicket/GitBlitWebApp.java @@ -21,7 +21,6 @@ import java.util.Locale; import java.util.Map; import java.util.TimeZone; -import org.apache.wicket.Application; import org.apache.wicket.RuntimeConfigurationType; import org.apache.wicket.Session; import org.apache.wicket.application.IClassResolver; @@ -284,7 +283,7 @@ public class GitBlitWebApp extends WebApplication implements GitblitWicketApp { } //TODO: check if needed with wichet-7 // mount(new GitblitParamUrlCodingStrategy(settings, xssFilter, location, clazz, parameters)); - mount(location, clazz, parameters); + mountPage(location, clazz); // map the mount point to the cache control definition diff --git a/src/main/java/com/gitblit/wicket/pages/BasePage.java b/src/main/java/com/gitblit/wicket/pages/BasePage.java index 06b6a6b8..887edac6 100644 --- a/src/main/java/com/gitblit/wicket/pages/BasePage.java +++ b/src/main/java/com/gitblit/wicket/pages/BasePage.java @@ -31,8 +31,6 @@ import java.util.Set; import java.util.TimeZone; import java.util.regex.Pattern; -import javax.servlet.http.HttpServletRequest; - import org.apache.commons.io.IOUtils; import org.apache.wicket.Application; import org.apache.wicket.Page; @@ -40,16 +38,14 @@ import org.apache.wicket.request.flow.RedirectToUrlException; import org.apache.wicket.request.http.WebResponse; import org.apache.wicket.request.http.handler.RedirectRequestHandler; import org.apache.wicket.request.mapper.parameter.PageParameters; -import org.apache.wicket.request.resource.CssPackageResource; +import org.apache.wicket.request.resource.CssResourceReference; import org.apache.wicket.request.resource.JavaScriptResourceReference; -import org.apache.wicket.markup.html.CSSPackageResource; +import org.apache.wicket.markup.head.CssHeaderItem; +import org.apache.wicket.markup.head.IHeaderResponse; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.link.ExternalLink; import org.apache.wicket.markup.html.panel.FeedbackPanel; -import org.apache.wicket.markup.html.resources.JavascriptResourceReference; import org.apache.wicket.markup.repeater.RepeatingView; -import org.apache.wicket.protocol.http.RequestUtils; -import org.apache.wicket.protocol.http.servlet.ServletWebRequest; import org.apache.wicket.util.time.Duration; import org.apache.wicket.util.time.Time; import org.slf4j.Logger; @@ -74,18 +70,20 @@ import com.gitblit.wicket.WicketUtils; public abstract class BasePage extends SessionPage { + private static final long serialVersionUID = 1L; + private transient Logger logger; private transient TimeUtils timeUtils; public BasePage() { super(); - customizeHeader(); +// customizeHeader(); } public BasePage(PageParameters params) { super(params); - customizeHeader(); +// customizeHeader(); } protected Logger logger() { @@ -95,12 +93,25 @@ public abstract class BasePage extends SessionPage { return logger; } - private void customizeHeader() { +// private void customizeHeader() { +// if (app().settings().getBoolean(Keys.web.useResponsiveLayout, true)) { +// add(CssPackageResource.getHeaderContribution("bootstrap/css/bootstrap-responsive.css")); +// } +// if (app().settings().getBoolean(Keys.web.hideHeader, false)) { +// add(CssPackageResource.getHeaderContribution("hideheader.css")); +// } +// } + + @Override + public void renderHead(IHeaderResponse response) { + super.renderHead(response); if (app().settings().getBoolean(Keys.web.useResponsiveLayout, true)) { - add(CssPackageResource.getHeaderContribution("bootstrap/css/bootstrap-responsive.css")); +// add(CssPackageResource.getHeaderContribution("bootstrap/css/bootstrap-responsive.css")); + response.render(CssHeaderItem.forReference(new CssResourceReference(Application.class, "bootstrap/css/bootstrap-responsive.css"))); } if (app().settings().getBoolean(Keys.web.hideHeader, false)) { - add(CssPackageResource.getHeaderContribution("hideheader.css")); +// add(CssPackageResource.getHeaderContribution("hideheader.css")); + response.render(CssHeaderItem.forReference(new CssResourceReference(Application.class, "hideheader.css"))); } } @@ -525,7 +536,7 @@ public abstract class BasePage extends SessionPage { protected void addBottomScript(String scriptPath) { RepeatingView bottomScripts = getBottomScriptContainer(); Label script = new Label(bottomScripts.newChildId(), "\n"); + + urlFor(new JavaScriptResourceReference(this.getClass(), scriptPath), null) + "'>\n"); bottomScripts.add(script.setEscapeModelStrings(false).setRenderBodyOnly(true)); } diff --git a/src/main/java/com/gitblit/wicket/pages/BlobPage.java b/src/main/java/com/gitblit/wicket/pages/BlobPage.java index a25068db..0c9bc626 100644 --- a/src/main/java/com/gitblit/wicket/pages/BlobPage.java +++ b/src/main/java/com/gitblit/wicket/pages/BlobPage.java @@ -127,7 +127,7 @@ public class BlobPage extends RepositoryPage { case 3: // binary blobs add(new Label("blobText", "Binary File")); - add(new Image("blobImage").setVisible(false)); + add(new Image("blobImage", "blobImage").setVisible(false)); break; default: // plain text @@ -140,7 +140,7 @@ public class BlobPage extends RepositoryPage { addBottomScriptInline("jQuery(prettyPrint);"); } add(new Label("blobText", table).setEscapeModelStrings(false)); - add(new Image("blobImage").setVisible(false)); + add(new Image("blobImage", "blobImage").setVisible(false)); fileExtension = extension; } } else { @@ -154,7 +154,7 @@ public class BlobPage extends RepositoryPage { addBottomScriptInline("jQuery(prettyPrint);"); } add(new Label("blobText", table).setEscapeModelStrings(false)); - add(new Image("blobImage").setVisible(false)); + add(new Image("blobImage", "blobImage").setVisible(false)); } } } diff --git a/src/main/java/com/gitblit/wicket/pages/ChangePasswordPage.java b/src/main/java/com/gitblit/wicket/pages/ChangePasswordPage.java index 8c91ac30..95850c63 100644 --- a/src/main/java/com/gitblit/wicket/pages/ChangePasswordPage.java +++ b/src/main/java/com/gitblit/wicket/pages/ChangePasswordPage.java @@ -33,6 +33,8 @@ import com.gitblit.wicket.NonTrimmedPasswordTextField; public class ChangePasswordPage extends RootSubPage { + private static final long serialVersionUID = 1L; + IModel password = new Model(""); IModel confirmPassword = new Model(""); @@ -106,7 +108,6 @@ public class ChangePasswordPage extends RootSubPage { error(e.getMessage()); return; } - setRedirect(false); info(getString("gb.passwordChanged")); setResponsePage(RepositoriesPage.class); } @@ -125,7 +126,6 @@ public class ChangePasswordPage extends RootSubPage { @Override public void onSubmit() { - setRedirect(false); error(getString("gb.passwordChangeAborted")); setResponsePage(RepositoriesPage.class); } diff --git a/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java index b7b3d817..355867b6 100644 --- a/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java +++ b/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java @@ -79,6 +79,8 @@ import com.gitblit.wicket.panels.TextOption; public class EditRepositoryPage extends RootSubPage { + private static final long serialVersionUID = 1L; + private final boolean isCreate; RepositoryNamePanel namePanel; @@ -388,7 +390,6 @@ public class EditRepositoryPage extends RootSubPage { error(e.getMessage()); return; } - setRedirect(false); setResponsePage(SummaryPage.class, WicketUtils.newRepositoryParameter(repositoryModel.name)); } }; diff --git a/src/main/java/com/gitblit/wicket/pages/EditTeamPage.java b/src/main/java/com/gitblit/wicket/pages/EditTeamPage.java index 8c735a5d..2346ce13 100644 --- a/src/main/java/com/gitblit/wicket/pages/EditTeamPage.java +++ b/src/main/java/com/gitblit/wicket/pages/EditTeamPage.java @@ -208,7 +208,6 @@ public class EditTeamPage extends RootSubPage { error(e.getMessage()); return; } - setRedirect(false); if (isCreate) { // create another team info(MessageFormat.format(getString("gb.teamCreated"), diff --git a/src/main/java/com/gitblit/wicket/pages/EditUserPage.java b/src/main/java/com/gitblit/wicket/pages/EditUserPage.java index af37af7f..9cdb4c95 100644 --- a/src/main/java/com/gitblit/wicket/pages/EditUserPage.java +++ b/src/main/java/com/gitblit/wicket/pages/EditUserPage.java @@ -203,7 +203,6 @@ public class EditUserPage extends RootSubPage { error(e.getMessage()); return; } - setRedirect(false); if (isCreate) { // create another user info(MessageFormat.format(getString("gb.userCreated"), diff --git a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java index 7c9a46b3..d1d77aa7 100644 --- a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java +++ b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java @@ -33,6 +33,8 @@ import com.gitblit.wicket.panels.RepositoryUrlPanel; public class EmptyRepositoryPage extends RepositoryPage { + private static final long serialVersionUID = 1L; + public EmptyRepositoryPage(PageParameters params) { super(params); diff --git a/src/main/java/com/gitblit/wicket/pages/ExportTicketPage.java b/src/main/java/com/gitblit/wicket/pages/ExportTicketPage.java index 3d63550b..c60f83a3 100644 --- a/src/main/java/com/gitblit/wicket/pages/ExportTicketPage.java +++ b/src/main/java/com/gitblit/wicket/pages/ExportTicketPage.java @@ -15,12 +15,10 @@ */ package com.gitblit.wicket.pages; -import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.IRequestCycle; +import org.apache.wicket.request.IRequestHandler; import org.apache.wicket.request.http.WebResponse; -//import org.apache.wicket.IRequestTarget; import org.apache.wicket.request.mapper.parameter.PageParameters; -//import org.apache.wicket.RequestCycle; -//import org.apache.wicket.protocol.http.WebResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,6 +30,8 @@ import com.gitblit.wicket.WicketUtils; public class ExportTicketPage extends SessionPage { + private static final long serialVersionUID = 1L; + private final Logger logger = LoggerFactory.getLogger(getClass().getSimpleName()); String contentType; @@ -44,13 +44,10 @@ public class ExportTicketPage extends SessionPage { redirectToInterceptPage(new RepositoriesPage()); } - getRequestCycle().setRequestTarget(new IRequestTarget() { - @Override - public void detach(RequestCycle requestCycle) { - } - + getRequestCycle().scheduleRequestHandlerAfterCurrent(new IRequestHandler() { + @Override - public void respond(RequestCycle requestCycle) { + public void respond(IRequestCycle requestCycle) { WebResponse response = (WebResponse) requestCycle.getResponse(); final String repositoryName = WicketUtils.getRepositoryName(params); @@ -71,6 +68,12 @@ public class ExportTicketPage extends SessionPage { logger.error("Failed to write text response", e); } } + + @Override + public void detach(IRequestCycle requestCycle) { + // TODO Auto-generated method stub + + } }); } diff --git a/src/main/java/com/gitblit/wicket/pages/ImageDiffHandler.java b/src/main/java/com/gitblit/wicket/pages/ImageDiffHandler.java index bdd33b9c..29e308d5 100644 --- a/src/main/java/com/gitblit/wicket/pages/ImageDiffHandler.java +++ b/src/main/java/com/gitblit/wicket/pages/ImageDiffHandler.java @@ -15,11 +15,10 @@ */ package com.gitblit.wicket.pages; -import java.nio.charset.StandardCharsets; import java.util.List; -import org.apache.wicket.protocol.http.WebApplication; -import org.apache.wicket.util.encoding.UrlDecoder; +import org.apache.wicket.request.Url; +import org.apache.wicket.request.cycle.RequestCycle; import org.apache.wicket.util.encoding.UrlEncoder; import org.eclipse.jgit.diff.DiffEntry; import org.eclipse.jgit.diff.DiffEntry.Side; @@ -147,8 +146,8 @@ public class ImageDiffHandler implements DiffUtils.BinaryDiffHandler { * Returns a URL that will fetch the designated static resource from within GitBlit. */ protected String getStaticResourceUrl(String contextRelativePath) { - return WebApplication.get().getRequestCycleProcessor().getRequestCodingStrategy().rewriteStaticRelativeUrl(contextRelativePath); - } + return RequestCycle.get().getUrlRenderer().renderFullUrl(Url.parse(contextRelativePath)); + } /** * Encode a URL component of a {@link RawServlet} URL in the special way that the servlet expects it. Note that diff --git a/src/main/java/com/gitblit/wicket/pages/LogoutPage.java b/src/main/java/com/gitblit/wicket/pages/LogoutPage.java index 92d3d623..e9f6bde3 100644 --- a/src/main/java/com/gitblit/wicket/pages/LogoutPage.java +++ b/src/main/java/com/gitblit/wicket/pages/LogoutPage.java @@ -42,7 +42,6 @@ public class LogoutPage extends BasePage { setupPage(null, getString("gb.logout")); } else { -// setRedirect(true); // setResponsePage(getApplication().getHomePage()); throw new RestartResponseException(getApplication().getHomePage()); } // not via WWW-Auth diff --git a/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java b/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java index a8fcb8a6..70ab1d2f 100644 --- a/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java +++ b/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java @@ -23,6 +23,7 @@ import java.util.HashMap; import java.util.List; 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.repeater.Item; @@ -56,7 +57,9 @@ import com.gitblit.wicket.panels.UserTitlePanel; */ public class MyTicketsPage extends RootPage { - public MyTicketsPage() { + private static final long serialVersionUID = 1L; + + public MyTicketsPage() { this(null); } @@ -66,14 +69,13 @@ public class MyTicketsPage extends RootPage { UserModel currentUser = GitBlitWebSession.get().getUser(); if (currentUser == null || UserModel.ANONYMOUS.equals(currentUser)) { - setRedirect(true); setResponsePage(getApplication().getHomePage()); return; } final String username = currentUser.getName(); - final String[] statiiParam = (params == null) ? TicketsUI.openStatii : params.getStringArray(Lucene.status.name()); + final String[] statiiParam = (params == null) ? TicketsUI.openStatii : (String[]) params.getValues(Lucene.status.name()).stream().map(StringValue::toString).toArray(); final String assignedToParam = (params == null) ? "" : params.get(Lucene.responsible.name()).toString(); final String milestoneParam = (params == null) ? "" : params.get(Lucene.milestone.name()).toString(); final String queryParam = (params == null) ? null : params.get("q").toString(); diff --git a/src/main/java/com/gitblit/wicket/pages/NewRepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/NewRepositoryPage.java index b9e9f871..bf897de3 100644 --- a/src/main/java/com/gitblit/wicket/pages/NewRepositoryPage.java +++ b/src/main/java/com/gitblit/wicket/pages/NewRepositoryPage.java @@ -145,7 +145,6 @@ public class NewRepositoryPage extends RootSubPage { error(e.getMessage()); return; } - setRedirect(true); setResponsePage(SummaryPage.class, WicketUtils.newRepositoryParameter(repositoryModel.name)); } }; diff --git a/src/main/java/com/gitblit/wicket/pages/RawPage.java b/src/main/java/com/gitblit/wicket/pages/RawPage.java index 10c98fcd..310d928b 100644 --- a/src/main/java/com/gitblit/wicket/pages/RawPage.java +++ b/src/main/java/com/gitblit/wicket/pages/RawPage.java @@ -24,8 +24,8 @@ import java.util.Map; import javax.servlet.http.HttpServletResponse; -import org.apache.wicket.request.cycle.RequestCycle; -import org.apache.wicket.request.http.WebRequest; +import org.apache.wicket.request.IRequestCycle; +import org.apache.wicket.request.IRequestHandler; import org.apache.wicket.request.http.WebResponse; import org.apache.wicket.request.http.flow.AbortWithHttpErrorCodeException; import org.apache.wicket.request.mapper.parameter.PageParameters; @@ -46,6 +46,8 @@ import com.gitblit.wicket.WicketUtils; public class RawPage extends SessionPage { + private static final long serialVersionUID = 1L; + private final Logger logger = LoggerFactory.getLogger(getClass().getSimpleName()); String contentType; @@ -58,13 +60,10 @@ public class RawPage extends SessionPage { redirectToInterceptPage(new RepositoriesPage()); } - getRequestCycle().setRequestTarget(new IRequestTarget() { - @Override - public void detach(RequestCycle requestCycle) { - } + getRequestCycle().scheduleRequestHandlerAfterCurrent(new IRequestHandler() { @Override - public void respond(RequestCycle requestCycle) { + public void respond(IRequestCycle requestCycle) { WebResponse response = (WebResponse) requestCycle.getResponse(); final String repositoryName = WicketUtils.getRepositoryName(params); @@ -173,7 +172,6 @@ public class RawPage extends SessionPage { response.setContentType(contentType); try { - WebRequest request = (WebRequest) requestCycle.getRequest(); String userAgent = GitBlitRequestUtils.getServletRequest().getHeader("User-Agent"); if (userAgent != null && userAgent.indexOf("MSIE 5.5") > -1) { @@ -233,7 +231,15 @@ public class RawPage extends SessionPage { } r.close(); } + + @Override + public void detach(IRequestCycle requestCycle) { + // TODO Auto-generated method stub + + } + }); + } @Override diff --git a/src/main/java/com/gitblit/wicket/pages/RootSubPage.java b/src/main/java/com/gitblit/wicket/pages/RootSubPage.java index 40ccfda9..76111dba 100644 --- a/src/main/java/com/gitblit/wicket/pages/RootSubPage.java +++ b/src/main/java/com/gitblit/wicket/pages/RootSubPage.java @@ -57,7 +57,8 @@ public abstract class RootSubPage extends RootPage { // Wicket seems to get confused as to when it really should // generate a page map for complex pages. Conditionally ensure we // have a page map for complex AJAX pages like the EditNNN pages. - Session.get().pageMapForName(null, true); + //TODO: check if no longer needed +// Session.get().pageMapForName(null, true); setVersioned(true); } } diff --git a/src/main/java/com/gitblit/wicket/pages/UserPage.java b/src/main/java/com/gitblit/wicket/pages/UserPage.java index 39235acb..284970ff 100644 --- a/src/main/java/com/gitblit/wicket/pages/UserPage.java +++ b/src/main/java/com/gitblit/wicket/pages/UserPage.java @@ -291,7 +291,6 @@ public class UserPage extends RootPage { try { app().gitblit().reviseUser(user.username, user); - setRedirect(true); setResponsePage(UserPage.class, WicketUtils.newUsernameParameter(user.username)); } catch (GitBlitException e) { // logger.error("Failed to update user " + user.username, e); -- 2.39.5