From d00a0ca46fcde3e3e580afea6a548b9c12aeac25 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Wed, 11 Jul 2012 17:18:02 -0400
Subject: [PATCH] Update to slf4j 1.6.6 and log4j 1.2.17
---
src/com/gitblit/wicket/pages/SendProposalPage.java | 55 ++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 40 insertions(+), 15 deletions(-)
diff --git a/src/com/gitblit/wicket/pages/SendProposalPage.java b/src/com/gitblit/wicket/pages/SendProposalPage.java
index adef0c5..aa9c03a 100644
--- a/src/com/gitblit/wicket/pages/SendProposalPage.java
+++ b/src/com/gitblit/wicket/pages/SendProposalPage.java
@@ -26,6 +26,7 @@
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.CompoundPropertyModel;
+import com.gitblit.Constants.FederationProposalResult;
import com.gitblit.GitBlit;
import com.gitblit.models.FederationProposal;
import com.gitblit.models.RepositoryModel;
@@ -36,7 +37,7 @@
import com.gitblit.wicket.panels.RepositoriesPanel;
@RequiresAdminRole
-public class SendProposalPage extends BasePage {
+public class SendProposalPage extends RootSubPage {
public String myUrl;
@@ -47,18 +48,18 @@
public SendProposalPage(PageParameters params) {
super(params);
- setupPage("", getString("gb.sendProposal"));
+ setupPage(getString("gb.sendProposal"), "");
setStatelessHint(true);
final String token = WicketUtils.getToken(params);
- myUrl = WicketUtils.getHostURL(getRequest());
+ myUrl = WicketUtils.getGitblitURL(getRequest());
destinationUrl = "https://";
// temporary proposal
FederationProposal proposal = GitBlit.self().createFederationProposal(myUrl, token);
if (proposal == null) {
- error("Could not create federation proposal!", true);
+ error(getString("gb.couldNotCreateFederationProposal"), true);
}
CompoundPropertyModel<SendProposalPage> model = new CompoundPropertyModel<SendProposalPage>(
@@ -71,30 +72,54 @@
protected void onSubmit() {
// confirm a repository name was entered
if (StringUtils.isEmpty(myUrl)) {
- error("Please enter your Gitblit url!");
+ error(getString("gb.pleaseSetGitblitUrl"));
return;
}
if (StringUtils.isEmpty(destinationUrl)) {
- error("Please enter a destination url for your proposal!");
+ error(getString("gb.pleaseSetDestinationUrl"));
return;
}
-
+
// build new proposal
FederationProposal proposal = GitBlit.self().createFederationProposal(myUrl, token);
proposal.url = myUrl;
proposal.message = message;
try {
- if (FederationUtils.propose(destinationUrl, proposal)) {
- info(MessageFormat.format("Proposal successfully received by {0}.", destinationUrl));
+ FederationProposalResult res = FederationUtils
+ .propose(destinationUrl, proposal);
+ switch (res) {
+ case ACCEPTED:
+ info(MessageFormat.format(getString("gb.proposalReceived"),
+ destinationUrl));
setResponsePage(RepositoriesPage.class);
- } else {
- error(MessageFormat.format("Sorry, {0} rejected your proposal.", destinationUrl));
+ break;
+ case NO_POKE:
+ error(MessageFormat.format(getString("noGitblitFound"),
+ destinationUrl, myUrl));
+ break;
+ case NO_PROPOSALS:
+ error(MessageFormat.format(getString("gb.noProposals"),
+ destinationUrl));
+ break;
+ case FEDERATION_DISABLED:
+ error(MessageFormat
+ .format(getString("gb.noFederation"),
+ destinationUrl));
+ break;
+ case MISSING_DATA:
+ error(MessageFormat.format(getString("gb.proposalFailed"),
+ destinationUrl));
+ break;
+ case ERROR:
+ error(MessageFormat.format(getString("gb.proposalError"),
+ destinationUrl));
+ break;
}
} catch (Exception e) {
if (!StringUtils.isEmpty(e.getMessage())) {
error(e.getMessage());
} else {
- error("Failed to send proposal!");
+ error(getString("gb.failedToSendProposal"));
}
}
}
@@ -111,7 +136,7 @@
@Override
public void onSubmit() {
- setResponsePage(RepositoriesPage.class);
+ setResponsePage(FederationPage.class);
}
};
cancel.setDefaultFormProcessing(false);
@@ -120,8 +145,8 @@
List<RepositoryModel> repositories = new ArrayList<RepositoryModel>(
proposal.repositories.values());
- RepositoriesPanel repositoriesPanel = new RepositoriesPanel("repositories", false,
- repositories, getAccessRestrictions());
+ RepositoriesPanel repositoriesPanel = new RepositoriesPanel("repositoriesPanel", false,
+ repositories, false, getAccessRestrictions());
add(repositoriesPanel);
}
}
--
Gitblit v1.9.1