// Path: modules/cloud-portal-server/src/main/java/de/papke/cloud/portal/constants/Constants.java
// public class Constants {
// 	
// 	public static final String CHAR_EMPTY = "";
// 	public static final String CHAR_STAR = "*";
// 	public static final String CHAR_DIAMOND = "#";
// 	public static final String CHAR_EQUAL = "=";
// 	public static final String CHAR_DASH = "-";
// 	public static final String CHAR_UNDERSCORE = "_";
// 	public static final String CHAR_WHITESPACE = " ";
// 	public static final String CHAR_DOUBLE_QUOTE = "\"";
// 	public static final String CHAR_SINGLE_QUOTE = "'";
// 	public static final String CHAR_NEW_LINE = "\n";
// 	public static final String CHAR_TAB = "\t";
// 	public static final String CHAR_DOT = ".";
// 	public static final String CHAR_DOUBLE_DOT = ":";
// 	public static final String CHAR_BRACE_OPEN = "{";
// 	public static final String CHAR_BRACE_CLOSE = "}";
// 	public static final String CHAR_BRAKET_OPEN = "[";
// 	public static final String CHAR_BRAKET_CLOSE = "]";
// 	public static final String CHAR_COMMA = ",";
// 	public static final String CHAR_PARENTHESES_OPEN = "(";
// 	public static final String CHAR_PARENTHESES_CLOSE = ")";
// 	
// 	public static final String ACTION_INIT = "init";
// 	public static final String ACTION_APPLY = "apply";
// 	public static final String ACTION_PLAN = "plan";
// 	public static final String ACTION_DESTROY = "destroy";
// 	
// 	public static final String VM_EXPIRATION_DAYS_STRING = "expiration_days";
// 	
// 	public static final String KEY_FILE_PREFIX = "id_rsa";
// 	public static final String KEY_FILE_PUBLIC_SUFFIX = ".pub";
// 	public static final String KEY_FILE_PRIVATE_SUFFIX = ".pem";
// 	
// 	public static final String RESULT_FILE_PREFIX = "result";
// 	public static final String RESULT_FILE_SUFFIX = ".zip";
// 	
// 	public static final String TMP_FOLDER_PREFIX = System.getProperty("java.io.tmpdir") + "/tmp-";
// 
// 	public static final String FOLDER_CONSOLE = "console";
// 	public static final String FOLDER_USE_CASE = "usecase";
// 	public static final String FOLDER_PROVISIONER = "provisioner";
// 	public static final String FOLDER_TERRAFORM = "terraform";
// 	
// 	public static final String VAR_TYPE_SECRET = "secret";
// 	
// 	public static final String PROVISIONER_ESXI = "esxi";
// 	
// 	public static final String RESPONSE_CONTENT_TYPE_TEXT_PLAIN = "text/plain; charset=utf-8";
// 	
// 	private Constants() {}
// }


import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
import org.apache.commons.io.IOUtils;
import de.papke.cloud.portal.constants.Constants;
package de.papke.cloud.portal.util;




public class ZipUtil {
	
	private ZipUtil() {}
	
	public static void zip(File sourceDir, File outputFile) throws IOException {
		ZipOutputStream zipFile = new ZipOutputStream(new FileOutputStream(outputFile));
		Path srcPath = Paths.get(sourceDir.toURI());
		zipFolder(srcPath.getParent().toString(), srcPath.getFileName().toString(), zipFile);
		IOUtils.closeQuietly(zipFile);
	}

	private static void zipFolder(String rootDir, String sourceDir, ZipOutputStream out) throws IOException {
		
		String dir = Paths.get(rootDir, sourceDir).toString();
		
		for (File file : new File(dir).listFiles()) {
			
// Path: modules/cloud-portal-server/src/main/java/de/papke/cloud/portal/constants/Constants.java
// public class Constants {
// 	
// 	public static final String CHAR_EMPTY = "";
// 	public static final String CHAR_STAR = "*";
// 	public static final String CHAR_DIAMOND = "#";
// 	public static final String CHAR_EQUAL = "=";
// 	public static final String CHAR_DASH = "-";
// 	public static final String CHAR_UNDERSCORE = "_";
// 	public static final String CHAR_WHITESPACE = " ";
// 	public static final String CHAR_DOUBLE_QUOTE = "\"";
// 	public static final String CHAR_SINGLE_QUOTE = "'";
// 	public static final String CHAR_NEW_LINE = "\n";
// 	public static final String CHAR_TAB = "\t";
// 	public static final String CHAR_DOT = ".";
// 	public static final String CHAR_DOUBLE_DOT = ":";
// 	public static final String CHAR_BRACE_OPEN = "{";
// 	public static final String CHAR_BRACE_CLOSE = "}";
// 	public static final String CHAR_BRAKET_OPEN = "[";
// 	public static final String CHAR_BRAKET_CLOSE = "]";
// 	public static final String CHAR_COMMA = ",";
// 	public static final String CHAR_PARENTHESES_OPEN = "(";
// 	public static final String CHAR_PARENTHESES_CLOSE = ")";
// 	
// 	public static final String ACTION_INIT = "init";
// 	public static final String ACTION_APPLY = "apply";
// 	public static final String ACTION_PLAN = "plan";
// 	public static final String ACTION_DESTROY = "destroy";
// 	
// 	public static final String VM_EXPIRATION_DAYS_STRING = "expiration_days";
// 	
// 	public static final String KEY_FILE_PREFIX = "id_rsa";
// 	public static final String KEY_FILE_PUBLIC_SUFFIX = ".pub";
// 	public static final String KEY_FILE_PRIVATE_SUFFIX = ".pem";
// 	
// 	public static final String RESULT_FILE_PREFIX = "result";
// 	public static final String RESULT_FILE_SUFFIX = ".zip";
// 	
// 	public static final String TMP_FOLDER_PREFIX = System.getProperty("java.io.tmpdir") + "/tmp-";
// 
// 	public static final String FOLDER_CONSOLE = "console";
// 	public static final String FOLDER_USE_CASE = "usecase";
// 	public static final String FOLDER_PROVISIONER = "provisioner";
// 	public static final String FOLDER_TERRAFORM = "terraform";
// 	
// 	public static final String VAR_TYPE_SECRET = "secret";
// 	
// 	public static final String PROVISIONER_ESXI = "esxi";
// 	
// 	public static final String RESPONSE_CONTENT_TYPE_TEXT_PLAIN = "text/plain; charset=utf-8";
// 	
// 	private Constants() {}
// }


// Path: modules/cloud-portal-server/src/main/java/de/papke/cloud/portal/util/ZipUtil.java
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
import org.apache.commons.io.IOUtils;
import de.papke.cloud.portal.constants.Constants;

package de.papke.cloud.portal.util;




public class ZipUtil {
	
	private ZipUtil() {}
	
	public static void zip(File sourceDir, File outputFile) throws IOException {
		ZipOutputStream zipFile = new ZipOutputStream(new FileOutputStream(outputFile));
		Path srcPath = Paths.get(sourceDir.toURI());
		zipFolder(srcPath.getParent().toString(), srcPath.getFileName().toString(), zipFile);
		IOUtils.closeQuietly(zipFile);
	}

	private static void zipFolder(String rootDir, String sourceDir, ZipOutputStream out) throws IOException {
		
		String dir = Paths.get(rootDir, sourceDir).toString();
		
		for (File file : new File(dir).listFiles()) {
			
			if (!file.getName().startsWith(Constants.CHAR_DOT)) {