// Path: distribution/src/main/java/nl/crowndov/displaydirect/distribution/Configuration.java
// public class Configuration {
// 
//     private static final Logger LOGGER = LoggerFactory.getLogger(Configuration.class);
// 
//     private static AbstractConfiguration config = ConfigurationManager.getConfigInstance();
// 
//     public static List<String> getKvEndpoints() {
//         return Arrays.asList(config.getStringArray("distribution.kv78turbo.endpoints"));
//     }
// 
//     public static String[] getKvPublishers() {
//         return config.getStringArray("distribution.kv78turbo.publishers");
//     }
// 
//     public static ZoneId getZoneId() {
//         return ZoneId.of(config.getString("distribution.timezone.default"));
//     }
// 
//     public static String getOutputTransport() {
//         return config.getString("distribution.transport", "mqtt");
//     }
// 
//     public static String getMqttBrokerHost() {
//         return config.getString("distribution.mqtt.host", "localhost:1883");
//     }
// 
//     public static int getZmqInternalPort() {
//         return 9800;
//     }
// 
//     public static String getMqttClientId() {
//         return config.getString("distribution.mqtt.client_id", "distribution");
//     }
// 
//     public static int getAuthorizationTokenMaxAge() {
//         return config.getInt("distribution.authorization.max_age_hours");
//     }
// 
//     public static List<String> getAuthorizationWhitelist() {
//         return Arrays.asList(config.getStringArray("distribution.authorization.whitelist_prefix"));
//     }
// 
//     public static String getBaseUrl() {
//         return config.getString("distribution.install.base_url", "http://localhost:8080");
//     }
// 
//     public static String getSmtpUsername() {
//         return config.getString("distribution.smtp.username", null);
//     }
// 
//     public static String getSmtpPassword() {
//         return config.getString("distribution.smtp.password", null);
//     }
// 
//     public static String getSmtpFrom() {
//         return config.getString("distribution.smtp.from");
//     }
// 
//     public static String getSmtpHostname() {
//         return config.getString("distribution.smtp.hostname");
//     }
// 
//     public static String getSmtpReplyTo() {
//         return config.getString("distribution.smtp.reply_to");
//     }
// 
//     public static boolean getSmtpSsl() { return config.getBoolean("distribution.smtp.ssl", false); }
// 
//     public static int getSmtpPort() {
//         return config.getInt("distribution.smtp.port", 25);
//     }
// 
//     public static int getSmtpConnectTimeout() {
//         return  config.getInt("distribution.smtp.connect_timeout", 10*1000);
//     }
// 
//     public static String getFileBasePath() {
//         return config.getString("distribution.backup.path", System.getProperty("java.io.tmpdir"));
//     }
// 
//     public static String getKv7PlanningPath() {
//         return config.getString("distribution.kv78turbo.path.planning");
//     }
// 
//     public static String getKv7CalendarPath() {
//         return config.getString("distribution.kv78turbo.path.calendar");
//     }
// 
//     public static String getChbPath() {
//         return config.getString("distribution.chb.path");
//     }
// 
// 
//     public static String getPlanningLoaderTime() {
//         return config.getString("distribution.planning.loadTime", "03:30");
//     }
// 
//     public static String getPlanningCleanupTime() {
//         return config.getString("distribution.planning.cleanupTime", "04:00");
//     }
// 
// }
// 
// Path: distribution/src/main/java/nl/crowndov/displaydirect/distribution/util/ZeroMQUtils.java
// public class ZeroMQUtils {
// 	
// 	public static String[] gunzipMultifameZMsg(ZMsg msg) throws IOException {
// 		Iterator<ZFrame> frames = msg.iterator();
// 		// pop off first frame, which contains "/GOVI/KV8" (the feed name)
// 		// (isn't there a method for this?)
// 		String header = frames.next().toString();
// 		ByteArrayOutputStream buffer = new ByteArrayOutputStream();
// 		while (frames.hasNext()) {
// 			ZFrame frame = frames.next();
// 			byte[] frameData = frame.getData();
// 			buffer.write(frameData);
// 		}
// 		if (buffer.size() == 0) {
// 			return null;
// 		}
// 		// chain input streams to gunzip contents of byte buffer
// 		InputStream gzippedMessageStream = new ByteArrayInputStream(
// 				buffer.toByteArray());
// 		InputStream messageStream = new GZIPInputStream(gzippedMessageStream);
// 		// copy input stream back to transport stream
// 		buffer.reset();
// 		byte[] b = new byte[4096];
// 		for (int n; (n = messageStream.read(b)) != -1;) {
// 			buffer.write(b, 0, n);
// 		}
// 		return new String[] { header, buffer.toString() };
// 	}
// }


import nl.crowndov.displaydirect.distribution.Configuration;
import nl.crowndov.displaydirect.distribution.util.ZeroMQUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zeromq.ZMQ;
import org.zeromq.ZMsg;
import java.util.List;
import java.util.concurrent.TimeUnit;
package nl.crowndov.displaydirect.distribution.input;



/**
 * Copyright 2017 CROW-NDOV
 *
 * This file is subject to the terms and conditions defined in file 'LICENSE.txt', which is part of this source code package.
 */
public class Kv78ReceiveTask implements Runnable {

