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.Keys;
|
|
27 |
import com.gitblit.models.FederationProposal;
|
|
28 |
import com.gitblit.models.RepositoryModel;
|
|
29 |
import com.gitblit.utils.StringUtils;
|
|
30 |
import com.gitblit.wicket.RequiresAdminRole;
|
|
31 |
import com.gitblit.wicket.WicketUtils;
|
|
32 |
import com.gitblit.wicket.panels.RepositoriesPanel;
|
|
33 |
|
|
34 |
@RequiresAdminRole
|
d376ab
|
35 |
public class ReviewProposalPage extends RootSubPage {
|
831469
|
36 |
|
JM |
37 |
private final String PROPS_PATTERN = "{0} = {1}\n";
|
|
38 |
|
dd9ae7
|
39 |
public ReviewProposalPage(PageParameters params) {
|
831469
|
40 |
super(params);
|
JM |
41 |
|
|
42 |
final String token = WicketUtils.getToken(params);
|
|
43 |
|
99d0d4
|
44 |
FederationProposal proposal = app().federation().getPendingFederationProposal(token);
|
831469
|
45 |
if (proposal == null) {
|
6caa93
|
46 |
error(getString("gb.couldNotFindFederationProposal"), true);
|
831469
|
47 |
}
|
JM |
48 |
|
a7571b
|
49 |
setupPage(getString("gb.proposals"), proposal.url);
|
699e71
|
50 |
|
a7571b
|
51 |
|
831469
|
52 |
add(new Label("url", proposal.url));
|
dd9ae7
|
53 |
add(new Label("message", proposal.message));
|
9adf62
|
54 |
add(WicketUtils.createTimestampLabel("received", proposal.received, getTimeZone(), getTimeUtils()));
|
831469
|
55 |
add(new Label("token", proposal.token));
|
dd9ae7
|
56 |
add(new Label("tokenType", proposal.tokenType.name()));
|
699e71
|
57 |
|
99d0d4
|
58 |
String p = PROPS_PATTERN;
|
831469
|
59 |
|
JM |
60 |
// build proposed definition
|
|
61 |
StringBuilder sb = new StringBuilder();
|
|
62 |
sb.append(asParam(p, proposal.name, "url", proposal.url));
|
|
63 |
sb.append(asParam(p, proposal.name, "token", proposal.token));
|
|
64 |
|
|
65 |
if (FederationToken.USERS_AND_REPOSITORIES.equals(proposal.tokenType)
|
|
66 |
|| FederationToken.ALL.equals(proposal.tokenType)) {
|
|
67 |
sb.append(asParam(p, proposal.name, "mergeAccounts", "false"));
|
|
68 |
}
|
|
69 |
sb.append(asParam(p, proposal.name, "frequency",
|
99d0d4
|
70 |
app().settings().getString(Keys.federation.defaultFrequency, "60 mins")));
|
831469
|
71 |
sb.append(asParam(p, proposal.name, "folder", proposal.name));
|
d7fb20
|
72 |
sb.append(asParam(p, proposal.name, "bare", "true"));
|
2548a7
|
73 |
sb.append(asParam(p, proposal.name, "mirror", "true"));
|
831469
|
74 |
sb.append(asParam(p, proposal.name, "sendStatus", "true"));
|
JM |
75 |
sb.append(asParam(p, proposal.name, "notifyOnError", "true"));
|
|
76 |
sb.append(asParam(p, proposal.name, "exclude", ""));
|
|
77 |
sb.append(asParam(p, proposal.name, "include", ""));
|
|
78 |
|
310a80
|
79 |
final int tabLength = app().settings().getInteger(Keys.web.tabLength, 4);
|
831469
|
80 |
add(new Label("definition", StringUtils.breakLinesForHtml(StringUtils.escapeForHtml(sb
|
310a80
|
81 |
.toString().trim(), true, tabLength))).setEscapeModelStrings(false));
|
831469
|
82 |
|
JM |
83 |
List<RepositoryModel> repositories = new ArrayList<RepositoryModel>(
|
|
84 |
proposal.repositories.values());
|
d376ab
|
85 |
RepositoriesPanel repositoriesPanel = new RepositoriesPanel("repositoriesPanel", false,
|
6662e3
|
86 |
false, repositories, false, getAccessRestrictions());
|
831469
|
87 |
add(repositoriesPanel);
|
JM |
88 |
}
|
|
89 |
|
|
90 |
private String asParam(String pattern, String name, String key, String value) {
|
|
91 |
return MessageFormat.format(pattern, Keys.federation._ROOT + "." + name + "." + key, value);
|
|
92 |
}
|
|
93 |
}
|