forked from I2P_Developers/i2p.i2p
NamingService: Add export methods,
fill in subclass methods for efficient exporting, fill in getBase64Entires() and getNames() where unimplemented SusiDNS: Add export support, no UI yet
This commit is contained in:
@@ -42,6 +42,11 @@
|
||||
<url-pattern>/index</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>i2p.susi.dns.jsp.export_jsp</servlet-name>
|
||||
<url-pattern>/export</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<session-config>
|
||||
<session-timeout>
|
||||
30
|
||||
|
@@ -21,12 +21,15 @@
|
||||
|
||||
package i2p.susi.dns;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.SortedMap;
|
||||
|
||||
import net.i2p.client.naming.NamingService;
|
||||
import net.i2p.data.DataFormatException;
|
||||
@@ -196,7 +199,8 @@ public class NamingServiceBean extends AddressbookBean
|
||||
}
|
||||
}
|
||||
AddressBean array[] = list.toArray(new AddressBean[list.size()]);
|
||||
Arrays.sort( array, sorter );
|
||||
if (!(results instanceof SortedMap))
|
||||
Arrays.sort( array, sorter );
|
||||
entries = array;
|
||||
|
||||
message = generateLoadMessage();
|
||||
@@ -351,4 +355,21 @@ public class NamingServiceBean extends AddressbookBean
|
||||
rv.setProperties(outProps);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 0.9.20
|
||||
*/
|
||||
public void export(Writer out) throws IOException {
|
||||
Properties searchProps = new Properties();
|
||||
// only blockfile needs this
|
||||
searchProps.setProperty("list", getFileName());
|
||||
if (filter != null) {
|
||||
String startsAt = filter.equals("0-9") ? "[0-9]" : filter;
|
||||
searchProps.setProperty("startsWith", startsAt);
|
||||
}
|
||||
if (search != null && search.length() > 0)
|
||||
searchProps.setProperty("search", search.toLowerCase(Locale.US));
|
||||
getNamingService().export(out, searchProps);
|
||||
// No post-filtering for hosts.txt naming services. It is what it is.
|
||||
}
|
||||
}
|
||||
|
35
apps/susidns/src/jsp/export.jsp
Normal file
35
apps/susidns/src/jsp/export.jsp
Normal file
@@ -0,0 +1,35 @@
|
||||
<%
|
||||
/*
|
||||
* This file is part of susidns project, see http://susi.i2p/
|
||||
*
|
||||
* Copyright (C) 2005 <susi23@mail.i2p>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
// http://www.crazysquirrel.com/computing/general/form-encoding.jspx
|
||||
if (request.getCharacterEncoding() == null)
|
||||
request.setCharacterEncoding("UTF-8");
|
||||
%>
|
||||
<%@page pageEncoding="UTF-8"%>
|
||||
<%@page trimDirectiveWhitespaces="true"%>
|
||||
<%@ page contentType="text/plain"%>
|
||||
<jsp:useBean id="book" class="i2p.susi.dns.NamingServiceBean" scope="session" />
|
||||
<jsp:setProperty name="book" property="*" />
|
||||
<jsp:setProperty name="book" property="resetDeletionMarks" value="1"/>
|
||||
<%
|
||||
book.export(out);
|
||||
%>
|
Reference in New Issue
Block a user