// Path: modules/cloud-portal-server/src/main/java/de/papke/cloud/portal/pojo/CommandResult.java
// public class CommandResult {
// 	
// 	private String output;
// 	private boolean success;
// 
// 	public CommandResult() {}
// 	
// 	public CommandResult(String output, boolean success) {
// 		this.output = output;
// 		this.success = success;
// 	}
// 	
// 	public String getOutput() {
// 		return output;
// 	}
// 	public void setOutput(String output) {
// 		this.output = output;
// 	}
// 	public boolean isSuccess() {
// 		return success;
// 	}
// 	public void setSuccess(boolean success) {
// 		this.success = success;
// 	}
// }
// 
// Path: modules/cloud-portal-server/src/main/java/de/papke/cloud/portal/pojo/Credentials.java
// public class Credentials {
// 
//     @Id
//     private String id;
//     private String group;
//     private String provider;
//     private Map<String, String> secretMap = new HashMap<>();
// 
//     public Credentials() {}
//     
// 	public Credentials(String group, String provider, Map<String, String> secretMap) {
// 		this.group = group;
// 		this.provider = provider;
// 		this.secretMap = secretMap;
// 	}
// 
// 	public String getId() {
// 		return id;
// 	}
// 
// 	public void setId(String id) {
// 		this.id = id;
// 	}
// 
// 	public String getGroup() {
// 		return group;
// 	}
// 	
// 	public void setGroup(String group) {
// 		this.group = group;
// 	}
// 
// 	public String getProvider() {
// 		return provider;
// 	}
// 
// 	public void setProvider(String provider) {
// 		this.provider = provider;
// 	}
// 
// 	public Map<String, String> getSecretMap() {
// 		return secretMap;
// 	}
// 
// 	public void setSecretMap(Map<String, String> secretMap) {
// 		this.secretMap = secretMap;
// 	}
// }
// 
// Path: modules/cloud-portal-server/src/main/java/de/papke/cloud/portal/pojo/UseCase.java
// public class UseCase {
// 	
// 	private String id;
// 	private String name;
// 	private String provider;
// 	private String provisioner;
// 	private List<VariableGroup> variableGroups; 
// 	private String resourceFolderPath; 
// 	
// 	@Override
// 	public String toString() {
// 		return "id=" + id;
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	public String getProvider() {
// 		return provider;
// 	}
// 
// 	public void setProvider(String provider) {
// 		this.provider = provider;
// 	}
// 
// 	public String getProvisioner() {
// 		return provisioner;
// 	}
// 
// 	public void setProvisioner(String provisioner) {
// 		this.provisioner = provisioner;
// 	}
// 
// 	public String getId() {
// 		return id;
// 	}
// 
// 	public void setId(String id) {
// 		this.id = id;
// 	}
// 
// 	public List<VariableGroup> getVariableGroups() {
// 		return variableGroups;
// 	}
// 
// 	public void setVariableGroups(List<VariableGroup> variableGroups) {
// 		this.variableGroups = variableGroups;
// 	}
// 
// 	public String getResourceFolderPath() {
// 		return resourceFolderPath;
// 	}
// 
// 	public void setResourceFolderPath(String resourceFolderPath) {
// 		this.resourceFolderPath = resourceFolderPath;
// 	}
// }


import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import de.papke.cloud.portal.pojo.CommandResult;
import de.papke.cloud.portal.pojo.Credentials;
import de.papke.cloud.portal.pojo.UseCase;
package de.papke.cloud.portal.service;




@Service
public abstract class ProvisionerService {
	
	private static final Logger LOG = LoggerFactory.getLogger(ProvisionerService.class);
	
	private static final String INTRODUCTION_SUFFIX = " IS WORKING ON YOUR ACTION. PLEASE BE PATIENT!!!\n\n";
	
	protected abstract String getPrefix();
	protected abstract String getBinaryPath();
	protected abstract CommandLine buildActionCommand(String ansiblePath, String action, Map<String, Object> variableMap);
	protected abstract Pattern getParsingPattern();
	protected abstract void prepare(UseCase useCase, String action, Credentials credentials, Map<String, Object> variableMap, OutputStream outputStream, File tmpFolder) throws IOException;
	protected abstract void cleanup(UseCase useCase, String action, Credentials credentials, Map<String, Object> variableMap, OutputStream outputStream, File tmpFolder) throws IOException;
	
	@Autowired
	private CommandExecutorService commandExecutorService;
	
// Path: modules/cloud-portal-server/src/main/java/de/papke/cloud/portal/pojo/CommandResult.java
// public class CommandResult {
// 	
// 	private String output;
// 	private boolean success;
// 
// 	public CommandResult() {}
// 	
// 	public CommandResult(String output, boolean success) {
// 		this.output = output;
// 		this.success = success;
// 	}
// 	
// 	public String getOutput() {
// 		return output;
// 	}
// 	public void setOutput(String output) {
// 		this.output = output;
// 	}
// 	public boolean isSuccess() {
// 		return success;
// 	}
// 	public void setSuccess(boolean success) {
// 		this.success = success;
// 	}
// }
// 
// Path: modules/cloud-portal-server/src/main/java/de/papke/cloud/portal/pojo/Credentials.java
// public class Credentials {
// 
//     @Id
//     private String id;
//     private String group;
//     private String provider;
//     private Map<String, String> secretMap = new HashMap<>();
// 
//     public Credentials() {}
//     
// 	public Credentials(String group, String provider, Map<String, String> secretMap) {
// 		this.group = group;
// 		this.provider = provider;
// 		this.secretMap = secretMap;
// 	}
// 
// 	public String getId() {
// 		return id;
// 	}
// 
// 	public void setId(String id) {
// 		this.id = id;
// 	}
// 
// 	public String getGroup() {
// 		return group;
// 	}
// 	
// 	public void setGroup(String group) {
// 		this.group = group;
// 	}
// 
// 	public String getProvider() {
// 		return provider;
// 	}
// 
// 	public void setProvider(String provider) {
// 		this.provider = provider;
// 	}
// 
// 	public Map<String, String> getSecretMap() {
// 		return secretMap;
// 	}
// 
// 	public void setSecretMap(Map<String, String> secretMap) {
// 		this.secretMap = secretMap;
// 	}
// }
// 
// Path: modules/cloud-portal-server/src/main/java/de/papke/cloud/portal/pojo/UseCase.java
// public class UseCase {
// 	
// 	private String id;
// 	private String name;
// 	private String provider;
// 	private String provisioner;
// 	private List<VariableGroup> variableGroups; 
// 	private String resourceFolderPath; 
// 	
// 	@Override
// 	public String toString() {
// 		return "id=" + id;
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	public String getProvider() {
// 		return provider;
// 	}
// 
// 	public void setProvider(String provider) {
// 		this.provider = provider;
// 	}
// 
// 	public String getProvisioner() {
// 		return provisioner;
// 	}
// 
// 	public void setProvisioner(String provisioner) {
// 		this.provisioner = provisioner;
// 	}
// 
// 	public String getId() {
// 		return id;
// 	}
// 
// 	public void setId(String id) {
// 		this.id = id;
// 	}
// 
// 	public List<VariableGroup> getVariableGroups() {
// 		return variableGroups;
// 	}
// 
// 	public void setVariableGroups(List<VariableGroup> variableGroups) {
// 		this.variableGroups = variableGroups;
// 	}
// 
// 	public String getResourceFolderPath() {
// 		return resourceFolderPath;
// 	}
// 
// 	public void setResourceFolderPath(String resourceFolderPath) {
// 		this.resourceFolderPath = resourceFolderPath;
// 	}
// }


// Path: modules/cloud-portal-server/src/main/java/de/papke/cloud/portal/service/ProvisionerService.java
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import de.papke.cloud.portal.pojo.CommandResult;
import de.papke.cloud.portal.pojo.Credentials;
import de.papke.cloud.portal.pojo.UseCase;

package de.papke.cloud.portal.service;




@Service
public abstract class ProvisionerService {
	
	private static final Logger LOG = LoggerFactory.getLogger(ProvisionerService.class);
	
	private static final String INTRODUCTION_SUFFIX = " IS WORKING ON YOUR ACTION. PLEASE BE PATIENT!!!\n\n";
	
	protected abstract String getPrefix();
	protected abstract String getBinaryPath();
	protected abstract CommandLine buildActionCommand(String ansiblePath, String action, Map<String, Object> variableMap);
	protected abstract Pattern getParsingPattern();
	protected abstract void prepare(UseCase useCase, String action, Credentials credentials, Map<String, Object> variableMap, OutputStream outputStream, File tmpFolder) throws IOException;
	protected abstract void cleanup(UseCase useCase, String action, Credentials credentials, Map<String, Object> variableMap, OutputStream outputStream, File tmpFolder) throws IOException;
	
	@Autowired
	private CommandExecutorService commandExecutorService;
	
	public CommandResult execute(UseCase useCase, String action, Credentials credentials, Map<String, Object> variableMap, OutputStream outputStream, File tmpFolder) {