need all zones list with acmeupdate info
This commit is contained in:
parent
cdc84a53e1
commit
dedf7c9c7b
@ -29,6 +29,7 @@ import de.hsadmin.mods.pac.Hive;
|
|||||||
import de.hsadmin.mods.pac.INetAddress;
|
import de.hsadmin.mods.pac.INetAddress;
|
||||||
import de.hsadmin.mods.pac.Pac;
|
import de.hsadmin.mods.pac.Pac;
|
||||||
import de.hsadmin.mods.pac.PacComponent;
|
import de.hsadmin.mods.pac.PacComponent;
|
||||||
|
import de.hsadmin.mods.user.UnixUser;
|
||||||
|
|
||||||
public class JsonPillarServlet extends HttpServlet {
|
public class JsonPillarServlet extends HttpServlet {
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ public class JsonPillarServlet extends HttpServlet {
|
|||||||
hiveQuery.setParameter("hive", hiveName);
|
hiveQuery.setParameter("hive", hiveName);
|
||||||
final Object hiveResult = hiveQuery.getSingleResult();
|
final Object hiveResult = hiveQuery.getSingleResult();
|
||||||
final Hive hive = (Hive) hiveResult;
|
final Hive hive = (Hive) hiveResult;
|
||||||
final Set<String> dnsZones = new TreeSet<String>();
|
final Map<String, Boolean> dnsZones = new HashMap<>();
|
||||||
final Query pacsQuery = em.createQuery("SELECT p FROM Pacs p WHERE p.hive.name = :hive AND p.basepac.name = 'PAC/WEB'");
|
final Query pacsQuery = em.createQuery("SELECT p FROM Pacs p WHERE p.hive.name = :hive AND p.basepac.name = 'PAC/WEB'");
|
||||||
pacsQuery.setParameter("hive", hiveName);
|
pacsQuery.setParameter("hive", hiveName);
|
||||||
final List<?> pacsResult = pacsQuery.getResultList();
|
final List<?> pacsResult = pacsQuery.getResultList();
|
||||||
@ -75,12 +76,12 @@ public class JsonPillarServlet extends HttpServlet {
|
|||||||
writer.println(" , \"currenttimeseconds\": \"" + currentTimeSeconds + "\"");
|
writer.println(" , \"currenttimeseconds\": \"" + currentTimeSeconds + "\"");
|
||||||
writer.println(" , \"pacs\": [");
|
writer.println(" , \"pacs\": [");
|
||||||
final Iterator<?> pacsIterator = pacsResult.iterator();
|
final Iterator<?> pacsIterator = pacsResult.iterator();
|
||||||
boolean firstLoop = true;
|
boolean firstLoopPacs = true;
|
||||||
while (pacsIterator.hasNext()) {
|
while (pacsIterator.hasNext()) {
|
||||||
final Object result = pacsIterator.next();
|
final Object result = pacsIterator.next();
|
||||||
final Pac pac = (Pac) result;
|
final Pac pac = (Pac) result;
|
||||||
if (firstLoop) {
|
if (firstLoopPacs) {
|
||||||
firstLoop = false;
|
firstLoopPacs = false;
|
||||||
writer.println(" {");
|
writer.println(" {");
|
||||||
} else {
|
} else {
|
||||||
writer.println(" , {");
|
writer.println(" , {");
|
||||||
@ -88,7 +89,7 @@ public class JsonPillarServlet extends HttpServlet {
|
|||||||
final String pacName = pac.getName();
|
final String pacName = pac.getName();
|
||||||
final String pacDomain = pacName + ".hostsharing.net";
|
final String pacDomain = pacName + ".hostsharing.net";
|
||||||
final INetAddress curINetAddr = pac.getCurINetAddr();
|
final INetAddress curINetAddr = pac.getCurINetAddr();
|
||||||
dnsZones.add(pacDomain);
|
dnsZones.put(pacDomain, Boolean.FALSE);
|
||||||
writer.println(" \"pac\": \"" + pacName + "\"");
|
writer.println(" \"pac\": \"" + pacName + "\"");
|
||||||
writer.println(" , \"ipv4\": \"" + curINetAddr.getInet4Addr() + "\"");
|
writer.println(" , \"ipv4\": \"" + curINetAddr.getInet4Addr() + "\"");
|
||||||
try {
|
try {
|
||||||
@ -114,12 +115,11 @@ public class JsonPillarServlet extends HttpServlet {
|
|||||||
final List<?> domsResult = domsQuery.getResultList();
|
final List<?> domsResult = domsQuery.getResultList();
|
||||||
writer.println(" , \"doms\": [");
|
writer.println(" , \"doms\": [");
|
||||||
final Iterator<?> domsIterator = domsResult.iterator();
|
final Iterator<?> domsIterator = domsResult.iterator();
|
||||||
firstLoop = true;
|
boolean firstLoopDoms = true;
|
||||||
while (domsIterator.hasNext()) {
|
while (domsIterator.hasNext()) {
|
||||||
final Object result = domsIterator.next();
|
final Domain dom = (Domain) domsIterator.next();
|
||||||
final Domain dom = (Domain) result;
|
|
||||||
final String domName = dom.getName();
|
final String domName = dom.getName();
|
||||||
dnsZones.add(domName);
|
dnsZones.put(domName, Boolean.FALSE);
|
||||||
final Map<String, Boolean> domainOpts = new HashMap<>();
|
final Map<String, Boolean> domainOpts = new HashMap<>();
|
||||||
for (final SelectableValue val : domainOptionValues.get()) {
|
for (final SelectableValue val : domainOptionValues.get()) {
|
||||||
domainOpts.put(val.getName(), Boolean.FALSE);
|
domainOpts.put(val.getName(), Boolean.FALSE);
|
||||||
@ -129,27 +129,57 @@ public class JsonPillarServlet extends HttpServlet {
|
|||||||
final String optName = opt.getName();
|
final String optName = opt.getName();
|
||||||
domainOpts.put(optName, Boolean.TRUE);
|
domainOpts.put(optName, Boolean.TRUE);
|
||||||
}
|
}
|
||||||
if (firstLoop) {
|
if (firstLoopDoms) {
|
||||||
firstLoop = false;
|
firstLoopDoms = false;
|
||||||
writer.println(" {");
|
writer.println(" {");
|
||||||
} else {
|
} else {
|
||||||
writer.println(" , {");
|
writer.println(" , {");
|
||||||
}
|
}
|
||||||
|
final UnixUser domUser = dom.getUser();
|
||||||
|
final Pac domPac = domUser.getPac();
|
||||||
|
final INetAddress domINetAddr = domPac.getCurINetAddr();
|
||||||
writer.println(" \"domain\": \"" + domName + "\"");
|
writer.println(" \"domain\": \"" + domName + "\"");
|
||||||
|
writer.println(" , \"pac\": \"" + domPac.getName() + "\"");
|
||||||
|
writer.println(" , \"user\": \"" + domUser.getName() + "\"");
|
||||||
|
writer.println(" , \"ipv4\": \"" + domINetAddr.getInet4Addr() + "\"");
|
||||||
|
try {
|
||||||
|
writer.println(" , \"ipv6\": \"" + domINetAddr.getInet6Addr() + "\"");
|
||||||
|
} catch (HSAdminException e) {
|
||||||
|
// dont care
|
||||||
|
}
|
||||||
writer.println(" , \"opts\": {");
|
writer.println(" , \"opts\": {");
|
||||||
firstLoop = true;
|
boolean firstLoopOpts = true;
|
||||||
for (final SelectableValue val : domainOptionValues.get()) {
|
for (final SelectableValue val : domainOptionValues.get()) {
|
||||||
if (firstLoop) {
|
final String optName = val.getName();
|
||||||
firstLoop = false;
|
final Boolean optValue = domainOpts.get(optName);
|
||||||
writer.println(" \"" + val.getName() + "\": " + domainOpts.get(val.getName()).toString().toLowerCase());
|
if ("letsencrypt".equals(domName)) {
|
||||||
|
dnsZones.put(domName, optValue);
|
||||||
|
}
|
||||||
|
if (firstLoopOpts) {
|
||||||
|
firstLoopOpts = false;
|
||||||
|
writer.println(" \"" + optName + "\": " + optValue.toString().toLowerCase());
|
||||||
} else {
|
} else {
|
||||||
writer.println(" , \"" + val.getName() + "\": " + domainOpts.get(val.getName()).toString().toLowerCase());
|
writer.println(" , \"" + optName + "\": " + optValue.toString().toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writer.println(" }");
|
writer.println(" }");
|
||||||
writer.println(" }");
|
writer.println(" }");
|
||||||
}
|
}
|
||||||
writer.println(" ]");
|
writer.println(" ]");
|
||||||
|
boolean firstLoopZones = true;
|
||||||
|
writer.println(" , \"zones\": [");
|
||||||
|
for (final String zone : dnsZones.keySet()) {
|
||||||
|
if (firstLoopZones) {
|
||||||
|
firstLoopZones = false;
|
||||||
|
writer.println(" {");
|
||||||
|
} else {
|
||||||
|
writer.println(" , {");
|
||||||
|
}
|
||||||
|
writer.println(" \"zone\": \"" + zone + "\"");
|
||||||
|
writer.println(" , \"acmeupdates\": " + dnsZones.get(zone).toString().toLowerCase());
|
||||||
|
writer.println(" }");
|
||||||
|
}
|
||||||
|
writer.println(" ]");
|
||||||
writer.println("}");
|
writer.println("}");
|
||||||
writer.close();
|
writer.close();
|
||||||
transaction.close();
|
transaction.close();
|
||||||
|
Loading…
Reference in New Issue
Block a user