-
Notifications
You must be signed in to change notification settings - Fork 23
/
Definitions-find-domains.jsp
277 lines (241 loc) · 10.8 KB
/
Definitions-find-domains.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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
<%--
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 handles searching for domains. With no parameters, it
gives an input box for searching that feeds back into itself.
With parameter DOMAIN_QUERY_TYPE and DOMAIN_QUERY_STRING set, it performs a
search.
The DOMAIN_QUERY_STRING can be a glob pattern
(using ? and * only) or a single domain. If domains are found, they are
displayed, otherwise the message is given that there are no domains matching the query.
The search-system are now able to search in different fields of the 'domain' table
- name (the only search-option before),
- comments,
- crawlertraps
On the todo list are aliases, seeds. domainconfigurations,
--%><%@page import="java.util.List,
dk.netarkivet.common.CommonSettings,
dk.netarkivet.common.utils.I18n,
dk.netarkivet.common.utils.Settings, dk.netarkivet.common.webinterface.HTMLUtils,
dk.netarkivet.common.webinterface.SiteSection,
dk.netarkivet.harvester.webinterface.Constants,
dk.netarkivet.harvester.webinterface.DomainDefinition,
dk.netarkivet.harvester.webinterface.DomainSearchType"
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);
%><%
HTMLUtils.setUTF8(request);
String searchType = request.getParameter(Constants.DOMAIN_QUERY_TYPE_PARAM);
String searchQuery = request.getParameter(Constants.DOMAIN_QUERY_STRING_PARAM);
if (searchType == null) { // The default is NAME searchS
searchType = Constants.NAME_DOMAIN_SEARCH;
}
if (searchQuery != null && searchQuery.trim().length() > 0) {
// search field is not empty
searchQuery = searchQuery.trim();
List<String> matchingDomains = DomainDefinition.getDomains(
pageContext, I18N, searchQuery, searchType);
if (matchingDomains.isEmpty()) { // No matching domains
HTMLUtils.forwardWithErrorMessage(pageContext, I18N,
"errormsg;no.matching.domains.for.query.0.when.searching.by.1",
searchQuery, searchType);
return;
} else {
// Include navigate.js
HTMLUtils.generateHeader(pageContext, "navigateWithTwoParams.js");
%><h3 class="page_heading">
<fmt:message key="searching.for.0.gave.1.hits">
<fmt:param value="<%=searchQuery%>"/>
<fmt:param value="<%=matchingDomains.size()%>"/>
</fmt:message>
</h3>
<%
String startPage=request.getParameter(Constants.START_PAGE_PARAMETER);
if(startPage == null){
startPage="1";
}
long totalResultsCount = matchingDomains.size();
long pageSize = Long.parseLong(Settings.get(
CommonSettings.HARVEST_STATUS_DFT_PAGE_SIZE));
long actualPageSize = (pageSize == 0 ?
totalResultsCount : pageSize);
long startPageIndex = Long.parseLong(startPage);
long startIndex = 0;
long endIndex = 0;
if (totalResultsCount > 0) {
startIndex = ((startPageIndex - 1) * actualPageSize);
endIndex = Math.min(startIndex + actualPageSize ,
totalResultsCount);
}
boolean prevLinkActive = false;
if (pageSize != 0 && totalResultsCount > 0 && startIndex > 1) {
prevLinkActive = true;
}
boolean nextLinkActive = false;
if (pageSize != 0 && totalResultsCount > 0
&& endIndex < totalResultsCount) {
nextLinkActive = true;
}
%>
<fmt:message key="status.results.displayed">
<fmt:param><%=totalResultsCount%></fmt:param>
<fmt:param><%=startIndex+1%></fmt:param>
<fmt:param><%=endIndex%></fmt:param>
</fmt:message>
<%
String startPagePost=request.getParameter(Constants.START_PAGE_PARAMETER);
if(startPagePost == null){
startPagePost="1";
}
String searchqueryParam=request.getParameter(Constants.DOMAIN_QUERY_STRING_PARAM);
searchqueryParam = HTMLUtils.encode(searchqueryParam);
%>
<p style="text-align: right">
<fmt:message key="status.results.displayed.pagination">
<fmt:param>
<%
if (prevLinkActive) {
%>
<a href="javascript:previousPage('<%=Constants.DOMAIN_QUERY_STRING_PARAM%>','<%=searchqueryParam%>','<%=Constants.DOMAIN_QUERY_TYPE_PARAM%>','<%=searchType%>');">
<fmt:message
key="status.results.displayed.prevPage"/>
</a>
<%
} else {
%>
<fmt:message
key="status.results.displayed.prevPage"/>
<%
}
%>
</fmt:param>
<fmt:param>
<%
if (nextLinkActive) {
%>
<a href="javascript:nextPage('<%=Constants.DOMAIN_QUERY_STRING_PARAM%>','<%=searchqueryParam%>', '<%=Constants.DOMAIN_QUERY_TYPE_PARAM%>','<%=searchType%>');">
<fmt:message
key="status.results.displayed.nextPage"/>
</a>
<%
} else {
%>
<fmt:message key="status.results.displayed.nextPage"/>
<%
}
%>
</fmt:param>
</fmt:message>
</p>
<form method="post" name="filtersForm" action="Definitions-find-domains.jsp">
<input type="hidden" name="START_PAGE_INDEX" value="<%=startPagePost%>"/>
</form>
<%
List<String> matchingDomainsSubList = matchingDomains.
subList((int)startIndex,(int)endIndex);
int rowCount = 0;
if (matchingDomainsSubList.size() > 0) {
%>
<table class="selection_table">
<tr>
<th><fmt:message key="domain"/></th>
<th><fmt:message key="harvestdefinition.linktext.historical"/></th>
</tr>
<%
for (String domainS : matchingDomainsSubList) {
String encodedDomain = HTMLUtils.encode(domainS);
%>
<tr class="<%=HTMLUtils.getRowClass(rowCount++)%>">
<td>
<a href="Definitions-edit-domain.jsp?<%=
Constants.DOMAIN_PARAM%>=<%=
HTMLUtils.escapeHtmlValues(encodedDomain)%>"><%=
HTMLUtils.escapeHtmlValues(domainS)%>
</a>
</td>
<%
if (SiteSection.isDeployed("History")) {
String historyLink = "/History/Harveststatus-perdomain.jsp?domainName="
+ HTMLUtils.encode(domainS);
%>
<td><a href="<%=HTMLUtils.escapeHtmlValues(historyLink)%>">
<fmt:message key="harvestdefinition.linktext.historical"/></a>
</td>
<% } %>
</tr>
<%
}
%>
</table>
<%
}
HTMLUtils.generateFooter(out);
return;
}
}
//Note: This point is only reached if no name was sent to the JSP-page
HTMLUtils.generateHeader(pageContext);
%>
<h3 class="page_heading"><fmt:message key="pagetitle;find.domains"/></h3>
<form method="post" onclick="resetPagination();"
action="Definitions-find-domains.jsp">
<table>
<tr>
<td><fmt:message key="prompt;enter.domain.query"/></td>
<td><span id="focusElement">
<input name="<%=Constants.DOMAIN_QUERY_STRING_PARAM%>"
size="<%=Constants.DOMAIN_NAME_FIELD_SIZE %>" value=""/>
</span>
</td>
<td><fmt:message key="may.use.wildcards"/></td>
</tr>
<tr>
<!-- add selector for what kind of search to make -->
<td><fmt:message key="search.domains.by"/></td>
<td><select name="<%=Constants.DOMAIN_QUERY_TYPE_PARAM%>">
<%
for(DomainSearchType aSearchType: DomainSearchType.values()) {
String selected = "";
if (aSearchType.equals(DomainSearchType.NAME)) {
selected = "selected = \"selected\"";
}
%> <option value="<%=HTMLUtils.escapeHtmlValues(aSearchType.name())%>"<%=selected%>>
<fmt:message key="<%=HTMLUtils.escapeHtmlValues(aSearchType.getLocalizedKey())%>"/>
</option>
<%
}
%>
</select>
</td>
<td> </td>
</tr>
<tr>
<td colspan="3"><input type="submit" value="<fmt:message key="search"/>"/></td>
</tr>
</table>
</form>
<%
HTMLUtils.generateFooter(out);
%>