// 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/pojo/User.java
// public class User implements Serializable {
// 
// 	private static final long serialVersionUID = 1L;
// 	
// 	private String username;
// 	private String givenName;
// 	private String surName;
// 	private String email;
// 	private List<String> groups;
// 	private boolean admin;
// 	
// 	public User() {}
// 	
// 	public User(String username, String givenName, String surName, String email, List<String> groups, boolean admin) {
// 		super();
// 		this.givenName = givenName;
// 		this.surName = surName;
// 		this.username = username;
// 		this.email = email;
// 		this.groups = groups;
// 		this.admin = admin;
// 	}
// 	
// 	public String getUsername() {
// 		return username;
// 	}
// 	
// 	public void setUsername(String username) {
// 		this.username = username;
// 	}
// 	
// 	public String getGivenName() {
// 		return givenName;
// 	}
// 
// 	public void setGivenName(String givenName) {
// 		this.givenName = givenName;
// 	}
// 
// 	public String getSurName() {
// 		return surName;
// 	}
// 
// 	public void setSurName(String surName) {
// 		this.surName = surName;
// 	}
// 
// 	public String getEmail() {
// 		return email;
// 	}
// 	
// 	public void setEmail(String email) {
// 		this.email = email;
// 	}
// 	
// 	public List<String> getGroups() {
// 		return groups;
// 	}
// 	
// 	public void setGroups(List<String> groups) {
// 		this.groups = groups;
// 	}
// 
// 	public boolean isAdmin() {
// 		return admin;
// 	}
// 
// 	public void setAdmin(boolean admin) {
// 		this.admin = admin;
// 	}
// }


import java.io.PrintWriter;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import de.papke.cloud.portal.constants.Constants;
import de.papke.cloud.portal.pojo.User;
package de.papke.cloud.portal.helper;



/**
 * Script helper class with utility functions for groovy scripts.
 */
public class ScriptHelper {

    private static final String OBJECTS_FOUND = "OBJECTS FOUND: ";

    private PrintWriter out;

    public ScriptHelper(PrintWriter out) {
        this.out = out;
    }

    /**
     * Method for printing an object on console.
     *
     * @param result
     */
    public void print(Object result) {
    	
    	if (result instanceof User) {
    		User user = (User) result;
    		printUser(user);
    	}
    	else {
    		if (result instanceof Collection<?>) {
    			Collection<?> collection = (Collection<?>) result;
    			printCollection(collection);
    		}
    		else {
    			if (result instanceof Map<?, ?>) {
    				Map<?, ?> map = (Map<?, ?>) result;
    				printMap(map);
    			}
    			else {
    				out.append(String.valueOf(result));
    			}
    		}
    	}
    }
    
    /**
     * Method for printing an object on console.
     *
     * @param result
     */
    public void println(Object result) {
    	print(result);
// 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/pojo/User.java
// public class User implements Serializable {
// 
// 	private static final long serialVersionUID = 1L;
// 	
// 	private String username;
// 	private String givenName;
// 	private String surName;
// 	private String email;
// 	private List<String> groups;
// 	private boolean admin;
// 	
// 	public User() {}
// 	
// 	public User(String username, String givenName, String surName, String email, List<String> groups, boolean admin) {
// 		super();
// 		this.givenName = givenName;
// 		this.surName = surName;
// 		this.username = username;
// 		this.email = email;
// 		this.groups = groups;
// 		this.admin = admin;
// 	}
// 	
// 	public String getUsername() {
// 		return username;
// 	}
// 	
// 	public void setUsername(String username) {
// 		this.username = username;
// 	}
// 	
// 	public String getGivenName() {
// 		return givenName;
// 	}
// 
// 	public void setGivenName(String givenName) {
// 		this.givenName = givenName;
// 	}
// 
// 	public String getSurName() {
// 		return surName;
// 	}
// 
// 	public void setSurName(String surName) {
// 		this.surName = surName;
// 	}
// 
// 	public String getEmail() {
// 		return email;
// 	}
// 	
// 	public void setEmail(String email) {
// 		this.email = email;
// 	}
// 	
// 	public List<String> getGroups() {
// 		return groups;
// 	}
// 	
// 	public void setGroups(List<String> groups) {
// 		this.groups = groups;
// 	}
// 
// 	public boolean isAdmin() {
// 		return admin;
// 	}
// 
// 	public void setAdmin(boolean admin) {
// 		this.admin = admin;
// 	}
// }


// Path: modules/cloud-portal-server/src/main/java/de/papke/cloud/portal/helper/ScriptHelper.java
import java.io.PrintWriter;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import de.papke.cloud.portal.constants.Constants;
import de.papke.cloud.portal.pojo.User;

package de.papke.cloud.portal.helper;



/**
 * Script helper class with utility functions for groovy scripts.
 */
public class ScriptHelper {

    private static final String OBJECTS_FOUND = "OBJECTS FOUND: ";

    private PrintWriter out;

    public ScriptHelper(PrintWriter out) {
        this.out = out;
    }

    /**
     * Method for printing an object on console.
     *
     * @param result
     */
    public void print(Object result) {
    	
    	if (result instanceof User) {
    		User user = (User) result;
    		printUser(user);
    	}
    	else {
    		if (result instanceof Collection<?>) {
    			Collection<?> collection = (Collection<?>) result;
    			printCollection(collection);
    		}
    		else {
    			if (result instanceof Map<?, ?>) {
    				Map<?, ?> map = (Map<?, ?>) result;
    				printMap(map);
    			}
    			else {
    				out.append(String.valueOf(result));
    			}
    		}
    	}
    }
    
    /**
     * Method for printing an object on console.
     *
     * @param result
     */
    public void println(Object result) {
    	print(result);
    	print(Constants.CHAR_NEW_LINE);