From b54c63ab1f3229f4733d3a7a70747b4befa083ab Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@jalin.de>
Date: Tue, 26 May 2020 18:31:02 +0200
Subject: [PATCH] show domain options

---
 hsarback/src/de/hsadmin/pillar/JsonPillarServlet.java |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/hsarback/src/de/hsadmin/pillar/JsonPillarServlet.java b/hsarback/src/de/hsadmin/pillar/JsonPillarServlet.java
index 5046545..7ad4f56 100644
--- a/hsarback/src/de/hsadmin/pillar/JsonPillarServlet.java
+++ b/hsarback/src/de/hsadmin/pillar/JsonPillarServlet.java
@@ -2,8 +2,10 @@
 
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
 
@@ -16,10 +18,13 @@
 
 import org.apache.commons.httpclient.HttpStatus;
 
+import de.hsadmin.core.model.SelectableValue;
 import de.hsadmin.core.model.Transaction;
 import de.hsadmin.core.util.HSAdminException;
 import de.hsadmin.core.util.IPv6Trick;
 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.INetAddress;
 import de.hsadmin.mods.pac.Pac;
@@ -28,6 +33,8 @@
 public class JsonPillarServlet extends HttpServlet {
 
 	private static final long serialVersionUID = 1L;
+	
+	private static final DomainOptionValues domainOptionValues = new DomainOptionValues(); 
 
 	@Override
 	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
@@ -113,7 +120,15 @@
 			final Domain dom = (Domain) result;
 			final String domName = dom.getName();
 			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) {
 				firstLoop = false;
 				writer.println("    {");
@@ -121,6 +136,18 @@
 				writer.println("    , {");
 			}
 			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("  ]");

--
Gitblit v1.9.0-SNAPSHOT