Added proxy configuration via system properties

Change-Id: Ifbd13f15e99510f8003a39ce250bc0b7a387494b
Signed-off-by: Fauth Dirk <Dirk.Fauth@de.bosch.com>
diff --git a/TODO.txt b/TODO.txt
new file mode 100644
index 0000000..1748d54
--- /dev/null
+++ b/TODO.txt
@@ -0,0 +1,29 @@
+This is a collection of open topics for the services and especially the manager:
+
+1. Persistence of service configuration
+The configuration of services in the manager admin panel should be persisted in a database.
+Additionally the docker configuration needs to be extended to have a volume for the database that lives longer than a container.
+
+2. Service selection
+Currently the service selection in the manager form is implemented as checkboxes. This way it is not possible to define an
+execution order. This should be changed to a combobox design. So all available services are available in a combobox. After
+selecting a service in a combobox, another combobox should appear containing all configured services. This way a user can
+select the service to execute and the order in which the services should be executed.
+
+3. Configuration resource
+There should be a configuration resource for each service that provides information about the possible parameters of the service.
+For example it could be possible to specify a version to migrate to in the converter service, and the validation service
+needs a configuration which validation profiles should be used. Based on this information the corresponding form parameters
+should be added in the manager form on selecting a service.
+
+4. Asynchronous service execution
+Currently the services are executed synchronously when the manager form is submitted. This should be changed to asynchronous
+execution to avoid timeouts for long running operations, e.g. for big model files. The update of the UI with the progress
+massages should be updated frequently, maybe using AJAX and/or websockets.
+
+5. Configuration via YAML
+Additionally to the manager workflow form UI it should be possible to trigger the workflow processing directly by providing
+an additional YAML configuration file. This allows the integration of the cloud service workflow in a CI/CD environment.
+
+6. Proxy configuration
+Add an administration UI to be able to configure a proxy server
\ No newline at end of file
diff --git a/manager/src/main/java/org/eclipse/app4mc/cloud/manager/WorkflowController.java b/manager/src/main/java/org/eclipse/app4mc/cloud/manager/WorkflowController.java
index e1fcd9e..7020d82 100644
--- a/manager/src/main/java/org/eclipse/app4mc/cloud/manager/WorkflowController.java
+++ b/manager/src/main/java/org/eclipse/app4mc/cloud/manager/WorkflowController.java
@@ -31,6 +31,7 @@
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
+import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.ModelAttribute;
@@ -183,6 +184,10 @@
 			String statusUrl = null;
 			if (uploadResponse.getStatus() == 201) {
 				statusUrl = uploadResponse.getHeaders().getFirst("Location");
+				if (StringUtils.isEmpty(statusUrl)) {
+					// fallback check for Link header if Location header is not set
+					statusUrl = getUrlFromLink(uploadResponse.getHeaders().get("Link"), "status");
+				}
 			} else if (uploadResponse.getStatus() == 200) {
 				// fallback if return code is 200, then follow up needs to be placed in Link header
 				statusUrl = getUrlFromLink(uploadResponse.getHeaders().get("Link"), "status");
diff --git a/manager/src/main/java/org/eclipse/app4mc/cloud/manager/administration/ApplicationConfig.java b/manager/src/main/java/org/eclipse/app4mc/cloud/manager/administration/ApplicationConfig.java
index c69243a..cd6cdee 100644
--- a/manager/src/main/java/org/eclipse/app4mc/cloud/manager/administration/ApplicationConfig.java
+++ b/manager/src/main/java/org/eclipse/app4mc/cloud/manager/administration/ApplicationConfig.java
@@ -5,8 +5,11 @@
 
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.util.StringUtils;
 import org.springframework.web.context.annotation.ApplicationScope;
 
+import kong.unirest.Unirest;
+
 @Configuration
 public class ApplicationConfig {
 
@@ -16,6 +19,21 @@
         ArrayList<CloudServiceDefinition> definitions = new ArrayList<>();
         definitions.add(new CloudServiceDefinition("Migration", "http://localhost:8080/app4mc/converter/", "Model Migration Service"));
         definitions.add(new CloudServiceDefinition("Validation", "http://localhost:8181/app4mc/validation/", "Model Validation Service"));
+        
+        // TODO make this configurable via admin ui
+        String proxyHost = System.getProperty("proxy.host");
+        String proxyPort = System.getProperty("proxy.port");
+        String proxyUser = System.getProperty("proxy.user");
+        String proxyPwd = System.getProperty("proxy.pwd");
+        
+        if (!StringUtils.isEmpty(proxyHost) && !StringUtils.isEmpty(proxyPort)) {
+        	if (!StringUtils.isEmpty(proxyUser) && !StringUtils.isEmpty(proxyPwd)) {
+        		Unirest.config().proxy(proxyHost, Integer.valueOf(proxyPort), proxyUser, proxyPwd);
+        	} else {
+        		Unirest.config().proxy(proxyHost, Integer.valueOf(proxyPort));
+        	}
+        }
+        
         return definitions;
     }
 }
diff --git a/manager/src/main/resources/templates/admin.html b/manager/src/main/resources/templates/admin.html
index 323059e..5807fae 100644
--- a/manager/src/main/resources/templates/admin.html
+++ b/manager/src/main/resources/templates/admin.html
@@ -32,6 +32,9 @@
 		    </fieldset>
 		</form>
 	</div>
+	<div>
+		<a th:href="@{/}">Go back</a>
+	</div>
 
 </body>
 </html>
\ No newline at end of file
diff --git a/manager/src/main/resources/templates/workflow.html b/manager/src/main/resources/templates/workflow.html
index 06c5df3..9a18fbe 100644
--- a/manager/src/main/resources/templates/workflow.html
+++ b/manager/src/main/resources/templates/workflow.html
@@ -55,5 +55,9 @@
 		<p><a th:href="@{/{uuid}/delete(uuid=${workflowStatus.uuid})}">Delete</a></p>
 	</div>
 
+	<div>
+		<a th:href="@{/}">Go back</a>
+	</div>
+
 </body>
 </html>
\ No newline at end of file