-
Notifications
You must be signed in to change notification settings - Fork 23
/
Definitions-selective-harvests.jsp
207 lines (194 loc) · 8.4 KB
/
Definitions-selective-harvests.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<%--
File: $Id$
Revision: $Revision$
Author: $Author$
Date: $Date$
The Netarchive Suite - Software to harvest and preserve websites
Copyright 2004-2018 The Royal Danish Library,
the National Library of France and the Austrian
National Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
--%><%--
This page is a summary page displaying a list of all selective harvests known to
the system.
Parameters:
flipactive=<definitionName>
If set, the harvest-definition with the given name is changed from active to
inactive or vice-versa.
--%>
<%@ page import="dk.netarkivet.common.utils.I18n,
dk.netarkivet.common.webinterface.HTMLUtils,
dk.netarkivet.common.webinterface.SiteSection,
dk.netarkivet.harvester.datamodel.HarvestDefinitionDAO,
dk.netarkivet.harvester.datamodel.SparsePartialHarvest,
dk.netarkivet.harvester.webinterface.Constants,
dk.netarkivet.harvester.webinterface.CookieUtils"
pageEncoding="UTF-8"
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"
%>
<fmt:setLocale value="<%=HTMLUtils.getLocale(request)%>" scope="page"
/><fmt:setBundle scope="page" basename="<%=dk.netarkivet.harvester.Constants.TRANSLATIONS_BUNDLE%>"/><%!
private static final I18n I18N = new I18n(dk.netarkivet.harvester.Constants.TRANSLATIONS_BUNDLE);
private static final String COMMANDWIDTH = "12%";
%><%
HTMLUtils.setUTF8(request);
HarvestDefinitionDAO dao = HarvestDefinitionDAO.getInstance();
String flipactive = request.getParameter(Constants.FLIPACTIVE_PARAM);
// Change activation if requested
if (flipactive != null) {
SparsePartialHarvest hd = dao.getSparsePartialHarvest(flipactive);
if (hd == null) {
HTMLUtils.forwardWithErrorMessage(pageContext, I18N,
"errormsg;harvestdefinition.0.does.not.exist",
flipactive);
return;
} else {
// disallow going to active mode, if no domainconfigurations
// associated with this harvestdefinition
if (!hd.isActive() && dao.getSparseDomainConfigurations(hd.getOid()).isEmpty()) {
HTMLUtils.forwardWithErrorMessage(pageContext, I18N,
"errormsg;harvestdefinition.0.cannot.be.activated;" + "no.domains.selected.for.harvesting",
hd.getName());
return;
}
dao.flipActive(hd);
response.sendRedirect("Definitions-selective-harvests.jsp");
return;
}
}
HTMLUtils.generateHeader(pageContext);
%>
<h3 class="page_heading"><fmt:message key="pagetitle;selective.harvests"/></h3>
<% String showInactiveDefinitionsParam =
CookieUtils.getParameterValue(request, Constants.SHOW_INACTIVE_PARAM);
boolean showInactiveHDs; // Default is 'true'.
if (showInactiveDefinitionsParam == null || showInactiveDefinitionsParam.isEmpty() ||
showInactiveDefinitionsParam.equals("true")) {
showInactiveHDs = true;
} else {
showInactiveHDs = false;
}
String flipShowHideInactiveLink = "Definitions-selective-harvests.jsp?" + Constants.SHOW_INACTIVE_PARAM
+ "=" + !showInactiveHDs;
CookieUtils.setCookie(response, Constants.SHOW_INACTIVE_PARAM, Boolean.toString(showInactiveHDs));
%>
<a href="<%=HTMLUtils.escapeHtmlValues(flipShowHideInactiveLink)%>">
<% if (showInactiveHDs) { %>
<fmt:message key="harvestdefinition.selective.hide.inactive"/>
<% } else { %>
<fmt:message key="harvestdefinition.selective.show.inactive"/>
<% } %>
</a>
<%
Iterable<SparsePartialHarvest> isph =
dao.getSparsePartialHarvestDefinitions(!showInactiveHDs);
if (!isph.iterator().hasNext()) { %>
<p>
<fmt:message key="harvestdefinition.selective.no.harvestdefinition"/>
<p>
<% } else { %>
<table class="selection_table" cols="6">
<tr>
<th><fmt:message key="harvestdefinition.selective.header.harvestdefinition"/></th>
<th><fmt:message key="harvestdefinition.selective.header.numberofruns"/></th>
<th><fmt:message key="harvestdefinition.selective.header.nextrun"/></th>
<th><fmt:message key="harvestdefinition.selective.header.status"/></th>
<th colspan="4"><fmt:message key="harvestdefinition.selective.header.commands"/></th>
</tr>
<%
// Build the HTML page
int rowCount = 0;
boolean inclHistory = SiteSection.isDeployed(Constants.HISTORY_SITESECTION_DIRNAME);
for (SparsePartialHarvest sph : isph) {
String name = sph.getName();
String editLink = "Definitions-edit-selective-harvest.jsp?" + Constants.HARVEST_PARAM + "="
+ HTMLUtils.encode(name);
String historicLink = "/History/Harveststatus-perhd.jsp?" + Constants.HARVEST_PARAM + "="
+ HTMLUtils.encode(name);
String seedsLink = "/History/Harveststatus-seeds.jsp?" + Constants.HARVEST_PARAM + "="
+ HTMLUtils.encode(name);
String isActive;
String flipActiveText;
if (sph.isActive()) {
isActive = I18N.getString(response.getLocale(), "active");
flipActiveText = I18N.getString(response.getLocale(), "deactivate");
} else {
isActive = I18N.getString(response.getLocale(), "inactive");
flipActiveText = I18N.getString(response.getLocale(), "activate");
}
String flipactiveLink
= "<a href=\"\" onclick=\"document.getElementById('flipActiveForm"
+ sph.getOid() + "').submit(); return false;\">"
+ HTMLUtils.escapeHtmlValues(flipActiveText)
+ "</a>";
%>
<tr class="<%=HTMLUtils.getRowClass(rowCount++)%>">
<td><%=HTMLUtils.escapeHtmlValues(name)%>
</td>
<td><%=sph.getNumEvents()%>
</td>
<td>
<% // Only output the date, if the HarvestDefinition is active
if (sph.isActive()) { %>
<%=HTMLUtils.parseDate(sph.getNextDate())%>
<% } else {
out.print(Constants.NoNextDate);
} %>
</td>
<td width="<%=COMMANDWIDTH%>"><%=HTMLUtils.escapeHtmlValues(isActive)%>
</td>
<td width="<%=COMMANDWIDTH%>">
<form
id="flipActiveForm<%=sph.getOid()%>"
action="Definitions-selective-harvests.jsp"
method="post"
><input
type="hidden"
name="<%=Constants.FLIPACTIVE_PARAM%>"
value="<%=HTMLUtils.escapeHtmlValues(sph.getName())%>"
/><%=flipactiveLink%>
</form>
</td>
<td width="<%=COMMANDWIDTH%>">
<a href="<%=HTMLUtils.escapeHtmlValues(editLink)%>">
<fmt:message key="edit"/>
</a>
</td>
<td width="<%=COMMANDWIDTH%>">
<a href="<%=HTMLUtils.escapeHtmlValues(seedsLink)%>">
<fmt:message key="harvestdefinition.linktext.seeds"/>
</a>
</td>
<td width="<%=COMMANDWIDTH%>">
<% if (inclHistory) { %>
<a href="<%=HTMLUtils.escapeHtmlValues(historicLink)%>">
<fmt:message key="harvestdefinition.linktext.historical"/></a>
<% } else { %>
<fmt:message key="harvestdefinition.linktext.no.historical"/>
<% } %>
</td>
</tr>
<%
} //for each harvest
%>
</table>
<%
} //else (if no harvest)
%>
<a href="Definitions-edit-selective-harvest.jsp?createnew=1">
<fmt:message key="create.new.selective.harvestdefinition"/>
</a>
<%
HTMLUtils.generateFooter(out);
%>