show domain options

This commit is contained in:
Peter Hormanns 2020-05-26 18:31:02 +02:00
parent a197b4b8af
commit b54c63ab1f

View File

@ -2,8 +2,10 @@ package de.hsadmin.pillar;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
@ -16,10 +18,13 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.HttpStatus;
import de.hsadmin.core.model.SelectableValue;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.Transaction;
import de.hsadmin.core.util.HSAdminException; import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.core.util.IPv6Trick; import de.hsadmin.core.util.IPv6Trick;
import de.hsadmin.mods.dom.Domain; import de.hsadmin.mods.dom.Domain;
import de.hsadmin.mods.dom.DomainOption;
import de.hsadmin.mods.dom.DomainOptionValues;
import de.hsadmin.mods.pac.Hive; 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;
@ -28,6 +33,8 @@ import de.hsadmin.mods.pac.PacComponent;
public class JsonPillarServlet extends HttpServlet { public class JsonPillarServlet extends HttpServlet {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final DomainOptionValues domainOptionValues = new DomainOptionValues();
@Override @Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
@ -113,7 +120,15 @@ public class JsonPillarServlet extends HttpServlet {
final Domain dom = (Domain) result; final Domain dom = (Domain) result;
final String domName = dom.getName(); final String domName = dom.getName();
dnsZones.add(domName); dnsZones.add(domName);
// final Set<DomainOption> domainoptions = dom.getDomainoptions(); final Map<String, Boolean> domainOpts = new HashMap<>();
for (final SelectableValue val : domainOptionValues.get()) {
domainOpts.put(val.getName(), Boolean.FALSE);
}
final Set<DomainOption> domainOptionNames = dom.getDomainoptions();
for (final DomainOption opt: domainOptionNames) {
final String optName = opt.getName();
domainOpts.put(optName, Boolean.TRUE);
}
if (firstLoop) { if (firstLoop) {
firstLoop = false; firstLoop = false;
writer.println(" {"); writer.println(" {");
@ -121,6 +136,18 @@ public class JsonPillarServlet extends HttpServlet {
writer.println(" , {"); writer.println(" , {");
} }
writer.println(" \"domain\": \"" + domName + "\""); writer.println(" \"domain\": \"" + domName + "\"");
writer.println(" , \"opts\": {");
writer.println(" \"letsencrypt\": \"" + domainOpts.get("letsencrypt").toString().toLowerCase() + "\"");
firstLoop = true;
for (final SelectableValue val : domainOptionValues.get()) {
if (firstLoop) {
firstLoop = false;
writer.println(" \"" + val.getName() + "\": " + domainOpts.get(val.getName()).toString().toLowerCase());
} else {
writer.println(" , \"" + val.getName() + "\": " + domainOpts.get(val.getName()).toString().toLowerCase());
}
}
writer.println(" }");
writer.println(" }"); writer.println(" }");
} }
writer.println(" ]"); writer.println(" ]");