Close #678
This commit is contained in:
parent
55178a6b2c
commit
54d4dce869
@ -1900,11 +1900,40 @@ public class ApiCommands {
|
||||
public JSONObject allDomNames(HttpServletRequest request) throws Exception {
|
||||
|
||||
boolean responsibleOnly = Boolean.parseBoolean(WebUtils.optional(request, "responsibleOnly", "false"));
|
||||
Map<String, Set<String>> domMap = domainsManager.getAllDomNames();
|
||||
JSONObject result = new JSONObject();
|
||||
// For old DNS-F client:
|
||||
String dnsfVersion = "1.0.1";
|
||||
String agent = request.getHeader("Client-Version");
|
||||
ClientInfo clientInfo = new ClientInfo(agent);
|
||||
if (clientInfo.type == ClientInfo.ClientType.DNS && clientInfo.version.compareTo(VersionUtil.parseVersion(dnsfVersion)) <= 0) {
|
||||
|
||||
List<String> doms = new ArrayList<String>();
|
||||
Set<String> domSet = null;
|
||||
|
||||
if (domMap.containsKey(Constants.REQUEST_PARAM_DEFAULT_NAMESPACE_ID)) {
|
||||
domSet = domMap.get(Constants.REQUEST_PARAM_DEFAULT_NAMESPACE_ID);
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(domSet)) {
|
||||
result.put("doms", new HashSet<>());
|
||||
result.put("count", 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
for (String dom : domSet) {
|
||||
if (DistroMapper.responsible(dom) || !responsibleOnly) {
|
||||
doms.add(dom);
|
||||
}
|
||||
}
|
||||
|
||||
result.put("doms", doms);
|
||||
result.put("count", doms.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
Map<String, Set<String>> doms = new HashMap<>(16);
|
||||
|
||||
Map<String, Set<String>> domMap = domainsManager.getAllDomNames();
|
||||
|
||||
int count = 0;
|
||||
for (String namespaceId : domMap.keySet()) {
|
||||
doms.put(namespaceId, new HashSet<>());
|
||||
for (String dom : domMap.get(namespaceId)) {
|
||||
@ -1912,12 +1941,11 @@ public class ApiCommands {
|
||||
doms.get(namespaceId).add(dom);
|
||||
}
|
||||
}
|
||||
count += doms.get(namespaceId).size();
|
||||
}
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
|
||||
result.put("doms", doms);
|
||||
result.put("count", doms.size());
|
||||
result.put("count", count);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user