    private static final Logger LOGGER = LoggerFactory.getLogger(Kv78ReceiveTask.class);

// Path: distribution/src/main/java/nl/crowndov/displaydirect/distribution/Configuration.java
// public class Configuration {
// 
//     private static final Logger LOGGER = LoggerFactory.getLogger(Configuration.class);
// 
//     private static AbstractConfiguration config = ConfigurationManager.getConfigInstance();
// 
//     public static List<String> getKvEndpoints() {
//         return Arrays.asList(config.getStringArray("distribution.kv78turbo.endpoints"));
//     }
// 
//     public static String[] getKvPublishers() {
//         return config.getStringArray("distribution.kv78turbo.publishers");
//     }
// 
//     public static ZoneId getZoneId() {
//         return ZoneId.of(config.getString("distribution.timezone.default"));
//     }
// 
//     public static String getOutputTransport() {
//         return config.getString("distribution.transport", "mqtt");
//     }
// 
//     public static String getMqttBrokerHost() {
//         return config.getString("distribution.mqtt.host", "localhost:1883");
//     }
// 
//     public static int getZmqInternalPort() {
//         return 9800;
//     }
// 
//     public static String getMqttClientId() {
//         return config.getString("distribution.mqtt.client_id", "distribution");
//     }
// 
//     public static int getAuthorizationTokenMaxAge() {
//         return config.getInt("distribution.authorization.max_age_hours");
//     }
// 
//     public static List<String> getAuthorizationWhitelist() {
//         return Arrays.asList(config.getStringArray("distribution.authorization.whitelist_prefix"));
//     }
// 
//     public static String getBaseUrl() {
//         return config.getString("distribution.install.base_url", "http://localhost:8080");
//     }
// 
//     public static String getSmtpUsername() {
//         return config.getString("distribution.smtp.username", null);
//     }
// 
//     public static String getSmtpPassword() {
//         return config.getString("distribution.smtp.password", null);
//     }
// 
//     public static String getSmtpFrom() {
//         return config.getString("distribution.smtp.from");
//     }
// 
//     public static String getSmtpHostname() {
//         return config.getString("distribution.smtp.hostname");
//     }
// 
//     public static String getSmtpReplyTo() {
//         return config.getString("distribution.smtp.reply_to");
//     }
// 
//     public static boolean getSmtpSsl() { return config.getBoolean("distribution.smtp.ssl", false); }
// 
//     public static int getSmtpPort() {
//         return config.getInt("distribution.smtp.port", 25);
//     }
// 
//     public static int getSmtpConnectTimeout() {
//         return  config.getInt("distribution.smtp.connect_timeout", 10*1000);
//     }
// 
//     public static String getFileBasePath() {
//         return config.getString("distribution.backup.path", System.getProperty("java.io.tmpdir"));
//     }
// 
//     public static String getKv7PlanningPath() {
//         return config.getString("distribution.kv78turbo.path.planning");
//     }
// 
//     public static String getKv7CalendarPath() {
//         return config.getString("distribution.kv78turbo.path.calendar");
//     }
// 
//     public static String getChbPath() {
//         return config.getString("distribution.chb.path");
//     }
// 
// 
//     public static String getPlanningLoaderTime() {
//         return config.getString("distribution.planning.loadTime", "03:30");
//     }
// 
//     public static String getPlanningCleanupTime() {
//         return config.getString("distribution.planning.cleanupTime", "04:00");
//     }
// 
// }
// 
// Path: distribution/src/main/java/nl/crowndov/displaydirect/distribution/util/ZeroMQUtils.java
// public class ZeroMQUtils {
// 	
// 	public static String[] gunzipMultifameZMsg(ZMsg msg) throws IOException {
// 		Iterator<ZFrame> frames = msg.iterator();
// 		// pop off first frame, which contains "/GOVI/KV8" (the feed name)
// 		// (isn't there a method for this?)
// 		String header = frames.next().toString();
// 		ByteArrayOutputStream buffer = new ByteArrayOutputStream();
// 		while (frames.hasNext()) {
// 			ZFrame frame = frames.next();
// 			byte[] frameData = frame.getData();
// 			buffer.write(frameData);
// 		}
// 		if (buffer.size() == 0) {
// 			return null;
// 		}
// 		// chain input streams to gunzip contents of byte buffer
// 		InputStream gzippedMessageStream = new ByteArrayInputStream(
// 				buffer.toByteArray());
// 		InputStream messageStream = new GZIPInputStream(gzippedMessageStream);
// 		// copy input stream back to transport stream
// 		buffer.reset();
// 		byte[] b = new byte[4096];
// 		for (int n; (n = messageStream.read(b)) != -1;) {
// 			buffer.write(b, 0, n);
// 		}
// 		return new String[] { header, buffer.toString() };
// 	}
// }


// Path: distribution/src/main/java/nl/crowndov/displaydirect/distribution/input/Kv78ReceiveTask.java
import nl.crowndov.displaydirect.distribution.Configuration;
import nl.crowndov.displaydirect.distribution.util.ZeroMQUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zeromq.ZMQ;
import org.zeromq.ZMsg;
import java.util.List;
import java.util.concurrent.TimeUnit;

package nl.crowndov.displaydirect.distribution.input;



/**
 * Copyright 2017 CROW-NDOV
 *
 * This file is subject to the terms and conditions defined in file 'LICENSE.txt', which is part of this source code package.
 */
public class Kv78ReceiveTask implements Runnable {

    private static final Logger LOGGER = LoggerFactory.getLogger(Kv78ReceiveTask.class);

    private final String[] kvPublishers = Configuration.getKvPublishers();