domains in pillar
This commit is contained in:
parent
5dae0e3353
commit
77f0da467f
@ -2,6 +2,7 @@ package de.hsadmin.pillar;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -17,7 +18,9 @@ import org.apache.commons.httpclient.HttpStatus;
|
|||||||
import de.hsadmin.core.model.Transaction;
|
import de.hsadmin.core.model.Transaction;
|
||||||
import de.hsadmin.core.qserv.ProcessorException;
|
import de.hsadmin.core.qserv.ProcessorException;
|
||||||
import de.hsadmin.core.util.IPv6Trick;
|
import de.hsadmin.core.util.IPv6Trick;
|
||||||
|
import de.hsadmin.mods.dom.Domain;
|
||||||
import de.hsadmin.mods.pac.Hive;
|
import de.hsadmin.mods.pac.Hive;
|
||||||
|
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;
|
||||||
|
|
||||||
@ -46,6 +49,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 List<String> dnsZones = new ArrayList<>();
|
||||||
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();
|
||||||
@ -73,10 +77,14 @@ public class JsonPillarServlet extends HttpServlet {
|
|||||||
} else {
|
} else {
|
||||||
writer.println(" , {");
|
writer.println(" , {");
|
||||||
}
|
}
|
||||||
writer.println(" \"pac\": \"" + pac.getName() + "\"");
|
final String pacName = pac.getName();
|
||||||
writer.println(" , \"ipv4\": \"" + pac.getCurINetAddr().getInet4Addr() + "\"");
|
final String pacDomain = pacName + ".hostsharing.net";
|
||||||
|
final INetAddress curINetAddr = pac.getCurINetAddr();
|
||||||
|
dnsZones.add(pacDomain);
|
||||||
|
writer.println(" \"pac\": \"" + pacName + "\"");
|
||||||
|
writer.println(" , \"ipv4\": \"" + curINetAddr.getInet4Addr() + "\"");
|
||||||
try {
|
try {
|
||||||
writer.println(" , \"ipv6\": \"" + pac.getCurINetAddr().getInet6Addr() + "\"");
|
writer.println(" , \"ipv6\": \"" + curINetAddr.getInet6Addr() + "\"");
|
||||||
} catch (ProcessorException e) {
|
} catch (ProcessorException e) {
|
||||||
// dont care
|
// dont care
|
||||||
}
|
}
|
||||||
@ -93,6 +101,37 @@ public class JsonPillarServlet extends HttpServlet {
|
|||||||
writer.println(" }");
|
writer.println(" }");
|
||||||
}
|
}
|
||||||
writer.println(" ]");
|
writer.println(" ]");
|
||||||
|
final Query domsQuery = em.createQuery("SELECT d FROM Domains d WHERE d.user.pac.hive.name = :hive");
|
||||||
|
domsQuery.setParameter("hive", hiveName);
|
||||||
|
final List<?> domsResult = pacsQuery.getResultList();
|
||||||
|
writer.println(" , \"doms\": [");
|
||||||
|
final Iterator<?> domsIterator = domsResult.iterator();
|
||||||
|
firstLoop = true;
|
||||||
|
while (domsIterator.hasNext()) {
|
||||||
|
final Object result = domsIterator.next();
|
||||||
|
final Domain dom = (Domain) result;
|
||||||
|
final String domName = dom.getName();
|
||||||
|
dnsZones.add(domName);
|
||||||
|
if (firstLoop) {
|
||||||
|
firstLoop = false;
|
||||||
|
writer.println(" {");
|
||||||
|
} else {
|
||||||
|
writer.println(" , {");
|
||||||
|
}
|
||||||
|
writer.println(" \"domain\": \"" + domName + "\"");
|
||||||
|
writer.println(" }");
|
||||||
|
}
|
||||||
|
writer.println(" , \"zones\": [");
|
||||||
|
firstLoop = true;
|
||||||
|
for (final String zone : dnsZones) {
|
||||||
|
if (firstLoop) {
|
||||||
|
firstLoop = false;
|
||||||
|
writer.println(" \"" + zone + "\"");
|
||||||
|
} else {
|
||||||
|
writer.println(" , \"" + zone + "\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
writer.println(" ]");
|
||||||
writer.println("}");
|
writer.println("}");
|
||||||
writer.close();
|
writer.close();
|
||||||
em.close();
|
em.close();
|
||||||
|
Loading…
Reference in New Issue
Block a user