use of org.apache.wicket.markup.html.pages.RedirectPage in project wicket by apache.
the class RestartResponseAtInterceptPageExceptionTest method newApplication.
@Override
protected WebApplication newApplication() {
return new MockApplication() {
@Override
protected void init() {
super.init();
getSecuritySettings().setAuthorizationStrategy(new AbstractPageAuthorizationStrategy() {
@Override
protected <T extends Page> boolean isPageAuthorized(Class<T> pageClass) {
if (pageClass != RedirectPage.class) {
RedirectPage intercept = new RedirectPage("http://example.com/path");
throw new RestartResponseAtInterceptPageException(intercept);
}
return true;
}
});
}
};
}
use of org.apache.wicket.markup.html.pages.RedirectPage in project gitblit by gitblit.
the class TicketPage method createDeletePatchsetLink.
private Link<Void> createDeletePatchsetLink(final RepositoryModel repositoryModel, final Patchset patchset) {
Link<Void> deleteLink = new Link<Void>("deleteRevision") {
private static final long serialVersionUID = 1L;
@Override
public void onClick() {
Repository r = app().repositories().getRepository(repositoryModel.name);
UserModel user = GitBlitWebSession.get().getUser();
if (r == null) {
if (app().repositories().isCollectingGarbage(repositoryModel.name)) {
error(MessageFormat.format(getString("gb.busyCollectingGarbage"), repositoryModel.name));
} else {
error(MessageFormat.format("Failed to find repository {0}", repositoryModel.name));
}
return;
}
// Construct the ref name based on the patchset
String ticketShard = String.format("%02d", ticket.number);
ticketShard = ticketShard.substring(ticketShard.length() - 2);
final String refName = String.format("%s%s/%d/%d", Constants.R_TICKETS_PATCHSETS, ticketShard, ticket.number, patchset.number);
Ref ref = null;
boolean success = true;
try {
ref = r.getRef(refName);
if (ref != null) {
success = JGitUtils.deleteBranchRef(r, ref.getName());
} else {
success = false;
}
if (success) {
// clear commit cache
CommitCache.instance().clear(repositoryModel.name, refName);
// optionally update reflog
if (RefLogUtils.hasRefLogBranch(r)) {
RefLogUtils.deleteRef(user, r, ref);
}
TicketModel updatedTicket = app().tickets().deletePatchset(ticket, patchset, user.username);
if (updatedTicket == null) {
success = false;
}
}
} catch (IOException e) {
logger().error("failed to determine ticket from ref", e);
success = false;
} finally {
r.close();
}
if (success) {
getSession().info(MessageFormat.format(getString("gb.deletePatchsetSuccess"), patchset.number));
logger().info(MessageFormat.format("{0} deleted patchset {1} from ticket {2}", user.username, patchset.number, ticket.number));
} else {
getSession().error(MessageFormat.format(getString("gb.deletePatchsetFailure"), patchset.number));
}
// Force reload of the page to rebuild ticket change cache
String relativeUrl = urlFor(TicketsPage.class, getPageParameters()).toString();
String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl);
setResponsePage(new RedirectPage(absoluteUrl));
}
};
WicketUtils.setHtmlTooltip(deleteLink, MessageFormat.format(getString("gb.deletePatchset"), patchset.number));
deleteLink.add(new JavascriptEventConfirmation("onclick", MessageFormat.format(getString("gb.deletePatchset"), patchset.number)));
return deleteLink;
}
Aggregations