diff --git a/pom.xml b/pom.xml
index b44ece2..3a6af6b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
mx.nic.labs.reddog
rdap-server
- 1.4.2
+ 1.4.3
war
mx.nic.labs.reddog:rdap-server
diff --git a/src/main/java/mx/nic/rdap/server/notices/NoticesUpdaterTask.java b/src/main/java/mx/nic/rdap/server/notices/NoticesUpdaterTask.java
index 04f8c4a..d122535 100644
--- a/src/main/java/mx/nic/rdap/server/notices/NoticesUpdaterTask.java
+++ b/src/main/java/mx/nic/rdap/server/notices/NoticesUpdaterTask.java
@@ -7,6 +7,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
+import java.util.ArrayList;
import java.util.List;
import java.util.TimerTask;
import java.util.logging.Level;
@@ -42,9 +43,18 @@ public void run() {
private void checkForUpdate(String fileName, ResultType type) {
Path updated = Paths.get(userPath, fileName + RequestNotices.UPDATED_EXTENSION);
- List updatedNotices;
+ List parsedNotices;
+ List updatedNotices = new ArrayList();
+ List updatedHostNotices = new ArrayList();
try {
- updatedNotices = NoticesReader.parseNoticesXML(updated.toString());
+ parsedNotices = NoticesReader.parseNoticesXML(updated.toString());
+
+ UserNotices.splitHostLinks(parsedNotices, updatedNotices, updatedHostNotices);
+
+ if (updatedHostNotices.isEmpty()) {
+ updatedHostNotices = null;
+ }
+
} catch (NoSuchFileException | FileNotFoundException e) {
return;
} catch (SAXException | ParserConfigurationException | IOException e) {
@@ -67,7 +77,7 @@ private void checkForUpdate(String fileName, ResultType type) {
return;
}
- RequestNotices.updateNotices(type, updatedNotices);
+ RequestNotices.updateNotices(type, updatedNotices, updatedHostNotices);
}
}
diff --git a/src/main/java/mx/nic/rdap/server/notices/RequestNotices.java b/src/main/java/mx/nic/rdap/server/notices/RequestNotices.java
index 7d4c7f0..b41cffd 100644
--- a/src/main/java/mx/nic/rdap/server/notices/RequestNotices.java
+++ b/src/main/java/mx/nic/rdap/server/notices/RequestNotices.java
@@ -35,26 +35,32 @@ public class RequestNotices {
private static List autnumNotices;
private static List ipNotices;
+ private static List domainHostNotices;
+ private static List entityHostNotices;
+ private static List nsHostNotices;
+ private static List autnumHostNotices;
+ private static List ipHostNotices;
+
private static ReadWriteLock lock;
- public static List getDomainNotices() {
- return getNotices(ResultType.DOMAIN);
+ public static List getDomainNotices(String header) {
+ return getNotices(ResultType.DOMAIN, header);
}
- public static List getEntityNotices() {
- return getNotices(ResultType.ENTITY);
+ public static List getEntityNotices(String header) {
+ return getNotices(ResultType.ENTITY, header);
}
- public static List getAutnumNotices() {
- return getNotices(ResultType.AUTNUM);
+ public static List getAutnumNotices(String header) {
+ return getNotices(ResultType.AUTNUM, header);
}
- public static List getNsNotices() {
- return getNotices(ResultType.NAMESERVER);
+ public static List getNsNotices(String header) {
+ return getNotices(ResultType.NAMESERVER, header);
}
- public static List getIpNotices() {
- return getNotices(ResultType.IP);
+ public static List getIpNotices(String header) {
+ return getNotices(ResultType.IP, header);
}
/**
@@ -71,6 +77,18 @@ static void init(String userPath) throws SAXException, IOException, ParserConfig
try {
domainNotices = NoticesReader.parseNoticesXML(Paths.get(userPath, DOMAIN_FILE_NAME).toString());
+
+ List normalList = new ArrayList();
+ List hostList = new ArrayList();
+
+ UserNotices.splitHostLinks(domainNotices, normalList, hostList);
+
+ if (hostList.isEmpty()) {
+ hostList = null;
+ }
+
+ domainNotices = normalList;
+ domainHostNotices = hostList;
} catch (FileNotFoundException | NoSuchFileException e) {
// Nothing happens, continue
logger.log(Level.INFO,
@@ -79,6 +97,19 @@ static void init(String userPath) throws SAXException, IOException, ParserConfig
try {
entityNotices = NoticesReader.parseNoticesXML(Paths.get(userPath, ENTITY_FILE_NAME).toString());
+
+ List normalList = new ArrayList();
+ List hostList = new ArrayList();
+
+ UserNotices.splitHostLinks(entityNotices, normalList, hostList);
+
+ if (hostList.isEmpty()) {
+ hostList = null;
+ }
+
+ entityNotices = normalList;
+ entityHostNotices = hostList;
+
} catch (FileNotFoundException | NoSuchFileException e) {
// Nothing happens, continue
logger.log(Level.INFO, "Optional File '" + ENTITY_FILE_NAME + "' not found, continue. \n\t" + e);
@@ -86,6 +117,19 @@ static void init(String userPath) throws SAXException, IOException, ParserConfig
try {
nsNotices = NoticesReader.parseNoticesXML(Paths.get(userPath, NS_FILE_NAME).toString());
+
+ List normalList = new ArrayList();
+ List hostList = new ArrayList();
+
+ UserNotices.splitHostLinks(nsNotices, normalList, hostList);
+
+ if (hostList.isEmpty()) {
+ hostList = null;
+ }
+
+ nsNotices = normalList;
+ nsHostNotices = hostList;
+
} catch (FileNotFoundException | NoSuchFileException e) {
// Nothing happens, continue
logger.log(Level.INFO, "Optional File '" + NS_FILE_NAME + "' not found, continue. \n\t" + e);
@@ -93,6 +137,18 @@ static void init(String userPath) throws SAXException, IOException, ParserConfig
try {
autnumNotices = NoticesReader.parseNoticesXML(Paths.get(userPath, AUTNUM_FILE_NAME).toString());
+
+ List normalList = new ArrayList();
+ List hostList = new ArrayList();
+
+ UserNotices.splitHostLinks(autnumNotices, normalList, hostList);
+
+ if (hostList.isEmpty()) {
+ hostList = null;
+ }
+
+ autnumNotices = normalList;
+ autnumHostNotices = hostList;
} catch (FileNotFoundException | NoSuchFileException e) {
// Nothing happens, continue
logger.log(Level.INFO, "Optional File '" + AUTNUM_FILE_NAME + "' not found, continue. \n\t" + e);
@@ -100,20 +156,33 @@ static void init(String userPath) throws SAXException, IOException, ParserConfig
try {
ipNotices = NoticesReader.parseNoticesXML(Paths.get(userPath, IP_NETWORK_FILE_NAME).toString());
+
+ List normalList = new ArrayList();
+ List hostList = new ArrayList();
+
+ UserNotices.splitHostLinks(ipNotices, normalList, hostList);
+
+ if (hostList.isEmpty()) {
+ hostList = null;
+ }
+
+ ipNotices = normalList;
+ ipHostNotices = hostList;
} catch (FileNotFoundException | NoSuchFileException e) {
// Nothing happens, continue
logger.log(Level.INFO,
"Optional File '" + IP_NETWORK_FILE_NAME + "' not found, continue. \n\t" + e);
}
- if (RdapConfiguration.getNoticesUpdateTime() > 0) {
+ if (RdapConfiguration.getNoticesUpdateTime() >= UserNotices.MIN_TIMER_TIME) {
lock = new ReentrantReadWriteLock();
}
}
- private static List getNotices(ResultType type) {
+ private static List getNotices(ResultType type, String header) {
List notices = null;
+ List hostNotices = null;
List result = null;
if (lock != null) {
lock.readLock().lock();
@@ -123,38 +192,51 @@ private static List getNotices(ResultType type) {
switch (type) {
case DOMAIN :
notices = domainNotices;
+ hostNotices = domainHostNotices;
break;
case ENTITY :
notices = entityNotices;
+ hostNotices = entityHostNotices;
break;
case AUTNUM :
notices = autnumNotices;
+ hostNotices = autnumHostNotices;
break;
case IP :
notices = ipNotices;
+ hostNotices = ipHostNotices;
break;
case NAMESERVER :
notices = nsNotices;
+ hostNotices = nsHostNotices;
break;
default :
notices = null;
}
- if (notices != null) {
- result = new ArrayList<>(notices);
- }
- notices = null;
} finally {
if (lock != null) {
lock.readLock().unlock();
}
}
+ if (notices != null) {
+ result = new ArrayList<>(notices);
+ notices = null;
+ }
+
+ if (hostNotices != null) {
+ if (result == null)
+ result = new ArrayList();
+
+ UserNotices.appendRemarkWithPatternHost(result, hostNotices, header);
+ }
+
return result;
}
- public static void updateNotices(ResultType type, List updatedNotices) {
+ public static void updateNotices(ResultType type, List updatedNotices, List updatedHostNotices) {
if (lock != null) {
lock.writeLock().lock();
}
@@ -162,18 +244,23 @@ public static void updateNotices(ResultType type, List updatedNotices) {
switch (type) {
case DOMAIN :
domainNotices = updatedNotices;
+ domainHostNotices = updatedHostNotices;
break;
case ENTITY :
entityNotices = updatedNotices;
+ entityHostNotices = updatedHostNotices;
break;
case AUTNUM :
autnumNotices = updatedNotices;
+ autnumHostNotices = updatedHostNotices;
break;
case IP :
ipNotices = updatedNotices;
+ ipHostNotices = updatedHostNotices;
break;
case NAMESERVER :
nsNotices = updatedNotices;
+ nsHostNotices = updatedHostNotices;
break;
default :
break;
diff --git a/src/main/java/mx/nic/rdap/server/notices/UserNotices.java b/src/main/java/mx/nic/rdap/server/notices/UserNotices.java
index 9dfc8f9..03ded4d 100644
--- a/src/main/java/mx/nic/rdap/server/notices/UserNotices.java
+++ b/src/main/java/mx/nic/rdap/server/notices/UserNotices.java
@@ -15,6 +15,7 @@
import org.xml.sax.SAXException;
+import mx.nic.rdap.core.db.Link;
import mx.nic.rdap.core.db.Remark;
import mx.nic.rdap.core.db.RemarkDescription;
import mx.nic.rdap.db.exception.InitializationException;
@@ -27,7 +28,7 @@
public class UserNotices {
private static Logger logger = Logger.getLogger(UserNotices.class.getName());
-
+
// XML file names
private static final String HELP_FILE_NAME = "help.xml";
private static final String TOS_FILE_NAME = "tos.xml";
@@ -39,19 +40,52 @@ public class UserNotices {
private static List tos;
private static List notices;
+ private static List helpWithHost;
+ private static List tosWithHost;
+ private static List noticesWithHost;
+
private static boolean isTimerActive = false;
private static boolean isRdapDefaultPath;
+ static String hostLinkPattern = "${host}";
+
+ static void splitHostLinks(List original, List normalList, List hostList) {
+ boolean found = false;
+ for (Remark r : original) {
+ for (Link l : r.getLinks()) {
+ String value = l.getHref();
+ int indexOf = value.indexOf(hostLinkPattern);
+ if (indexOf >= 0) {
+ hostList.add(r);
+ found = true;
+ break;
+ }
+ indexOf = l.getValue().indexOf(hostLinkPattern);
+ if (indexOf >= 0) {
+ hostList.add(r);
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ normalList.add(r);
+ }
+
+ found = false;
+ }
+
+ return;
+ }
+
/**
* Reads the XML files and stores the information from the XML.
*
- * @param userPath
- * User path that contains the xml files.
- * @throws SAXException
- * When the XML file content has an invalid format.
- * @throws IOException
- * Problems reading the XML file.
- * @throws InitializationException
+ * @param userPath User path that contains the xml files.
+ * @throws SAXException When the XML file content has an invalid
+ * format.
+ * @throws IOException Problems reading the XML file.
+ * @throws InitializationException
*/
public static void init(String userPath, boolean isDefaultPath)
throws SAXException, IOException, ParserConfigurationException, InitializationException {
@@ -59,11 +93,24 @@ public static void init(String userPath, boolean isDefaultPath)
try {
help = NoticesReader.parseHelpXML(Paths.get(userPath, HELP_FILE_NAME).toString());
+
+ List tmp = new ArrayList();
+ List tmpWithHost = new ArrayList();
+
+ splitHostLinks(help, tmp, tmpWithHost);
+
+ if (tmpWithHost.isEmpty()) {
+ tmpWithHost = null;
+ }
+
+ help = tmp;
+ helpWithHost = tmpWithHost;
+
} catch (FileNotFoundException | NoSuchFileException e) {
// Nothing happens, continue
logger.log(Level.WARNING, "Optional File '" + HELP_FILE_NAME + "' not found, it is recommended to provide "
+ "a help file , continue. \n\t" + e);
-
+
help = new ArrayList();
Remark r = new Remark();
r.setTitle("Example Help");
@@ -75,13 +122,25 @@ public static void init(String userPath, boolean isDefaultPath)
rd1.setDescription("Contact the administrator to provide a help file.");
lrd.add(rd);
lrd.add(rd1);
-
+
help.add(r);
}
// The terms of service are optional.
try {
tos = NoticesReader.parseTOSXML(Paths.get(userPath, TOS_FILE_NAME).toString());
+
+ List tmp = new ArrayList();
+ List tmpWithHost = new ArrayList();
+
+ splitHostLinks(tos, tmp, tmpWithHost);
+
+ if (tmpWithHost.isEmpty()) {
+ tmpWithHost = null;
+ }
+
+ tos = tmp;
+ tosWithHost = tmpWithHost;
} catch (FileNotFoundException | NoSuchFileException e) {
// Nothing happens, continue
logger.log(Level.INFO, "Optional File '" + TOS_FILE_NAME + "' not found, continue. \n\t" + e);
@@ -90,6 +149,19 @@ public static void init(String userPath, boolean isDefaultPath)
// The notices are optional.
try {
notices = NoticesReader.parseNoticesXML(Paths.get(userPath, NOTICES_FILE_NAME).toString());
+
+ List tmp = new ArrayList();
+ List tmpWithHost = new ArrayList();
+
+ splitHostLinks(notices, tmp, tmpWithHost);
+
+ if (tmpWithHost.isEmpty()) {
+ tmpWithHost = null;
+ }
+
+ notices = tmp;
+ noticesWithHost = tmpWithHost;
+
} catch (FileNotFoundException | NoSuchFileException e) {
// Nothing happens, continue
logger.log(Level.INFO, "Optional File '" + NOTICES_FILE_NAME + "' not found, continue. \n\t" + e);
@@ -113,13 +185,13 @@ public static synchronized void createTimerSchema(String userPath) {
return;
}
- //Check if the files can be update.
+ // Check if the files can be update.
String realPath = RdapInitializer.getServletContext().getRealPath("/");
if (realPath == null) {
logger.log(Level.WARNING, "Can't read the path of WEB-INF, notices and event timers will not work");
return;
- }
-
+ }
+
// If for some reason this function is called two or more times, we
// don't want to create lot of timers.
if (isTimerActive) {
@@ -134,33 +206,96 @@ public static synchronized void createTimerSchema(String userPath) {
timer.schedule(task, millis, millis);
logger.log(Level.INFO, "Notices updater is active");
}
-
+
if (userEventsTimer >= MIN_TIMER_TIME) {
EventsUpdaterTask task = new EventsUpdaterTask(userPath);
long millis = TimeUnit.SECONDS.toMillis(noticesTimerUpdate);
timer.schedule(task, millis, millis);
-
+
logger.log(Level.INFO, "Events updater is active");
}
isTimerActive = true;
}
- public static List getHelp() {
- return help;
+ static String replaceHostPattern(String header, String toReplace) {
+ if (toReplace == null || toReplace.isEmpty()) {
+ return toReplace;
+ }
+
+ String valueResult = toReplace;
+ int indexOf = toReplace.indexOf(hostLinkPattern);
+ if (indexOf >= 0) {
+ StringBuilder sb = new StringBuilder(toReplace);
+ sb.delete(indexOf, indexOf + hostLinkPattern.length());
+ sb.insert(indexOf, header);
+ valueResult = sb.toString();
+// valueResult = header + toReplace.substring(indexOf + hostLinkPattern.length());
+ }
+ return valueResult;
}
- public static List getTos() {
- return tos;
+ static void appendRemarkWithPatternHost(List result, List listWithHost, String header) {
+ for (Remark r : listWithHost) {
+ Remark clone = new Remark();
+ clone.setDescriptions(r.getDescriptions());
+ clone.setLanguage(r.getLanguage());
+ clone.setTitle(r.getTitle());
+ clone.setType(r.getType());
+
+ for (Link l : r.getLinks()) {
+ Link cl = new Link();
+ cl.setHreflang(l.getHreflang());
+ cl.setMedia(l.getMedia());
+ cl.setRel(l.getRel());
+ cl.setTitle(l.getTitle());
+ cl.setType(l.getType());
+
+ cl.setHref(replaceHostPattern(header, l.getHref()));
+ cl.setValue(replaceHostPattern(header, l.getValue()));
+
+ clone.getLinks().add(cl);
+ }
+
+ result.add(clone);
+ }
}
- public static List getNotices() {
- return notices;
+ public static List getHelp(String header) {
+ if (helpWithHost == null)
+ return help;
+
+ List result = new ArrayList(help);
+
+ appendRemarkWithPatternHost(result, helpWithHost, header);
+
+ return result;
+ }
+
+ public static List getTos(String header) {
+ if (tosWithHost == null)
+ return tos;
+
+ List result = new ArrayList(tos);
+
+ appendRemarkWithPatternHost(result, tosWithHost, header);
+
+ return result;
}
-
+
+ public static List getNotices(String header) {
+ if (noticesWithHost == null)
+ return notices;
+
+ List result = new ArrayList(notices);
+
+ appendRemarkWithPatternHost(result, noticesWithHost, header);
+
+ return result;
+ }
+
static boolean isRdapDefaultPath() {
return isRdapDefaultPath;
}
-
}
diff --git a/src/main/java/mx/nic/rdap/server/result/HelpResult.java b/src/main/java/mx/nic/rdap/server/result/HelpResult.java
index 74a840c..ff6303f 100644
--- a/src/main/java/mx/nic/rdap/server/result/HelpResult.java
+++ b/src/main/java/mx/nic/rdap/server/result/HelpResult.java
@@ -14,18 +14,10 @@ public class HelpResult extends RdapResult {
private List notices;
- public HelpResult() {
+ public HelpResult(String header) {
notices = new ArrayList<>();
- notices.addAll(UserNotices.getHelp());
- if (UserNotices.getTos() != null && !UserNotices.getTos().isEmpty()) {
- notices.addAll(UserNotices.getTos());
- }
-
- List userNotices = UserNotices.getNotices();
- if (userNotices != null && !userNotices.isEmpty()) {
- notices.addAll(userNotices);
- }
-
+ notices.addAll(UserNotices.getHelp(header));
+
setResultType(ResultType.HELP);
HelpResponse helpResponse = new HelpResponse();
helpResponse.setNotices(notices);
diff --git a/src/main/java/mx/nic/rdap/server/servlet/HelpServlet.java b/src/main/java/mx/nic/rdap/server/servlet/HelpServlet.java
index 8f439d8..fbfed37 100644
--- a/src/main/java/mx/nic/rdap/server/servlet/HelpServlet.java
+++ b/src/main/java/mx/nic/rdap/server/servlet/HelpServlet.java
@@ -5,6 +5,7 @@
import mx.nic.rdap.server.result.HelpResult;
import mx.nic.rdap.server.result.RdapResult;
+import mx.nic.rdap.server.util.Util;
@WebServlet(name = "help", urlPatterns = { "/help" })
public class HelpServlet extends RdapServlet {
@@ -19,7 +20,7 @@ public class HelpServlet extends RdapServlet {
*/
@Override
protected RdapResult doRdapGet(HttpServletRequest httpRequest) {
- RdapResult result = new HelpResult();
+ RdapResult result = new HelpResult(Util.getServerUrl(httpRequest));
return result;
}
diff --git a/src/main/java/mx/nic/rdap/server/servlet/RdapServlet.java b/src/main/java/mx/nic/rdap/server/servlet/RdapServlet.java
index a24b0d4..33ff109 100644
--- a/src/main/java/mx/nic/rdap/server/servlet/RdapServlet.java
+++ b/src/main/java/mx/nic/rdap/server/servlet/RdapServlet.java
@@ -46,6 +46,7 @@
import mx.nic.rdap.server.result.RdapResult;
import mx.nic.rdap.server.servlet.AcceptHeaderFieldParser.Accept;
import mx.nic.rdap.server.util.PrivacyUtil;
+import mx.nic.rdap.server.util.Util;
/**
* Base class of all RDAP servlets.
@@ -119,13 +120,13 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
}
// Add TOS notice if exists
- addNotices(result.getRdapResponse());
+ addNotices(result.getRdapResponse(), Util.getServerUrl(request));
- renderResult(renderer.getRenderer(), result, response.getWriter());
+ renderResult(renderer.getRenderer(), result, response.getWriter(), Util.getServerUrl(request));
}
@SuppressWarnings("unchecked")
- private void renderResult(Renderer renderer, RdapResult result, PrintWriter printWriter) {
+ private void renderResult(Renderer renderer, RdapResult result, PrintWriter printWriter, String originalHeader) {
// Filter objects according to privacy settings
boolean wasFiltered = false;
switch (result.getResultType()) {
@@ -135,7 +136,7 @@ private void renderResult(Renderer renderer, RdapResult result, PrintWriter prin
if (wasFiltered) {
PrivacyUtil.addPrivacyRemarkAndStatus(autnumRequestResponse.getRdapObject());
}
- handleAutnumPostFilter(result, autnumRequestResponse);
+ handleAutnumPostFilter(result, autnumRequestResponse, originalHeader);
renderer.renderAutnum(autnumRequestResponse, printWriter);
break;
case DOMAIN :
@@ -146,7 +147,7 @@ private void renderResult(Renderer renderer, RdapResult result, PrintWriter prin
}
if (RdapConfiguration.addEmailRemark())
PrivacyUtil.addEmailRedactedForPrivacy(domainRequestResponse.getRdapObject());
- handleDomainPostFilter(result, domainRequestResponse);
+ handleDomainPostFilter(result, domainRequestResponse, originalHeader);
renderer.renderDomain(domainRequestResponse, printWriter);
break;
case DOMAINS :
@@ -159,7 +160,7 @@ private void renderResult(Renderer renderer, RdapResult result, PrintWriter prin
if (RdapConfiguration.addEmailRemark())
PrivacyUtil.addEmailRedactedForPrivacy(domain);
}
- handleDomainsPostFilter(domainSearchResponse);
+ handleDomainsPostFilter(domainSearchResponse, originalHeader);
renderer.renderDomains(domainSearchResponse, printWriter);
break;
case ENTITIES :
@@ -170,7 +171,7 @@ private void renderResult(Renderer renderer, RdapResult result, PrintWriter prin
PrivacyUtil.addPrivacyRemarkAndStatus(entity);
}
}
- handleEntitiesPostFilter(entitySearchResponse);
+ handleEntitiesPostFilter(entitySearchResponse, originalHeader);
renderer.renderEntities(entitySearchResponse, printWriter);
break;
case ENTITY :
@@ -179,7 +180,7 @@ private void renderResult(Renderer renderer, RdapResult result, PrintWriter prin
if (wasFiltered) {
PrivacyUtil.addPrivacyRemarkAndStatus(entityRequestResponse.getRdapObject());
}
- handleEntityPostFilter(result, entityRequestResponse);
+ handleEntityPostFilter(result, entityRequestResponse, originalHeader);
renderer.renderEntity(entityRequestResponse, printWriter);
break;
case EXCEPTION :
@@ -195,7 +196,7 @@ private void renderResult(Renderer renderer, RdapResult result, PrintWriter prin
PrivacyUtil.addPrivacyRemarkAndStatus(ipRequestResponse.getRdapObject());
}
- handleIpNetworkPostFilter(result, ipRequestResponse);
+ handleIpNetworkPostFilter(result, ipRequestResponse, originalHeader);
renderer.renderIpNetwork(ipRequestResponse, printWriter);
break;
case NAMESERVER :
@@ -205,7 +206,7 @@ private void renderResult(Renderer renderer, RdapResult result, PrintWriter prin
if (wasFiltered) {
PrivacyUtil.addPrivacyRemarkAndStatus(nameserverRequestResponse.getRdapObject());
}
- handleNameserverPostFilter(result, nameserverRequestResponse);
+ handleNameserverPostFilter(result, nameserverRequestResponse, originalHeader);
renderer.renderNameserver(nameserverRequestResponse, printWriter);
break;
case NAMESERVERS :
@@ -217,7 +218,7 @@ private void renderResult(Renderer renderer, RdapResult result, PrintWriter prin
PrivacyUtil.addPrivacyRemarkAndStatus(nameserver);
}
}
- handleNameserversPostFilter(nameserverSearchResponse);
+ handleNameserversPostFilter(nameserverSearchResponse, originalHeader);
renderer.renderNameservers(nameserverSearchResponse, printWriter);
break;
default :
@@ -226,8 +227,8 @@ private void renderResult(Renderer renderer, RdapResult result, PrintWriter prin
}
- private void addNotices(RdapResponse response) {
- List tos = UserNotices.getTos();
+ private void addNotices(RdapResponse response, String header) {
+ List tos = UserNotices.getTos(header);
if (tos != null && !tos.isEmpty()) {
if (response.getNotices() == null) {
response.setNotices(new ArrayList<>());
@@ -235,7 +236,7 @@ private void addNotices(RdapResponse response) {
response.getNotices().addAll(tos);
}
- List userNotices = UserNotices.getNotices();
+ List userNotices = UserNotices.getNotices(header);
if (userNotices != null && !userNotices.isEmpty()) {
if (response.getNotices() == null) {
response.setNotices(new ArrayList<>());
@@ -246,8 +247,8 @@ private void addNotices(RdapResponse response) {
return;
}
- private void handleNameserverPostFilter(RdapResult result, RequestResponse response) {
- addToRequestEventsAndNotices(response, RequestNotices.getNsNotices());
+ private void handleNameserverPostFilter(RdapResult result, RequestResponse response, String header) {
+ addToRequestEventsAndNotices(response, RequestNotices.getNsNotices(header));
handleCountryProperty(response.getRdapObject());
if (!RdapConfiguration.isNameserverSharingNameConformance()) {
@@ -269,43 +270,43 @@ private void handleNameserverPostFilter(RdapResult result, RequestResponse response) {
- addToRequestEventsAndNotices(response, RequestNotices.getDomainNotices());
+ private void handleDomainPostFilter(RdapResult result, RequestResponse response, String header) {
+ addToRequestEventsAndNotices(response, RequestNotices.getDomainNotices(header));
handleCountryProperty(response.getRdapObject());
}
- private void handleEntityPostFilter(RdapResult result, RequestResponse response) {
- addToRequestEventsAndNotices(response, RequestNotices.getEntityNotices());
+ private void handleEntityPostFilter(RdapResult result, RequestResponse response, String header) {
+ addToRequestEventsAndNotices(response, RequestNotices.getEntityNotices(header));
handleCountryProperty(response.getRdapObject());
}
- private void handleIpNetworkPostFilter(RdapResult result, RequestResponse response) {
- addToRequestEventsAndNotices(response, RequestNotices.getIpNotices());
+ private void handleIpNetworkPostFilter(RdapResult result, RequestResponse response, String header) {
+ addToRequestEventsAndNotices(response, RequestNotices.getIpNotices(header));
handleCountryProperty(response.getRdapObject());
}
- private void handleAutnumPostFilter(RdapResult result, RequestResponse response) {
- addToRequestEventsAndNotices(response, RequestNotices.getAutnumNotices());
+ private void handleAutnumPostFilter(RdapResult result, RequestResponse response, String header) {
+ addToRequestEventsAndNotices(response, RequestNotices.getAutnumNotices(header));
handleCountryProperty(response.getRdapObject());
}
- private void handleDomainsPostFilter(SearchResponse searchResponse) {
- addToSearchEventsAndNotices(searchResponse, RequestNotices.getDomainNotices());
+ private void handleDomainsPostFilter(SearchResponse searchResponse, String header) {
+ addToSearchEventsAndNotices(searchResponse, RequestNotices.getDomainNotices(header));
for (RdapObject rdapObject : searchResponse.getRdapObjects()) {
handleCountryProperty(rdapObject);
}
}
- private void handleNameserversPostFilter(SearchResponse searchResponse) {
- addToSearchEventsAndNotices(searchResponse, RequestNotices.getNsNotices());
+ private void handleNameserversPostFilter(SearchResponse searchResponse, String header) {
+ addToSearchEventsAndNotices(searchResponse, RequestNotices.getNsNotices(header));
for (RdapObject rdapObject : searchResponse.getRdapObjects()) {
handleCountryProperty(rdapObject);
}
}
- private void handleEntitiesPostFilter(SearchResponse searchResponse) {
- addToSearchEventsAndNotices(searchResponse, RequestNotices.getEntityNotices());
+ private void handleEntitiesPostFilter(SearchResponse searchResponse, String header) {
+ addToSearchEventsAndNotices(searchResponse, RequestNotices.getEntityNotices(header));
for (RdapObject rdapObject : searchResponse.getRdapObjects()) {
handleCountryProperty(rdapObject);
}