commit | author | age
|
831469
|
1 |
/*
|
JM |
2 |
* Copyright 2011 gitblit.com.
|
|
3 |
*
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
6 |
* You may obtain a copy of the License at
|
|
7 |
*
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9 |
*
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13 |
* See the License for the specific language governing permissions and
|
|
14 |
* limitations under the License.
|
|
15 |
*/
|
|
16 |
package com.gitblit.wicket.pages;
|
|
17 |
|
|
18 |
import java.text.MessageFormat;
|
|
19 |
import java.util.ArrayList;
|
|
20 |
import java.util.List;
|
|
21 |
|
|
22 |
import org.apache.wicket.PageParameters;
|
|
23 |
import org.apache.wicket.markup.html.basic.Label;
|
|
24 |
|
|
25 |
import com.gitblit.Constants.FederationToken;
|
|
26 |
import com.gitblit.GitBlit;
|
|
27 |
import com.gitblit.Keys;
|
|
28 |
import com.gitblit.models.FederationProposal;
|
|
29 |
import com.gitblit.models.RepositoryModel;
|
|
30 |
import com.gitblit.utils.StringUtils;
|
|
31 |
import com.gitblit.wicket.RequiresAdminRole;
|
|
32 |
import com.gitblit.wicket.WicketUtils;
|
|
33 |
import com.gitblit.wicket.panels.RepositoriesPanel;
|
|
34 |
|
|
35 |
@RequiresAdminRole
|
d376ab
|
36 |
public class ReviewProposalPage extends RootSubPage {
|
831469
|
37 |
|
JM |
38 |
private final String PROPS_PATTERN = "{0} = {1}\n";
|
|
39 |
|
|
40 |
private final String WEBXML_PATTERN = "\n<context-param>\n\t<param-name>{0}</param-name>\n\t<param-value>{1}</param-value>\n</context-param>\n";
|
|
41 |
|
dd9ae7
|
42 |
public ReviewProposalPage(PageParameters params) {
|
831469
|
43 |
super(params);
|
JM |
44 |
|
|
45 |
final String token = WicketUtils.getToken(params);
|
|
46 |
|
|
47 |
FederationProposal proposal = GitBlit.self().getPendingFederationProposal(token);
|
|
48 |
if (proposal == null) {
|
6caa93
|
49 |
error(getString("gb.couldNotFindFederationProposal"), true);
|
831469
|
50 |
}
|
JM |
51 |
|
a7571b
|
52 |
setupPage(getString("gb.proposals"), proposal.url);
|
JM |
53 |
|
|
54 |
|
831469
|
55 |
add(new Label("url", proposal.url));
|
dd9ae7
|
56 |
add(new Label("message", proposal.message));
|
9adf62
|
57 |
add(WicketUtils.createTimestampLabel("received", proposal.received, getTimeZone(), getTimeUtils()));
|
831469
|
58 |
add(new Label("token", proposal.token));
|
dd9ae7
|
59 |
add(new Label("tokenType", proposal.tokenType.name()));
|
a7571b
|
60 |
|
831469
|
61 |
String p;
|
JM |
62 |
if (GitBlit.isGO()) {
|
|
63 |
// gitblit.properties definition
|
|
64 |
p = PROPS_PATTERN;
|
|
65 |
} else {
|
|
66 |
// web.xml definition
|
|
67 |
p = WEBXML_PATTERN;
|
|
68 |
}
|
|
69 |
|
|
70 |
// build proposed definition
|
|
71 |
StringBuilder sb = new StringBuilder();
|
|
72 |
sb.append(asParam(p, proposal.name, "url", proposal.url));
|
|
73 |
sb.append(asParam(p, proposal.name, "token", proposal.token));
|
|
74 |
|
|
75 |
if (FederationToken.USERS_AND_REPOSITORIES.equals(proposal.tokenType)
|
|
76 |
|| FederationToken.ALL.equals(proposal.tokenType)) {
|
|
77 |
sb.append(asParam(p, proposal.name, "mergeAccounts", "false"));
|
|
78 |
}
|
|
79 |
sb.append(asParam(p, proposal.name, "frequency",
|
|
80 |
GitBlit.getString(Keys.federation.defaultFrequency, "60 mins")));
|
|
81 |
sb.append(asParam(p, proposal.name, "folder", proposal.name));
|
d7fb20
|
82 |
sb.append(asParam(p, proposal.name, "bare", "true"));
|
2548a7
|
83 |
sb.append(asParam(p, proposal.name, "mirror", "true"));
|
831469
|
84 |
sb.append(asParam(p, proposal.name, "sendStatus", "true"));
|
JM |
85 |
sb.append(asParam(p, proposal.name, "notifyOnError", "true"));
|
|
86 |
sb.append(asParam(p, proposal.name, "exclude", ""));
|
|
87 |
sb.append(asParam(p, proposal.name, "include", ""));
|
|
88 |
|
|
89 |
add(new Label("definition", StringUtils.breakLinesForHtml(StringUtils.escapeForHtml(sb
|
|
90 |
.toString().trim(), true))).setEscapeModelStrings(false));
|
|
91 |
|
|
92 |
List<RepositoryModel> repositories = new ArrayList<RepositoryModel>(
|
|
93 |
proposal.repositories.values());
|
d376ab
|
94 |
RepositoriesPanel repositoriesPanel = new RepositoriesPanel("repositoriesPanel", false,
|
6662e3
|
95 |
false, repositories, false, getAccessRestrictions());
|
831469
|
96 |
add(repositoriesPanel);
|
JM |
97 |
}
|
|
98 |
|
|
99 |
private String asParam(String pattern, String name, String key, String value) {
|
|
100 |
return MessageFormat.format(pattern, Keys.federation._ROOT + "." + name + "." + key, value);
|
|
101 |
}
|
|
102 |
}
|