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.util.Collections;
|
|
19 |
import java.util.List;
|
|
20 |
|
|
21 |
import org.apache.wicket.PageParameters;
|
|
22 |
import org.apache.wicket.markup.html.basic.Label;
|
|
23 |
import org.apache.wicket.markup.repeater.Item;
|
|
24 |
import org.apache.wicket.markup.repeater.data.DataView;
|
|
25 |
import org.apache.wicket.markup.repeater.data.ListDataProvider;
|
|
26 |
|
|
27 |
import com.gitblit.GitBlit;
|
|
28 |
import com.gitblit.models.FederationModel;
|
|
29 |
import com.gitblit.models.FederationModel.RepositoryStatus;
|
|
30 |
import com.gitblit.wicket.WicketUtils;
|
|
31 |
|
d376ab
|
32 |
public class FederationRegistrationPage extends RootSubPage {
|
831469
|
33 |
|
JM |
34 |
public FederationRegistrationPage(PageParameters params) {
|
|
35 |
super(params);
|
d376ab
|
36 |
|
831469
|
37 |
setStatelessHint(true);
|
JM |
38 |
|
|
39 |
String url = WicketUtils.getUrlParameter(params);
|
|
40 |
String name = WicketUtils.getNameParameter(params);
|
|
41 |
|
|
42 |
FederationModel registration = GitBlit.self().getFederationRegistration(url, name);
|
|
43 |
if (registration == null) {
|
6caa93
|
44 |
error(getString("gb.couldNotFindFederationRegistration"), true);
|
831469
|
45 |
}
|
JM |
46 |
|
a7571b
|
47 |
setupPage(registration.isResultData() ? getString("gb.federationResults")
|
JM |
48 |
: getString("gb.federationRegistration"), registration.url);
|
dd9ae7
|
49 |
|
831469
|
50 |
add(new Label("url", registration.url));
|
JM |
51 |
add(WicketUtils.getRegistrationImage("typeIcon", registration, this));
|
|
52 |
add(new Label("frequency", registration.frequency));
|
|
53 |
add(new Label("folder", registration.folder));
|
|
54 |
add(new Label("token", showAdmin ? registration.token : "--"));
|
9adf62
|
55 |
add(WicketUtils.createTimestampLabel("lastPull", registration.lastPull, getTimeZone(), getTimeUtils()));
|
JM |
56 |
add(WicketUtils.createTimestampLabel("nextPull", registration.nextPull, getTimeZone(), getTimeUtils()));
|
831469
|
57 |
|
JM |
58 |
StringBuilder inclusions = new StringBuilder();
|
|
59 |
for (String inc : registration.inclusions) {
|
|
60 |
inclusions.append(inc).append("<br/>");
|
|
61 |
}
|
|
62 |
StringBuilder exclusions = new StringBuilder();
|
|
63 |
for (String ex : registration.exclusions) {
|
|
64 |
exclusions.append(ex).append("<br/>");
|
|
65 |
}
|
|
66 |
|
|
67 |
add(new Label("inclusions", inclusions.toString()).setEscapeModelStrings(false));
|
|
68 |
|
|
69 |
add(new Label("exclusions", exclusions.toString()).setEscapeModelStrings(false));
|
|
70 |
|
|
71 |
List<RepositoryStatus> list = registration.getStatusList();
|
|
72 |
Collections.sort(list);
|
|
73 |
DataView<RepositoryStatus> dataView = new DataView<RepositoryStatus>("row",
|
|
74 |
new ListDataProvider<RepositoryStatus>(list)) {
|
|
75 |
private static final long serialVersionUID = 1L;
|
|
76 |
private int counter;
|
|
77 |
|
|
78 |
@Override
|
|
79 |
protected void onBeforeRender() {
|
|
80 |
super.onBeforeRender();
|
|
81 |
counter = 0;
|
|
82 |
}
|
|
83 |
|
|
84 |
public void populateItem(final Item<RepositoryStatus> item) {
|
|
85 |
final RepositoryStatus entry = item.getModelObject();
|
|
86 |
item.add(WicketUtils.getPullStatusImage("statusIcon", entry.status));
|
|
87 |
item.add(new Label("name", entry.name));
|
|
88 |
item.add(new Label("status", entry.status.name()));
|
|
89 |
WicketUtils.setAlternatingBackground(item, counter);
|
|
90 |
counter++;
|
|
91 |
}
|
|
92 |
};
|
|
93 |
add(dataView);
|
|
94 |
}
|
|
95 |
}
|