diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index 34632984424a895e6605023304305cc7e396c1c7..0000000000000000000000000000000000000000
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "statemachine"]
-	path = statemachine
-	url = https://git.code.tecnalia.com/decide/statemachine.git
diff --git a/State Machine/.gitkeep b/State Machine/.gitkeep
deleted file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000
diff --git a/State Machine/statemachine/.classpath b/State Machine/statemachine/.classpath
new file mode 100644
index 0000000000000000000000000000000000000000..5cab57a2eabfbc6bab6786c8ab404d3c26f48526
--- /dev/null
+++ b/State Machine/statemachine/.classpath	
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java">
+		<attributes>
+			<attribute name="optional" value="true"/>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="src" output="target/classes" path="src/gen">
+		<attributes>
+			<attribute name="optional" value="true"/>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/java">
+		<attributes>
+			<attribute name="optional" value="true"/>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/State Machine/statemachine/.gitignore b/State Machine/statemachine/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..b83d22266ac8aa2f8df2edef68082c789727841d
--- /dev/null
+++ b/State Machine/statemachine/.gitignore	
@@ -0,0 +1 @@
+/target/
diff --git a/State Machine/statemachine/.project b/State Machine/statemachine/.project
new file mode 100644
index 0000000000000000000000000000000000000000..d0491bbdb74d6da713bbbe8b0f23430703c0a3d1
--- /dev/null
+++ b/State Machine/statemachine/.project	
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>statemachine</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.m2e.core.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
+	</natures>
+</projectDescription>
diff --git a/State Machine/statemachine/.settings/org.eclipse.core.resources.prefs b/State Machine/statemachine/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000000000000000000000000000000000000..0ab6055366c278437887ef30de57a8056f37c429
--- /dev/null
+++ b/State Machine/statemachine/.settings/org.eclipse.core.resources.prefs	
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+encoding//src/gen=UTF-8
+encoding//src/main/java=UTF-8
+encoding//src/main/resources=UTF-8
+encoding//src/test/java=UTF-8
+encoding//src/test/resources=UTF-8
+encoding/<project>=UTF-8
diff --git a/State Machine/statemachine/.settings/org.eclipse.jdt.core.prefs b/State Machine/statemachine/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000000000000000000000000000000000000..ec4300d5d0999d569b87f3935944bcfc5197f877
--- /dev/null
+++ b/State Machine/statemachine/.settings/org.eclipse.jdt.core.prefs	
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/State Machine/statemachine/.settings/org.eclipse.m2e.core.prefs b/State Machine/statemachine/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000000000000000000000000000000000000..f897a7f1cb2389f85fe6381425d29f0a9866fb65
--- /dev/null
+++ b/State Machine/statemachine/.settings/org.eclipse.m2e.core.prefs	
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/State Machine/statemachine/Dockerfile b/State Machine/statemachine/Dockerfile
new file mode 100644
index 0000000000000000000000000000000000000000..95fd9ba8e984f9930c4515fac72ffe34813af3eb
--- /dev/null
+++ b/State Machine/statemachine/Dockerfile	
@@ -0,0 +1,8 @@
+FROM openjdk:8-jdk-alpine
+
+ADD target/statemachine-1.0.0.jar app.jar
+CMD ["java", "-Xmx200m", "-jar", "/app/statemachine-1.0.0.jar"]
+
+ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
+
+EXPOSE 5000
diff --git a/State Machine/statemachine/README.md b/State Machine/statemachine/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..f60054e4279b215e171d73eb0fa9a8fa3db6882a
--- /dev/null
+++ b/State Machine/statemachine/README.md	
@@ -0,0 +1,18 @@
+# Swagger generated server
+
+Spring Boot Server 
+
+
+## Overview  
+This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project.  
+By using the [OpenAPI-Spec](https://github.com/swagger-api/swagger-core), you can easily generate a server stub.  
+This is an example of building a swagger-enabled server in Java using the SpringBoot framework.  
+
+The underlying library integrating swagger to SpringBoot is [springfox](https://github.com/springfox/springfox)  
+
+Start your server as an simple java application  
+
+You can view the api documentation in swagger-ui by pointing to  
+http://localhost:5000/  
+
+Change default port value in application.properties
\ No newline at end of file
diff --git a/State Machine/statemachine/docker-compose-release.yml b/State Machine/statemachine/docker-compose-release.yml
new file mode 100644
index 0000000000000000000000000000000000000000..13fedc5a5a22bfa94ab794169d5447e8cc2579a0
--- /dev/null
+++ b/State Machine/statemachine/docker-compose-release.yml	
@@ -0,0 +1,25 @@
+version: "3"
+services:          
+    mysql_sm:
+        image: mysql:5.5.59
+        container_name: mysql_sm
+        environment:
+            MYSQL_ROOT_PASSWORD: root
+            MYSQL_USER: admin
+            MYSQL_PASSWORD: decide
+            MYSQL_DATABASE: db_statemachine 
+        ports:
+            - 3506:3306
+    statemachine:
+        build: 
+            context: .
+            args:
+                GIT_CREDENTIALS: $GIT_CREDENTIALS
+        container_name: statemachine
+        depends_on:
+            - mysql_sm
+        ports:
+            - 8096:5000
+networks:
+  decide: 
+    external: true
\ No newline at end of file
diff --git a/State Machine/statemachine/pom.xml b/State Machine/statemachine/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..1d600943cb0c576e3256954505db83ba73f9553f
--- /dev/null
+++ b/State Machine/statemachine/pom.xml	
@@ -0,0 +1,160 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.decideh2020</groupId>
+	<artifactId>statemachine</artifactId>
+	<name>statemachine</name>
+	<version>1.0.0</version>
+	<packaging>jar</packaging>
+	<properties>
+		<java.version>1.7</java.version>
+		<maven.compiler.source>${java.version}</maven.compiler.source>
+		<maven.compiler.target>${java.version}</maven.compiler.target>
+		<springfox-version>2.7.0</springfox-version>
+	</properties>
+	<parent>
+		<groupId>org.springframework.boot</groupId>
+		<artifactId>spring-boot-starter-parent</artifactId>
+		<version>1.5.9.RELEASE</version>
+	</parent>
+	<dependencies>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-web</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-tomcat</artifactId>
+		</dependency>
+		<!--SpringFox dependencies -->
+		<dependency>
+			<groupId>io.springfox</groupId>
+			<artifactId>springfox-swagger2</artifactId>
+			<version>${springfox-version}</version>
+		</dependency>
+		<dependency>
+			<groupId>io.springfox</groupId>
+			<artifactId>springfox-swagger-ui</artifactId>
+			<version>${springfox-version}</version>
+		</dependency>
+		<dependency>
+			<groupId>com.github.joschi.jackson</groupId>
+			<artifactId>jackson-datatype-threetenbp</artifactId>
+			<version>2.6.4</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.json</groupId>
+			<artifactId>json</artifactId>
+			<version>20160810</version>
+			<scope>compile</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>com.fasterxml.jackson.jaxrs</groupId>
+			<artifactId>jackson-jaxrs-json-provider</artifactId>
+			<version>2.9.1</version>
+			<scope>compile</scope>
+		</dependency>
+		
+		<dependency>
+			<groupId>eu.decideh2020</groupId>
+			<artifactId>eu.DECIDEh2020.optimus.client</artifactId>
+			<version>3.0.0</version>
+		</dependency>
+
+		<!-- CXF Client -->
+		<dependency>
+			<groupId>org.apache.cxf</groupId>
+			<artifactId>cxf-rt-rs-client</artifactId>
+			<version>3.2.1</version>
+		</dependency>
+
+		<dependency>
+			<groupId>javax.ws.rs</groupId>
+			<artifactId>javax.ws.rs-api</artifactId>
+			<version>2.1</version>
+		</dependency>
+
+		<!-- Bean Validation API support -->
+		<dependency>
+			<groupId>javax.validation</groupId>
+			<artifactId>validation-api</artifactId>
+		</dependency>
+
+		<!-- JPA Data (We are going to use Repositories, Entities, Hibernate, etc...) -->
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-data-jpa</artifactId>
+		</dependency>
+
+		<dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-mongodb</artifactId>
+        </dependency>
+        
+		<!-- Use MySQL Connector-J -->
+		<dependency>
+			<groupId>mysql</groupId>
+			<artifactId>mysql-connector-java</artifactId>
+		</dependency>
+		
+		<!--  Vault -->
+		<dependency>
+            <groupId>org.springframework.vault</groupId>
+            <artifactId>spring-vault-core</artifactId>
+            <version>1.1.1.RELEASE</version>
+        </dependency>
+
+		<dependency>
+			<groupId>eu.DECIDEh2020</groupId>
+			<artifactId>app-controller</artifactId>
+			<version>0.0.24</version>
+		</dependency>
+		
+		<dependency>
+		    <groupId>commons-io</groupId>
+		    <artifactId>commons-io</artifactId>
+		    <version>2.6</version>
+		</dependency>
+	</dependencies>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.codehaus.mojo</groupId>
+				<artifactId>build-helper-maven-plugin</artifactId>
+				<version>3.0.0</version>
+				<executions>
+					<execution>
+						<phase>generate-sources</phase>
+						<goals>
+							<goal>add-source</goal>
+						</goals>
+						<configuration>
+							<sources>
+								<source>src/gen</source>
+							</sources>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+				<configuration>
+					<sources>
+						<source>src/main/java</source>
+					</sources>
+				</configuration>
+				<executions>
+					<execution>
+						<goals>
+							<goal>repackage</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
+</project>
\ No newline at end of file
diff --git a/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/RFC3339DateFormat.java b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/RFC3339DateFormat.java
new file mode 100644
index 0000000000000000000000000000000000000000..66d07e3388c757cf626c831739d4c98885b60101
--- /dev/null
+++ b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/RFC3339DateFormat.java	
@@ -0,0 +1,22 @@
+package eu.decideh2020.statemachine.server;
+
+import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
+import com.fasterxml.jackson.databind.util.ISO8601Utils;
+
+import java.text.FieldPosition;
+import java.util.Date;
+
+
+public class RFC3339DateFormat extends ISO8601DateFormat {
+
+  private static final long serialVersionUID = 1L;
+
+  // Same as ISO8601DateFormat but serializing milliseconds.
+  @Override
+  public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
+    String value = ISO8601Utils.format(date, true);
+    toAppendTo.append(value);
+    return toAppendTo;
+  }
+
+}
\ No newline at end of file
diff --git a/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/api/ApiException.java b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/api/ApiException.java
new file mode 100644
index 0000000000000000000000000000000000000000..80e25375fd7a836a4abcfcf5fd6b35da1b727620
--- /dev/null
+++ b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/api/ApiException.java	
@@ -0,0 +1,11 @@
+package eu.decideh2020.statemachine.server.api;
+
+@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-09-30T15:24:56.314Z")
+
+public class ApiException extends Exception{
+    private int code;
+    public ApiException (int code, String msg) {
+        super(msg);
+        this.code = code;
+    }
+}
diff --git a/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/api/ApiOriginFilter.java b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/api/ApiOriginFilter.java
new file mode 100644
index 0000000000000000000000000000000000000000..de48503d9c98592ec5a871624a831c752b9f1b20
--- /dev/null
+++ b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/api/ApiOriginFilter.java	
@@ -0,0 +1,28 @@
+package eu.decideh2020.statemachine.server.api;
+
+import java.io.IOException;
+
+import javax.servlet.*;
+import javax.servlet.http.HttpServletResponse;
+
+@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-09-30T15:24:56.314Z")
+
+public class ApiOriginFilter implements javax.servlet.Filter {
+    @Override
+    public void doFilter(ServletRequest request, ServletResponse response,
+            FilterChain chain) throws IOException, ServletException {
+        HttpServletResponse res = (HttpServletResponse) response;
+        res.addHeader("Access-Control-Allow-Origin", "*");
+        res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
+        res.addHeader("Access-Control-Allow-Headers", "Content-Type");
+        chain.doFilter(request, response);
+    }
+
+    @Override
+    public void destroy() {
+    }
+
+    @Override
+    public void init(FilterConfig filterConfig) throws ServletException {
+    }
+}
diff --git a/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/api/ApiResponseMessage.java b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/api/ApiResponseMessage.java
new file mode 100644
index 0000000000000000000000000000000000000000..ba22ecbd95c8a9a5ccf385edaadfd38808ee4e92
--- /dev/null
+++ b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/api/ApiResponseMessage.java	
@@ -0,0 +1,70 @@
+package eu.decideh2020.statemachine.server.api;
+
+import javax.xml.bind.annotation.XmlTransient;
+
+@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-09-30T15:24:56.314Z")
+
+@javax.xml.bind.annotation.XmlRootElement
+public class ApiResponseMessage {
+    public static final int ERROR = 1;
+    public static final int WARNING = 2;
+    public static final int INFO = 3;
+    public static final int OK = 4;
+    public static final int TOO_BUSY = 5;
+
+    int code;
+    String type;
+    String message;
+
+    public ApiResponseMessage(){}
+
+    public ApiResponseMessage(int code, String message){
+        this.code = code;
+        switch(code){
+        case ERROR:
+            setType("error");
+            break;
+        case WARNING:
+            setType("warning");
+            break;
+        case INFO:
+            setType("info");
+            break;
+        case OK:
+            setType("ok");
+            break;
+        case TOO_BUSY:
+            setType("too busy");
+            break;
+        default:
+            setType("unknown");
+            break;
+        }
+        this.message = message;
+    }
+
+    @XmlTransient
+    public int getCode() {
+        return code;
+    }
+
+    public void setCode(int code) {
+        this.code = code;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+}
diff --git a/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/api/GetStateApi.java b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/api/GetStateApi.java
new file mode 100644
index 0000000000000000000000000000000000000000..867def35ef715639db858eda07e919e60001b38e
--- /dev/null
+++ b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/api/GetStateApi.java	
@@ -0,0 +1,38 @@
+/**
+ * NOTE: This class is auto generated by the swagger code generator program (2.4.8).
+ * https://github.com/swagger-api/swagger-codegen
+ * Do not edit the class manually.
+ */
+package eu.decideh2020.statemachine.server.api;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import eu.decideh2020.statemachine.server.model.State;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-09-30T15:53:23.605Z")
+
+@Api(value = "getState", description = "the getState API")
+public interface GetStateApi {
+
+    @ApiOperation(value = "Get the state of user application", nickname = "getState", notes = "Get the application state", response = State.class, tags={ "state-machine", })
+    @ApiResponses(value = { 
+        @ApiResponse(code = 200, message = "successful operation", response = State.class),
+        @ApiResponse(code = 401, message = "Unauthorized"),
+        @ApiResponse(code = 403, message = "Forbidden"),
+        @ApiResponse(code = 404, message = "Not Found") })
+    @RequestMapping(value = "/getState",
+        produces = { "application/json" }, 
+        method = RequestMethod.GET)
+    ResponseEntity<State> getState(@NotNull @ApiParam(value = "Id of the user", required = true) @Valid @RequestParam(value = "user", required = true) String user,@NotNull @ApiParam(value = "Id of the application", required = true) @Valid @RequestParam(value = "app", required = true) String app);
+
+}
diff --git a/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/api/NotFoundException.java b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/api/NotFoundException.java
new file mode 100644
index 0000000000000000000000000000000000000000..edd097afe8401234b3a61f9bef51b8e644e52bf5
--- /dev/null
+++ b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/api/NotFoundException.java	
@@ -0,0 +1,11 @@
+package eu.decideh2020.statemachine.server.api;
+
+@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-09-30T15:24:56.314Z")
+
+public class NotFoundException extends ApiException {
+    private int code;
+    public NotFoundException (int code, String msg) {
+        super(code, msg);
+        this.code = code;
+    }
+}
diff --git a/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/api/SetStateApi.java b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/api/SetStateApi.java
new file mode 100644
index 0000000000000000000000000000000000000000..6f3c647e150ee2999a3fd44cf32e079cbf76811e
--- /dev/null
+++ b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/api/SetStateApi.java	
@@ -0,0 +1,39 @@
+/**
+ * NOTE: This class is auto generated by the swagger code generator program (2.4.8).
+ * https://github.com/swagger-api/swagger-codegen
+ * Do not edit the class manually.
+ */
+package eu.decideh2020.statemachine.server.api;
+
+import javax.validation.Valid;
+
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import eu.decideh2020.statemachine.server.model.State;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-09-30T15:53:23.605Z")
+
+@Api(value = "setState", description = "the setState API")
+public interface SetStateApi {
+
+    @ApiOperation(value = "Change state from application", nickname = "setState", notes = "Report a new application state in the system", response = State.class, tags={ "state-machine", })
+    @ApiResponses(value = { 
+        @ApiResponse(code = 200, message = "successful operation", response = State.class),
+        @ApiResponse(code = 201, message = "Created"),
+        @ApiResponse(code = 401, message = "Unauthorized"),
+        @ApiResponse(code = 403, message = "Forbidden"),
+        @ApiResponse(code = 404, message = "Not Found") })
+    @RequestMapping(value = "/setState",
+        produces = { "application/json" }, 
+        consumes = { "application/json" },
+        method = RequestMethod.POST)
+    ResponseEntity<State> setState(@ApiParam(value = "State that wants to be reported" ,required=true )  @Valid @RequestBody State state);
+
+}
diff --git a/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/configuration/CustomInstantDeserializer.java b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/configuration/CustomInstantDeserializer.java
new file mode 100644
index 0000000000000000000000000000000000000000..8181319684e7c97f697c3db5639a35957c1e50df
--- /dev/null
+++ b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/configuration/CustomInstantDeserializer.java	
@@ -0,0 +1,232 @@
+package eu.decideh2020.statemachine.server.configuration;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonTokenId;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.datatype.threetenbp.DateTimeUtils;
+import com.fasterxml.jackson.datatype.threetenbp.DecimalUtils;
+import com.fasterxml.jackson.datatype.threetenbp.deser.ThreeTenDateTimeDeserializerBase;
+import com.fasterxml.jackson.datatype.threetenbp.function.BiFunction;
+import com.fasterxml.jackson.datatype.threetenbp.function.Function;
+import org.threeten.bp.DateTimeException;
+import org.threeten.bp.Instant;
+import org.threeten.bp.OffsetDateTime;
+import org.threeten.bp.ZoneId;
+import org.threeten.bp.ZonedDateTime;
+import org.threeten.bp.format.DateTimeFormatter;
+import org.threeten.bp.temporal.Temporal;
+import org.threeten.bp.temporal.TemporalAccessor;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+
+/**
+ * Deserializer for ThreeTen temporal {@link Instant}s, {@link OffsetDateTime}, and {@link ZonedDateTime}s.
+ * Adapted from the jackson threetenbp InstantDeserializer to add support for deserializing rfc822 format.
+ *
+ * @author Nick Williams
+ */
+public class CustomInstantDeserializer<T extends Temporal>
+    extends ThreeTenDateTimeDeserializerBase<T> {
+  private static final long serialVersionUID = 1L;
+
+  public static final CustomInstantDeserializer<Instant> INSTANT = new CustomInstantDeserializer<Instant>(
+      Instant.class, DateTimeFormatter.ISO_INSTANT,
+      new Function<TemporalAccessor, Instant>() {
+        @Override
+        public Instant apply(TemporalAccessor temporalAccessor) {
+          return Instant.from(temporalAccessor);
+        }
+      },
+      new Function<FromIntegerArguments, Instant>() {
+        @Override
+        public Instant apply(FromIntegerArguments a) {
+          return Instant.ofEpochMilli(a.value);
+        }
+      },
+      new Function<FromDecimalArguments, Instant>() {
+        @Override
+        public Instant apply(FromDecimalArguments a) {
+          return Instant.ofEpochSecond(a.integer, a.fraction);
+        }
+      },
+      null
+  );
+
+  public static final CustomInstantDeserializer<OffsetDateTime> OFFSET_DATE_TIME = new CustomInstantDeserializer<OffsetDateTime>(
+      OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME,
+      new Function<TemporalAccessor, OffsetDateTime>() {
+        @Override
+        public OffsetDateTime apply(TemporalAccessor temporalAccessor) {
+          return OffsetDateTime.from(temporalAccessor);
+        }
+      },
+      new Function<FromIntegerArguments, OffsetDateTime>() {
+        @Override
+        public OffsetDateTime apply(FromIntegerArguments a) {
+          return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId);
+        }
+      },
+      new Function<FromDecimalArguments, OffsetDateTime>() {
+        @Override
+        public OffsetDateTime apply(FromDecimalArguments a) {
+          return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId);
+        }
+      },
+      new BiFunction<OffsetDateTime, ZoneId, OffsetDateTime>() {
+        @Override
+        public OffsetDateTime apply(OffsetDateTime d, ZoneId z) {
+          return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime()));
+        }
+      }
+  );
+
+  public static final CustomInstantDeserializer<ZonedDateTime> ZONED_DATE_TIME = new CustomInstantDeserializer<ZonedDateTime>(
+      ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME,
+      new Function<TemporalAccessor, ZonedDateTime>() {
+        @Override
+        public ZonedDateTime apply(TemporalAccessor temporalAccessor) {
+          return ZonedDateTime.from(temporalAccessor);
+        }
+      },
+      new Function<FromIntegerArguments, ZonedDateTime>() {
+        @Override
+        public ZonedDateTime apply(FromIntegerArguments a) {
+          return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId);
+        }
+      },
+      new Function<FromDecimalArguments, ZonedDateTime>() {
+        @Override
+        public ZonedDateTime apply(FromDecimalArguments a) {
+          return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId);
+        }
+      },
+      new BiFunction<ZonedDateTime, ZoneId, ZonedDateTime>() {
+        @Override
+        public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) {
+          return zonedDateTime.withZoneSameInstant(zoneId);
+        }
+      }
+  );
+
+  protected final Function<FromIntegerArguments, T> fromMilliseconds;
+
+  protected final Function<FromDecimalArguments, T> fromNanoseconds;
+
+  protected final Function<TemporalAccessor, T> parsedToValue;
+
+  protected final BiFunction<T, ZoneId, T> adjust;
+
+  protected CustomInstantDeserializer(Class<T> supportedType,
+                    DateTimeFormatter parser,
+                    Function<TemporalAccessor, T> parsedToValue,
+                    Function<FromIntegerArguments, T> fromMilliseconds,
+                    Function<FromDecimalArguments, T> fromNanoseconds,
+                    BiFunction<T, ZoneId, T> adjust) {
+    super(supportedType, parser);
+    this.parsedToValue = parsedToValue;
+    this.fromMilliseconds = fromMilliseconds;
+    this.fromNanoseconds = fromNanoseconds;
+    this.adjust = adjust == null ? new BiFunction<T, ZoneId, T>() {
+      @Override
+      public T apply(T t, ZoneId zoneId) {
+        return t;
+      }
+    } : adjust;
+  }
+
+  @SuppressWarnings("unchecked")
+  protected CustomInstantDeserializer(CustomInstantDeserializer<T> base, DateTimeFormatter f) {
+    super((Class<T>) base.handledType(), f);
+    parsedToValue = base.parsedToValue;
+    fromMilliseconds = base.fromMilliseconds;
+    fromNanoseconds = base.fromNanoseconds;
+    adjust = base.adjust;
+  }
+
+  @Override
+  protected JsonDeserializer<T> withDateFormat(DateTimeFormatter dtf) {
+    if (dtf == _formatter) {
+      return this;
+    }
+    return new CustomInstantDeserializer<T>(this, dtf);
+  }
+
+  @Override
+  public T deserialize(JsonParser parser, DeserializationContext context) throws IOException {
+    //NOTE: Timestamps contain no timezone info, and are always in configured TZ. Only
+    //string values have to be adjusted to the configured TZ.
+    switch (parser.getCurrentTokenId()) {
+      case JsonTokenId.ID_NUMBER_FLOAT: {
+        BigDecimal value = parser.getDecimalValue();
+        long seconds = value.longValue();
+        int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds);
+        return fromNanoseconds.apply(new FromDecimalArguments(
+            seconds, nanoseconds, getZone(context)));
+      }
+
+      case JsonTokenId.ID_NUMBER_INT: {
+        long timestamp = parser.getLongValue();
+        if (context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) {
+          return this.fromNanoseconds.apply(new FromDecimalArguments(
+              timestamp, 0, this.getZone(context)
+          ));
+        }
+        return this.fromMilliseconds.apply(new FromIntegerArguments(
+            timestamp, this.getZone(context)
+        ));
+      }
+
+      case JsonTokenId.ID_STRING: {
+        String string = parser.getText().trim();
+        if (string.length() == 0) {
+          return null;
+        }
+        if (string.endsWith("+0000")) {
+          string = string.substring(0, string.length() - 5) + "Z";
+        }
+        T value;
+        try {
+          TemporalAccessor acc = _formatter.parse(string);
+          value = parsedToValue.apply(acc);
+          if (context.isEnabled(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)) {
+            return adjust.apply(value, this.getZone(context));
+          }
+        } catch (DateTimeException e) {
+          throw _peelDTE(e);
+        }
+        return value;
+      }
+    }
+    throw context.mappingException("Expected type float, integer, or string.");
+  }
+
+  private ZoneId getZone(DeserializationContext context) {
+    // Instants are always in UTC, so don't waste compute cycles
+    return (_valueClass == Instant.class) ? null : DateTimeUtils.timeZoneToZoneId(context.getTimeZone());
+  }
+
+  private static class FromIntegerArguments {
+    public final long value;
+    public final ZoneId zoneId;
+
+    private FromIntegerArguments(long value, ZoneId zoneId) {
+      this.value = value;
+      this.zoneId = zoneId;
+    }
+  }
+
+  private static class FromDecimalArguments {
+    public final long integer;
+    public final int fraction;
+    public final ZoneId zoneId;
+
+    private FromDecimalArguments(long integer, int fraction, ZoneId zoneId) {
+      this.integer = integer;
+      this.fraction = fraction;
+      this.zoneId = zoneId;
+    }
+  }
+}
diff --git a/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/configuration/HomeController.java b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/configuration/HomeController.java
new file mode 100644
index 0000000000000000000000000000000000000000..f60d717794f4d04c7a61b25acdc19a639cb1765b
--- /dev/null
+++ b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/configuration/HomeController.java	
@@ -0,0 +1,16 @@
+package eu.decideh2020.statemachine.server.configuration;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * Home redirection to swagger api documentation 
+ */
+@Controller
+public class HomeController {
+    @RequestMapping(value = "/")
+    public String index() {
+        System.out.println("swagger-ui.html");
+        return "redirect:swagger-ui.html";
+    }
+}
diff --git a/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/configuration/JacksonConfiguration.java b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/configuration/JacksonConfiguration.java
new file mode 100644
index 0000000000000000000000000000000000000000..9c510dd2a772028c3a33a630ff45eabd0f085b89
--- /dev/null
+++ b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/configuration/JacksonConfiguration.java	
@@ -0,0 +1,23 @@
+package eu.decideh2020.statemachine.server.configuration;
+
+import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.threeten.bp.Instant;
+import org.threeten.bp.OffsetDateTime;
+import org.threeten.bp.ZonedDateTime;
+
+@Configuration
+public class JacksonConfiguration {
+
+  @Bean
+  @ConditionalOnMissingBean(ThreeTenModule.class)
+  ThreeTenModule threeTenModule() {
+    ThreeTenModule module = new ThreeTenModule();
+    module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT);
+    module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME);
+    module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
+    return module;
+  }
+}
diff --git a/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/configuration/SwaggerDocumentationConfig.java b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/configuration/SwaggerDocumentationConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..e20ee9cd4ff7c9652798c7aaffa4534607ebcb04
--- /dev/null
+++ b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/configuration/SwaggerDocumentationConfig.java	
@@ -0,0 +1,41 @@
+package eu.decideh2020.statemachine.server.configuration;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.Contact;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+
+@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-09-30T15:24:56.314Z")
+
+@Configuration
+public class SwaggerDocumentationConfig {
+
+    ApiInfo apiInfo() {
+        return new ApiInfoBuilder()
+            .title("State Machine")
+            .description("This is the API documentation for State Machine service of DECIDE h2020 european project")
+            .license("")
+            .licenseUrl("http://unlicense.org")
+            .termsOfServiceUrl("")
+            .version("1.0.0")
+            .contact(new Contact("","", ""))
+            .build();
+    }
+
+    @Bean
+    public Docket customImplementation(){
+        return new Docket(DocumentationType.SWAGGER_2)
+                .select()
+                    .apis(RequestHandlerSelectors.basePackage("eu.decideh2020.statemachine.server.controllers"))
+                    .build()
+                .directModelSubstitute(org.threeten.bp.LocalDate.class, java.sql.Date.class)
+                .directModelSubstitute(org.threeten.bp.OffsetDateTime.class, java.util.Date.class)
+                .apiInfo(apiInfo());
+    }
+
+}
diff --git a/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/model/State.java b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/model/State.java
new file mode 100644
index 0000000000000000000000000000000000000000..daa662b2f57d1b9883783dc4425f0eadf992db20
--- /dev/null
+++ b/State Machine/statemachine/src/gen/eu/decideh2020/statemachine/server/model/State.java	
@@ -0,0 +1,161 @@
+package eu.decideh2020.statemachine.server.model;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.validation.constraints.NotNull;
+
+import org.springframework.validation.annotation.Validated;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * State machine object description
+ */
+@ApiModel(description = "State machine object description")
+@Validated
+@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-09-30T15:24:56.314Z")
+@Entity @IdClass(StateId.class)
+public class State{
+
+	@Id
+	@JsonProperty("user")
+	private String user = null;
+
+	@Id
+	@JsonProperty("app")
+	private String app = null;
+
+	@JsonProperty("status")
+	private String status = null;
+	
+	@JsonIgnore
+	private String last_status = null;
+
+	public State user(String user) {
+		this.user = user;
+		return this;
+	}
+
+	/**
+	 * Id of the user
+	 * 
+	 * @return user
+	 **/
+	@ApiModelProperty(example = "Decide", required = true, value = "Id of the user")
+	@NotNull
+
+	public String getUser() {
+		return user;
+	}
+
+	public void setUser(String user) {
+		this.user = user;
+	}
+
+	public State app(String app) {
+		this.app = app;
+		return this;
+	}
+
+	/**
+	 * Id of the application
+	 * 
+	 * @return app
+	 **/
+	@ApiModelProperty(example = "SockShop", required = true, value = "Id of the application")
+	@NotNull
+
+	public String getApp() {
+		return app;
+	}
+
+	public void setApp(String app) {
+		this.app = app;
+	}
+
+	public State status(String status) {
+		this.status = status;
+		return this;
+	}
+
+	/**
+	 * States of the application. Required values: basicInfo, patterns, containers,
+	 * schema, MCSLA, contracts, deployment or violation
+	 * 
+	 * @return status
+	 **/
+	@ApiModelProperty(example = "basicInfo", value = "States of the application. Required values: basicInfo, patterns, containers, schema, MCSLA, contracts, deployment or violation")
+
+	public String getStatus() {
+		return status;
+	}
+
+	public void setStatus(String status) {
+		this.status = status;
+	}
+	
+	public String getLast_status() {
+		return last_status;
+	}
+
+	public void setLast_status(String last_status) {
+		this.last_status = last_status;
+	}
+
+	@Override
+	public boolean equals(java.lang.Object o) {
+		if (this == o) {
+			return true;
+		}
+		if (o == null || getClass() != o.getClass()) {
+			return false;
+		}
+		State state = (State) o;
+		return Objects.equals(this.user, state.user) && Objects.equals(this.app, state.app)
+				&& Objects.equals(this.status, state.status)
+				&& Objects.equals(this.last_status, state.last_status);
+	}
+
+	@Override
+	public int hashCode() {
+		return Objects.hash(user, app, status, last_status);
+	}
+
+	@Override
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		sb.append("class State {\n");
+		sb.append("    user: ").append(toIndentedString(user)).append("\n");
+		sb.append("    app: ").append(toIndentedString(app)).append("\n");
+		sb.append("    status: ").append(toIndentedString(status)).append("\n");
+		sb.append("    last status: ").append(toIndentedString(last_status)).append("\n");
+		sb.append("}");
+		return sb.toString();
+	}
+
+	/**
+	 * Convert the given object to string with each line indented by 4 spaces
+	 * (except the first line).
+	 */
+	private String toIndentedString(java.lang.Object o) {
+		if (o == null) {
+			return "null";
+		}
+		return o.toString().replace("\n", "\n    ");
+	}
+	
+	
+}
+
+class StateId implements Serializable {
+	String user;
+	String app;
+}
\ No newline at end of file
diff --git a/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/StateMachineApplication.java b/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/StateMachineApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..1d58af1118a86249fea2190db0ee64d0e1b97117
--- /dev/null
+++ b/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/StateMachineApplication.java	
@@ -0,0 +1,39 @@
+package eu.decideh2020.statemachine.server;
+
+
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.boot.ExitCodeGenerator;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@SpringBootApplication()
+@EnableSwagger2
+@EnableJpaRepositories("eu.decideh2020.statemachine.server.repository")
+@ComponentScan(basePackages = { "eu.decideh2020.statemachine.server", "eu.decideh2020.statemachine.server.api"})
+public class StateMachineApplication implements CommandLineRunner {
+
+    @Override
+    public void run(String... arg0) throws Exception {
+        if (arg0.length > 0 && arg0[0].equals("exitcode")) {
+            throw new ExitException();
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        new SpringApplication(StateMachineApplication.class).run(args);
+    }
+
+    class ExitException extends RuntimeException implements ExitCodeGenerator {
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public int getExitCode() {
+            return 10;
+        }
+
+    }
+}
diff --git a/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/controllers/GetStateApiController.java b/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/controllers/GetStateApiController.java
new file mode 100644
index 0000000000000000000000000000000000000000..9585e0e930f72e3460e3af5077d59d53fb3e47bf
--- /dev/null
+++ b/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/controllers/GetStateApiController.java	
@@ -0,0 +1,55 @@
+package eu.decideh2020.statemachine.server.controllers;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import eu.decideh2020.statemachine.server.api.GetStateApi;
+import eu.decideh2020.statemachine.server.model.State;
+import eu.decideh2020.statemachine.server.repository.StateMachineRepository;
+import io.swagger.annotations.ApiParam;
+@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-09-30T15:53:23.605Z")
+
+@Controller
+public class GetStateApiController implements GetStateApi {
+
+    private static final Logger log = LoggerFactory.getLogger(GetStateApiController.class);
+
+    private final ObjectMapper objectMapper;
+
+    private final HttpServletRequest request;
+    
+    @Autowired
+    private StateMachineRepository repository;
+
+    @org.springframework.beans.factory.annotation.Autowired
+    public GetStateApiController(ObjectMapper objectMapper, HttpServletRequest request) {
+        this.objectMapper = objectMapper;
+        this.request = request;
+    }
+
+    public ResponseEntity<State> getState(@NotNull @ApiParam(value = "Id of the user", required = true) @Valid @RequestParam(value = "user", required = true) String user,@NotNull @ApiParam(value = "Id of the application", required = true) @Valid @RequestParam(value = "app", required = true) String app) {
+        String accept = request.getHeader("Accept");
+        if (accept != null && accept.contains("application/json")) {
+            try {
+            	return new ResponseEntity<State>(repository.findStateByUserApp(user, app), HttpStatus.OK);
+            } catch (Exception e) {
+                log.error("Couldn't serialize response for content type application/json", e);
+                return new ResponseEntity<State>(HttpStatus.INTERNAL_SERVER_ERROR);
+            }
+        }
+
+        return new ResponseEntity<State>(HttpStatus.NOT_IMPLEMENTED);
+    }
+
+}
diff --git a/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/controllers/SetStateApiController.java b/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/controllers/SetStateApiController.java
new file mode 100644
index 0000000000000000000000000000000000000000..d689274e7ac265d58eb96988e16aa84742b88a7b
--- /dev/null
+++ b/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/controllers/SetStateApiController.java	
@@ -0,0 +1,400 @@
+package eu.decideh2020.statemachine.server.controllers;
+
+import java.io.File;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.validation.Valid;
+
+import org.apache.commons.io.FileUtils;
+import org.everit.json.schema.ValidationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import eu.DECIDEh2020.appManager.AppManager;
+import eu.DECIDEh2020.appManager.exceptions.AppManagerException;
+import eu.DECIDEh2020.appManager.exceptions.DECIDEValidationException;
+import eu.DECIDEh2020.appManager.models.AppDescription;
+import eu.DECIDEh2020.appManager.models.Container;
+import eu.DECIDEh2020.appManager.models.DetachableResource;
+import eu.DECIDEh2020.appManager.models.Microservice;
+import eu.DECIDEh2020.appManager.models.SchemaElement;
+import eu.DECIDEh2020.appManager.models.VirtualMachine;
+import eu.decideh2020.statemachine.server.api.SetStateApi;
+import eu.decideh2020.statemachine.server.model.State;
+import eu.decideh2020.statemachine.server.model.User;
+import eu.decideh2020.statemachine.server.modules.ActionManagerImpl;
+import eu.decideh2020.statemachine.server.repository.StateMachineRepository;
+import eu.decideh2020.statemachine.server.service.BasicUserService;
+import eu.decideh2020.statemachine.server.util.VaultManager;
+import io.swagger.annotations.ApiParam;
+@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-09-30T15:53:23.605Z")
+
+@Controller
+public class SetStateApiController implements SetStateApi {
+    
+    @Autowired
+	Environment env;
+    
+    @Autowired
+	BasicUserService userService;
+    
+    @Autowired
+    private StateMachineRepository repository;
+
+    private final ObjectMapper objectMapper;
+    
+    @Autowired
+    private ActionManagerImpl actionManager;
+
+    private final HttpServletRequest request;
+    
+    private VaultManager vaultManager = new VaultManager();
+
+    @org.springframework.beans.factory.annotation.Autowired
+    public SetStateApiController(ObjectMapper objectMapper, HttpServletRequest request) {
+        this.objectMapper = objectMapper;
+        this.request = request;
+    }
+
+    public ResponseEntity<State> setState(@ApiParam(value = "State that wants to be reported" ,required=true )  @Valid @RequestBody State state) {
+    	
+    	String ip = request.getRemoteAddr() + "; " + request.getRemoteHost() + "; " + request.getRemotePort() + "; " + request.getRemoteUser();
+    	System.out.println("State received (" + ip +") --->");
+    	System.out.println(state.toString());
+        String accept = request.getHeader("Accept");
+        System.out.println("Accept --> " +  accept);
+        if (accept != null /*&& accept.contains("application/json")*/) {
+        	String user = state.getUser();
+			String app = state.getApp();
+			String transition = state.getStatus();
+			
+			String state2Change = this.changeTransition2State(transition);
+			System.out.println("Received transition: " + transition + "; state to change: " + state2Change);
+			
+			State dbState = repository.findStateByUserApp(user, app);	
+			
+			if(dbState == null){
+				System.out.println("****************** 1");
+				try {
+					dbState = new State();
+					dbState.setApp(app);
+					dbState.setUser(user);
+					dbState.setStatus(state2Change);
+					dbState.setLast_status(state2Change);
+					System.out.println("App " + user + "/" + app + " status " + dbState.getStatus() + " --> Update status to " + state2Change);
+					dbState = repository.save(dbState);
+					System.out.println("State saved ---> " + dbState.toString());
+	                return new ResponseEntity<State>(dbState, HttpStatus.OK);
+	            } catch (Exception e) {
+	            	System.out.println("Error updating last status for " + user + "/" + app + " --> last status to set " + state2Change);
+	                return new ResponseEntity<State>(HttpStatus.INTERNAL_SERVER_ERROR);
+	            }
+			}
+			
+			if(dbState != null && dbState.getStatus().equalsIgnoreCase("Automatic redeployment") && "violation".equalsIgnoreCase(transition)){
+				System.out.println("****************** 2");
+				System.out.println("New violation received - App " + user + "/" + app + " status " + dbState.getStatus() + " --> Discarded violation, app is in redeployment status");
+				return new ResponseEntity<State>(dbState, HttpStatus.OK);
+			}
+						
+			if(dbState != null && dbState.getStatus().equalsIgnoreCase("Automatic redeployment") && !"violation".equalsIgnoreCase(transition)){
+				System.out.println("****************** 3");
+				try {
+					System.out.println("App " + user + "/" + app + " status " + dbState.getStatus() + " --> Update last status to " + state2Change);
+					if(dbState.getLast_status().equals("ADAPT DO")) {
+						dbState.setStatus(state2Change);
+					}
+					dbState.setLast_status(state2Change);
+					dbState = repository.save(dbState);
+					System.out.println("State saved ---> " + dbState.toString());
+	                return new ResponseEntity<State>(dbState, HttpStatus.OK);
+	            } catch (Exception e) {
+	            	System.out.println("Error updating last status for " + user + "/" + app + " --> last status to set " + state2Change);
+	                return new ResponseEntity<State>(HttpStatus.INTERNAL_SERVER_ERROR);
+	            }
+			}
+			
+			if(dbState != null && !dbState.getStatus().equalsIgnoreCase("Monitoring") && "violation".equalsIgnoreCase(transition)){
+				System.out.println("****************** 3 Bis");
+				System.out.println("New violation received - App " + user + "/" + app + " status " + dbState.getStatus() + " --> Discarded violation, app no monitoring");
+				return new ResponseEntity<State>(dbState, HttpStatus.OK);
+			}
+						
+			if(dbState != null && dbState.getStatus().equalsIgnoreCase("Monitoring") && "violation".equalsIgnoreCase(transition)) {
+				System.out.println("****************** 4");
+				System.out.println("New violation received - App " + user + "/" + app + " status " + dbState.getStatus() + " --> Process violation start");
+				state.setStatus("Automatic redeployment");
+				state.setLast_status("Automatic redeployment");
+				state = repository.save(state);
+				
+				String appDescUri = null;
+				String gitToken = null;
+				String billingUsername = null;
+				
+				try {			
+					AppManager appManager = null;
+					AppDescription appDescription = null;
+					Map<String, String> appDescAndToken = vaultManager.readVault(env.getProperty("decide.vh.vaultUrl"), env.getProperty("decide.vh.vaultToken"), user, app);
+					
+					appDescUri = appDescAndToken.get("app_desc_uri");
+					gitToken = appDescAndToken.get("token_git");
+					billingUsername = appDescAndToken.get("billing_username");
+					
+					//Creation of the repository folder
+					String repoPath= env.getProperty("decide.vh.REPOSITORY_PATH");
+					File filePath = new File(repoPath);
+					if(!filePath.exists()) {
+						filePath.mkdirs();
+					}
+					Path path = Paths.get(repoPath);
+					path = Files.createTempDirectory(path, "Decide_");
+					//Initialize the Git repo.
+					System.out.println("Abrimos gitRef: " + appDescUri + "; token: " + gitToken + "; repoPath: " + path.toString());
+					appManager = AppManager.open(appDescUri, gitToken , FileSystems.getDefault().getPath(path.toString()));
+					appManager.sync();
+					appDescription = appManager.getAppDescription();
+					appManager.close();
+					
+					boolean highTechnologicalRisk = appDescription.getHighTechnologicalRisk();
+					System.out.println("High Technological Risk: " + highTechnologicalRisk);
+					if(highTechnologicalRisk) {
+						state.setStatus("OPTIMUS");
+						state.setLast_status("OPTIMUS");
+					} else {
+						try {
+							
+							boolean continueProcess = actionManager.beginOPTIMUSAutomaticRedeployment(state);//Automatic redeployment - Llamada a OPTIMUS
+							Thread.sleep(15000);
+							if(continueProcess)
+								continueProcess = actionManager.beginMCSLAAutomaticRedeployment(state); //Automatic redeployment - Llamada a MCSLA
+							Thread.sleep(15000);
+							if(continueProcess)
+								continueProcess = actionManager.beginACSmIContractingAutomaticRedeployment(state, billingUsername);//Automatic redeployment - Llamada a ACSmI Contracting
+							Thread.sleep(15000);
+							if(continueProcess) {
+								appManager = AppManager.open(appDescUri, gitToken, FileSystems.getDefault().getPath(path.toString()));
+								appManager.sync();
+								appDescription = appManager.getAppDescription();
+								this.updateContainersDockerHostNodeName(appManager, appDescription);
+								this.updateVMDockerPrivateRegistryParams(appManager, appDescription);
+								appManager.close();
+							}
+							Thread.sleep(15000);
+							if(continueProcess) {
+								User userMongo = userService.findByUsername(state.getUser());
+								String mHost = userMongo.getMonitoringHostIp() == null || userMongo.getMonitoringHostIp().isEmpty() ? "http://85.91.40.245" : userMongo.getMonitoringHostIp();
+								String mPort = userMongo.getMonitoringHostPort() == null || userMongo.getMonitoringHostPort().isEmpty() ? "8088" : userMongo.getMonitoringHostPort();
+								System.out.println("*************** Access Mongo database from monitoring... " + mHost + ":" + mPort);
+								continueProcess = actionManager.beginAdaptDOAutomaticRedeployment(state, appDescUri, gitToken, mHost, mPort);	//Automatic redeployment - Llamada a Adapt DO
+							}
+							Thread.sleep(15000);
+						} catch (Exception e) {
+							System.out.println("Error in Automatic redeployment " + e.toString());
+						}
+					}
+					
+					if (Files.exists(path)) {
+						System.out.println("Delete tmp directory");
+			        	FileUtils.deleteDirectory(path.toFile());
+			        }
+					
+					 try {
+						 dbState = repository.findStateByUserApp(user, app);	
+						 System.out.println("App " + user + "/" + app + " status " + dbState.getStatus() + " --> Update status to " + state.getStatus());
+						 state = repository.save(state);
+						 System.out.println("State saved ---> " + state.toString());
+						 return new ResponseEntity<State>(state, HttpStatus.OK);
+		            } catch (Exception e) {
+		                System.out.println("Error updating status for " + user + "/" + app + " --> status to set " + state.getStatus());
+		                return new ResponseEntity<State>(HttpStatus.INTERNAL_SERVER_ERROR);
+		            }
+				} catch (AppManagerException e) {
+					System.out.println("Error processing violation " + e.toString());
+					dbState = repository.findStateByUserApp(user, app);
+					state2Change = dbState.getLast_status();
+					if(state2Change.equalsIgnoreCase("Automatic redeployment")){
+						state2Change = "OPTIMUS";
+					}
+				} catch (Exception e) {
+					System.out.println("Error processing violation " + e.toString());
+					dbState = repository.findStateByUserApp(user, app);
+					state2Change = dbState.getLast_status();
+					if(state2Change.equalsIgnoreCase("Automatic redeployment")){
+						state2Change = "OPTIMUS";
+					}
+				}
+				System.out.println("New violation received - App " + user + "/" + app + " status " + dbState.getStatus() + " --> Process violation end");
+			} else {
+				System.out.println("****************** 5");
+				try {
+					System.out.println("App " + user + "/" + app + " status " + dbState.getStatus() + " --> Update status to " + state2Change);
+					dbState.setStatus(state2Change);
+					dbState.setLast_status(state2Change);
+					dbState = repository.save(dbState);
+					System.out.println("State saved ---> " + dbState.toString());
+	                return new ResponseEntity<State>(dbState, HttpStatus.OK);
+	            } catch (Exception e) {
+	            	System.out.println("Error updating last status for " + user + "/" + app + " --> last status to set " + state2Change);
+	                return new ResponseEntity<State>(HttpStatus.INTERNAL_SERVER_ERROR);
+	            }
+			}
+        } else {
+        	System.out.println("****************** 6");
+        }
+
+        return new ResponseEntity<State>(HttpStatus.NOT_IMPLEMENTED);
+    }
+
+	private void updateVMDockerPrivateRegistryParams(AppManager appManager, AppDescription appDescription) {
+		try {
+			
+			Hashtable<String, Container> dockerPrivateRegistryHash = new Hashtable<>();
+			
+			List<Container> containerList = appDescription.getContainers();
+			if(!containerList.isEmpty()) {
+				for (Container container : containerList) {
+					if(container.getDockerPrivateRegistryIp() != null && container.getDockerPrivateRegistryPort() != null) {
+						dockerPrivateRegistryHash.put(container.getDockerHostNodeName(), container);
+					}
+				}
+			}
+			
+			List<VirtualMachine> vmList = appDescription.getVirtualMachines();
+			if(!vmList.isEmpty()) {
+				for (VirtualMachine vm : vmList) {
+					String key = vm.getDockerHostNodeName();
+					Container container = dockerPrivateRegistryHash.get(key);
+					if(container!=null) {
+						vm.setDockerPrivateRegistryIp(container.getDockerPrivateRegistryIp());
+						vm.setDockerPrivateRegistryPort(container.getDockerPrivateRegistryPort());
+					}
+				}
+			}
+			appDescription.setVirtualMachines(vmList);
+			appManager.writeAndSync(appDescription, "StateMachine update virtualmachines dockerPrivateRegistry");
+			appManager.sync();
+		} catch (DECIDEValidationException e) {
+			e.printStackTrace();
+		    String json = ((ValidationException)e.getCause()).toJSON().toString(4);
+		}catch(Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	private String changeTransition2State(String transition) {
+		String result = null;
+		if("basicInfo".equalsIgnoreCase(transition)) {
+			result = "ARCHITECT";
+		} else if("patterns".equalsIgnoreCase(transition)) {
+			result = "OPTIMUS";
+		} else if("schema".equalsIgnoreCase(transition)) {
+			result = "MCSLA";
+		} else if("MCSLA".equalsIgnoreCase(transition)) {
+			result = "ACSmI Contracting";
+		} else if("contracts".equalsIgnoreCase(transition)) {
+			result = "ADAPT DO";
+		} else if("deployment".equalsIgnoreCase(transition) || "Monitoring".equalsIgnoreCase(transition)) {
+			result = "Monitoring";
+		} else if("violation".equalsIgnoreCase(transition)) {
+			result = "Monitoring";
+		}
+		return result;
+	}
+
+	private void updateContainersDockerHostNodeName(AppManager appManager, AppDescription appDescription) {
+		try {
+			List<SchemaElement> schemaList = appDescription.getSchema();
+			List<Microservice> msList = appDescription.getMicroservices();
+			List<VirtualMachine> vmList = appDescription.getVirtualMachines();
+			
+			Hashtable<String, String> contanerNameHostNameHash = new Hashtable<>();
+			System.out.println("***********************");
+			for (SchemaElement schemaElement : schemaList) {
+				
+				List<String> schemaMSList = schemaElement.getMicroservices();
+				
+				System.out.println("*** 1 *** Schema: " + schemaElement.getVmId() + "; Schema Microservices " + schemaMSList.size());
+				
+				for (String msName : schemaMSList) {
+					String containerName = null;
+					listMS:for (Microservice ms : msList) {
+						if(msName.equals(ms.getId())) {
+							containerName = ms.getName();
+							break listMS;
+						} else {
+							List<DetachableResource> detachableList = ms.getDetachableResources();
+							for (DetachableResource detachableResource : detachableList) {
+								if (msName.equals(detachableResource.getId())) {
+									containerName = ms.getName() + "-" + detachableResource.getClassification();
+									break listMS;
+		                        }
+							}
+		                }
+					}
+					
+					System.out.println("*** 2 *** msName: " + msName + "; containerName " + containerName);
+					
+					for (VirtualMachine virtualMachine : vmList) {
+						if ((schemaElement.getVmId() == Integer.valueOf(virtualMachine.getVmId())) && containerName!=null) {
+							System.out.println("*** 3 *** containerName " + containerName + "; virtualMachine DockerHostNodeName " + virtualMachine.getDockerHostNodeName());
+							contanerNameHostNameHash.put(containerName, virtualMachine.getDockerHostNodeName());
+							break;
+		                }
+					}
+				}
+			}
+			
+			System.out.println("***********************");
+			
+			List<Container> containerList = appDescription.getContainers();
+			if(!containerList.isEmpty()) {
+				
+				for (Container container : containerList) {
+					System.out.println("*** 4 *** containerName " + container.getContainerName() + "; DockerHostNodeName " + container.getDockerHostNodeName());
+				}
+				
+				for (Container container : containerList) {
+					String key = container.getContainerName();
+					String dockerHostNodeName = contanerNameHostNameHash.get(key);
+					if(dockerHostNodeName!=null) {
+//						dockerHostNodeName = dockerHostNodeName.replace(" ", "");
+//						dockerHostNodeName = dockerHostNodeName.replace(".", "_");
+						container.setDockerHostNodeName(dockerHostNodeName);
+					}
+				}
+			}
+			
+			System.out.println("***********************");
+			
+			for (Container container : containerList) {
+				System.out.println("*** 5 *** containerName " + container.getContainerName() + "; DockerHostNodeName " + container.getDockerHostNodeName());
+			}
+			appDescription.setContainers(containerList);
+			
+			System.out.println("***********************");
+			
+			appManager.writeAndSync(appDescription, "StateMachine update containers dockerHostNodeName");
+			appManager.sync();
+		} catch (DECIDEValidationException e) {
+			e.printStackTrace();
+		    String json = ((ValidationException)e.getCause()).toJSON().toString(4);
+		}catch(Exception e) {
+			e.printStackTrace();
+		}	
+	}
+}
diff --git a/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/model/User.java b/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/model/User.java
new file mode 100644
index 0000000000000000000000000000000000000000..1c013d2a597dba7c0bb32c7c8a72cc419e199cec
--- /dev/null
+++ b/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/model/User.java	
@@ -0,0 +1,155 @@
+package eu.decideh2020.statemachine.server.model;
+
+public class User {
+
+    private String username;
+    private String password;
+    private String email;
+    private boolean accountNonExpired;
+    private boolean accountNonLocked;
+    private boolean credentialsNonExpired;
+    private boolean isEnabled;
+    
+    private String dockerRegistry;
+    private String vmAccess;
+    
+    private String cbEndpointIp;
+    private String cbEndpointUser;
+    private String cbEndpointPwd;
+    
+    private String monitoringHostIp;
+    private String monitoringHostPort;
+    
+    private String certificate;
+    private String sshKey;
+    
+    
+    public String getPassword() {
+        return password;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public boolean isAccountNonExpired() {
+        return accountNonExpired;
+    }
+
+    public boolean isAccountNonLocked() {
+        return accountNonLocked;
+    }
+
+    public boolean isCredentialsNonExpired() {
+        return credentialsNonExpired;
+    }
+
+    public boolean isEnabled() {
+        return isEnabled;
+    }
+
+    public void setUsername(final String username) {
+        this.username = username;
+    }
+
+    public void setPassword(final String password) {
+        this.password = password;
+    }
+
+    public void setAccountNonExpired(final boolean accountNonExpired) {
+        this.accountNonExpired = accountNonExpired;
+    }
+
+    public void setAccountNonLocked(final boolean accountNonLocked) {
+        this.accountNonLocked = accountNonLocked;
+    }
+
+    public void setCredentialsNonExpired(final boolean credentialsNonExpired) {
+        this.credentialsNonExpired = credentialsNonExpired;
+    }
+
+    public void setEnabled(final boolean enabled) {
+        isEnabled = enabled;
+    }
+
+	public String getEmail() {
+		return email;
+	}
+
+	public void setEmail(String email) {
+		this.email = email;
+	}
+
+	public String getDockerRegistry() {
+		return dockerRegistry;
+	}
+
+	public void setDockerRegistry(String dockerRegistry) {
+		this.dockerRegistry = dockerRegistry;
+	}
+
+	public String getVmAccess() {
+		return vmAccess;
+	}
+
+	public void setVmAccess(String vmAccess) {
+		this.vmAccess = vmAccess;
+	}
+
+	public String getCbEndpointIp() {
+		return cbEndpointIp;
+	}
+
+	public void setCbEndpointIp(String cbEndpointIp) {
+		this.cbEndpointIp = cbEndpointIp;
+	}
+
+	public String getCbEndpointUser() {
+		return cbEndpointUser;
+	}
+
+	public void setCbEndpointUser(String cbEndpointUser) {
+		this.cbEndpointUser = cbEndpointUser;
+	}
+
+	public String getCbEndpointPwd() {
+		return cbEndpointPwd;
+	}
+
+	public void setCbEndpointPwd(String cbEndpointPwd) {
+		this.cbEndpointPwd = cbEndpointPwd;
+	}
+
+	public String getMonitoringHostIp() {
+		return monitoringHostIp;
+	}
+
+	public void setMonitoringHostIp(String monitoringHostIp) {
+		this.monitoringHostIp = monitoringHostIp;
+	}
+
+	public String getMonitoringHostPort() {
+		return monitoringHostPort;
+	}
+
+	public void setMonitoringHostPort(String monitoringHostPort) {
+		this.monitoringHostPort = monitoringHostPort;
+	}
+
+	public String getCertificate() {
+		return certificate;
+	}
+
+	public void setCertificate(String certificate) {
+		this.certificate = certificate;
+	}
+
+	public String getSshKey() {
+		return sshKey;
+	}
+
+	public void setSshKey(String sshKey) {
+		this.sshKey = sshKey;
+	}
+
+}
diff --git a/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/modules/ActionManagerImpl.java b/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/modules/ActionManagerImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..60c61a942c997489816868a01919690fef90fb3d
--- /dev/null
+++ b/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/modules/ActionManagerImpl.java	
@@ -0,0 +1,202 @@
+package eu.decideh2020.statemachine.server.modules;
+
+import java.io.DataOutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cxf.jaxrs.client.ClientConfiguration;
+import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Service;
+
+import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
+
+import eu.decideh2020.optimus.client.api.DefaultApi;
+import eu.decideh2020.optimus.client.model.ReturnedSimulation;
+import eu.decideh2020.optimus.client.model.Simulation;
+import eu.decideh2020.statemachine.server.model.State;
+
+@Service
+public class ActionManagerImpl implements ActionManager {
+	@Autowired
+	Environment env;
+	
+	@Override
+	public boolean beginOPTIMUSAutomaticRedeployment(State state) {
+		boolean returnValue = false;
+		try {
+			System.out.println("OPTIMUS redeployment process started.....");
+			// Create a Simulation Object
+			Simulation sim = new Simulation();
+			sim.setSimid(0);
+			sim.setSimdate(null);
+			sim.setAppurl(null);
+			sim.setCaller("VH");
+			sim.setStatus(null);
+			sim.setUser(state.getUser());
+			sim.setPss(null);
+			sim.setApp(state.getApp());
+			sim.setSc(null);
+			// Connection instructions
+			JacksonJsonProvider provider = new JacksonJsonProvider();
+			List providers = new ArrayList();
+			providers.add(provider);
+			DefaultApi apiInstance = JAXRSClientFactory.create(env.getProperty("decide.vh.optimusUrl"), DefaultApi.class, providers);
+			org.apache.cxf.jaxrs.client.Client client = WebClient.client(apiInstance);
+			ClientConfiguration config = WebClient.getConfig(client);
+			List<ReturnedSimulation> response = new ArrayList<ReturnedSimulation>();
+			response = apiInstance.createsSimulationUsingPOST(sim);
+			// In this moment the response is a list of simulations but just with an element. I have to re-analyze this aspect.
+			Integer id = response.get(0).getSimid();
+			// If VH needs to know when the simulation finishes this process (my way of do it I mean) can be improved
+			String status = response.get(0).getStatus();
+			while (status.equals("started")) {
+				List<ReturnedSimulation> response2 = new ArrayList<ReturnedSimulation>();
+				response2 = apiInstance.getSimulationUsingGET(id);
+				status = response2.get(0).getStatus();
+			}
+			// If the simulation finished, the schema should be stored in the DECIDE.json in the gitURL repo.
+			state.setLast_status("OPTIMUS");
+			returnValue = true;
+		} catch (Exception e) {
+			System.out.println("Error in OPTIMUS " + e.toString());
+			state.setStatus("OPTIMUS");
+			state.setLast_status("OPTIMUS");
+			returnValue = false;
+		}
+		System.out.println("OPTIMUS redeployment process end");
+		return returnValue;
+	}
+
+	@Override
+	public boolean beginMCSLAAutomaticRedeployment(State state) {
+		boolean returnValue = false;
+		try {
+			System.out.println("MCSLA redeployment process started...");
+			URL obj = new URL("http://85.91.40.245:8082/applications/init?app="+state.getApp()+"&user="+state.getUser()+"&autocommit=true");
+			HttpURLConnection con = (HttpURLConnection) obj.openConnection();
+			con.setRequestMethod("GET");
+			int responseCode = con.getResponseCode();
+			System.out.println("GET Response Code :: " + responseCode);
+			if (responseCode == HttpURLConnection.HTTP_OK) { // success
+				System.out.println("MCSLA redeployment process response code ok (" + responseCode + ")");
+				state.setLast_status("MCSLA");
+				returnValue = true;
+			} else {
+				System.out.println("MCSLA redeployment process response code error (" + responseCode + ")");
+				state.setStatus("MCSLA");
+				state.setLast_status("MCSLA");
+				returnValue = false;
+			}
+		} catch (Exception e) {
+			System.out.println("Error in MCSLA " + e.toString());
+			state.setStatus("MCSLA");
+			state.setLast_status("MCSLA");
+			returnValue = false;
+		}
+		System.out.println("MCSLA redeployment process end");
+		return returnValue;
+	}
+
+	@Override
+	public boolean beginACSmIContractingAutomaticRedeployment(State state, String billingEmail) {
+		boolean returnValue = false;
+		try {
+			System.out.println("ACSmIContracting redeployment process started...");
+			String url = "http://85.91.40.245:8089/decide/acsmi/contracting/api/v1/contracts";
+			URL obj = new URL(url);
+			HttpURLConnection con = (HttpURLConnection) obj.openConnection();
+			con.setRequestMethod("POST");
+			con.setRequestProperty("authorization", "Basic YWNzbWktY29udHJhY3RpbmdAY2xvdWRicm9rZXIuY29tOjUzZDMyOGVhLTQ5YmVhOTc0ZmItNGIwYmM3ZWItODA0MzFm");
+			con.setRequestProperty("accept","application/json");
+			con.setRequestProperty("Content-Type","application/json");
+			con.setDoOutput(true);
+			con.setDoInput(true);
+			DataOutputStream wr = new DataOutputStream(con.getOutputStream());
+			wr.writeBytes("{\"username\": \""+ state.getUser() +"\", \"app_name\":\""+ state.getApp() +"\", \"billing_email\":\""+ billingEmail +"\"}");
+			wr.flush();
+			wr.close();
+
+			int responseCode = con.getResponseCode();
+			if (responseCode == HttpURLConnection.HTTP_OK) { // success
+				System.out.println("ACSmIContracting redeployment process response code ok (" + responseCode + ")");
+				state.setLast_status("ACSmI Contracting");
+				returnValue = true;
+			} else {
+				System.out.println("ACSmIContracting redeployment process response code error (" + responseCode + ")");
+				state.setStatus("ACSmI Contracting");
+				state.setLast_status("ACSmI Contracting");
+				returnValue = false;
+			}
+		} catch (Exception e) {
+			System.out.println("Error in ACSmIContracting " + e.toString());
+			state.setStatus("ACSmI Contracting");
+			state.setLast_status("ACSmI Contracting");
+			returnValue = false;
+		}
+		System.out.println("ACSmIContracting redeployment process end");
+		return returnValue;
+	}
+
+	@Override
+	public boolean beginAdaptDOAutomaticRedeployment(State state, String repoURL, String repoToken, String mHost, String mPort) {
+		boolean returnValue = false;
+		try {
+			System.out.println("AdaptDO redeployment process started...");
+			//String url = "http://178.22.69.102:8473/terraform/oneshot/deployment";
+			String url = "http://82.223.81.97:8473/terraform/oneshot/deployment";
+			URL obj = new URL(url);
+			HttpURLConnection con = (HttpURLConnection) obj.openConnection();
+			con.setRequestMethod("POST");
+//			con.setRequestProperty("authorization", "Basic YWNzbWktY29udHJhY3RpbmdAY2xvdWRicm9rZXIuY29tOjUzZDMyOGVhLTQ5YmVhOTc0ZmItNGIwYmM3ZWItODA0MzFm");
+//			con.setRequestProperty("accept","application/json");
+			con.setRequestProperty("Content-Type","application/json");
+			con.setDoOutput(true);
+			con.setDoInput(true);
+			DataOutputStream wr = new DataOutputStream(con.getOutputStream());
+			String jsonAdapt = "{\"repository_url\": \""+ repoURL +"\", "
+					+ "\"repository_token\":\""+ repoToken +"\", "
+					+ "\"revison\":\"HEAD\", "
+					+ "\"filepath\":\"DECIDE.json\", "
+					+ "\"app_name\":\""+ state.getApp() +"\", "
+					+ "\"monitoring_host\":\""+ mHost +"\", "
+					+ "\"monitoring_port\":\""+ mPort +"\", "
+					+ "\"repository_user\":\""+ state.getUser() +"\"}";
+			System.out.println("****** JSON TO ADAPT --> " + jsonAdapt);
+			wr.writeBytes(jsonAdapt);
+			wr.flush();
+			wr.close();
+
+			int responseCode = con.getResponseCode();
+			if (responseCode >= HttpURLConnection.HTTP_OK  && responseCode < HttpURLConnection.HTTP_MULT_CHOICE) { // success
+				System.out.println("AdaptDO redeployment process response code ok (" + responseCode + ")");
+				state.setLast_status("ADAPT DO");
+				returnValue = true;
+			} else {
+				System.out.println("AdaptDO redeployment process response code error (" + responseCode + ")");
+				state.setStatus("ADAPT DO");
+				state.setLast_status("ADAPT DO");
+				returnValue = false;
+			}
+		} catch (Exception e) {
+			System.out.println("Error in AdaptDO " + e.toString());
+			state.setStatus("ADAPT DO");
+			state.setLast_status("ADAPT DO");
+			returnValue = false;
+		}
+		System.out.println("AdaptDO redeployment process end");
+		return returnValue;
+	}
+
+}
+
+interface ActionManager {
+	public boolean beginOPTIMUSAutomaticRedeployment(State state);
+	public boolean beginMCSLAAutomaticRedeployment(State state);
+	public boolean beginACSmIContractingAutomaticRedeployment(State state, String billingEmail);
+	public boolean beginAdaptDOAutomaticRedeployment(State state, String repoURL, String repoToken, String mHost, String mPort);
+}
diff --git a/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/repository/StateMachineRepository.java b/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/repository/StateMachineRepository.java
new file mode 100644
index 0000000000000000000000000000000000000000..e72ba0682fc46db503e1215f5ca0aca0a123d9b7
--- /dev/null
+++ b/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/repository/StateMachineRepository.java	
@@ -0,0 +1,12 @@
+package eu.decideh2020.statemachine.server.repository;
+
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.CrudRepository;
+
+import eu.decideh2020.statemachine.server.model.State;
+
+public interface StateMachineRepository extends CrudRepository<State, Integer> {
+
+	@Query(value="SELECT * FROM state WHERE user = ?1 AND app = ?2",nativeQuery=true)
+	State findStateByUserApp(String user, String app);
+}
diff --git a/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/repository/UserRepository.java b/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/repository/UserRepository.java
new file mode 100644
index 0000000000000000000000000000000000000000..f1a119550f15031ac5ba38a0f629fc319b8828ad
--- /dev/null
+++ b/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/repository/UserRepository.java	
@@ -0,0 +1,12 @@
+package eu.decideh2020.statemachine.server.repository;
+
+import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.stereotype.Repository;
+
+import eu.decideh2020.statemachine.server.model.User;
+
+@Repository
+public interface UserRepository extends MongoRepository<User, String> {
+
+    User findByUsername(final String userName);
+}
diff --git a/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/service/BasicUserService.java b/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/service/BasicUserService.java
new file mode 100644
index 0000000000000000000000000000000000000000..c0d568a770fe89beee3405b9c974e5bc45ec9091
--- /dev/null
+++ b/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/service/BasicUserService.java	
@@ -0,0 +1,24 @@
+package eu.decideh2020.statemachine.server.service;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import eu.decideh2020.statemachine.server.model.User;
+import eu.decideh2020.statemachine.server.repository.UserRepository;
+
+@Service
+public class BasicUserService implements UserService {
+
+    private final UserRepository repository;
+
+    @Autowired
+    public BasicUserService(final UserRepository repository) {
+        this.repository = repository;
+    }
+
+    @Override
+    public User findByUsername(final String userName) {
+        return repository.findByUsername(userName);
+    }
+    
+}
diff --git a/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/service/UserService.java b/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/service/UserService.java
new file mode 100644
index 0000000000000000000000000000000000000000..d7885454753482d2db445213916121b7f5bdd220
--- /dev/null
+++ b/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/service/UserService.java	
@@ -0,0 +1,9 @@
+package eu.decideh2020.statemachine.server.service;
+
+import eu.decideh2020.statemachine.server.model.User;
+
+public interface UserService {
+
+    User findByUsername(String username);
+
+}
diff --git a/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/util/VaultManager.java b/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/util/VaultManager.java
new file mode 100644
index 0000000000000000000000000000000000000000..9d439e452ce91f11e238d45f193bad0c58b80e16
--- /dev/null
+++ b/State Machine/statemachine/src/main/java/eu/decideh2020/statemachine/server/util/VaultManager.java	
@@ -0,0 +1,28 @@
+package eu.decideh2020.statemachine.server.util;
+
+import java.net.URI;
+import java.util.Map;
+
+import org.springframework.vault.authentication.TokenAuthentication;
+import org.springframework.vault.client.VaultEndpoint;
+import org.springframework.vault.core.VaultTemplate;
+import org.springframework.vault.support.VaultResponseSupport;
+
+public class VaultManager {
+	
+	//Read Vault
+	
+	public Map<String, String> readVault(String vaultUrl, String vaultToken, String userId, String appId) {
+	       Map<String, String> data = null;
+	        try {
+	            VaultEndpoint endpoint = VaultEndpoint.from(new URI(vaultUrl));
+	            VaultTemplate vaultTemplate = new VaultTemplate(endpoint, new TokenAuthentication(vaultToken));
+	            VaultResponseSupport<Map> response = vaultTemplate.read("secret/"+ userId + "/" + appId, Map.class);
+	            data = response.getData();
+	        } catch (Exception e) {
+	            data = null;
+	        }        
+	        return data;
+	    } 
+
+}
diff --git a/State Machine/statemachine/src/main/resources/application.properties b/State Machine/statemachine/src/main/resources/application.properties
new file mode 100644
index 0000000000000000000000000000000000000000..c0642b0b7417869914d5ca8e708cefaebc4ed297
--- /dev/null
+++ b/State Machine/statemachine/src/main/resources/application.properties	
@@ -0,0 +1,20 @@
+springfox.documentation.swagger.v2.path=/api-docs
+server.contextPath=/statemachine
+server.port=5000
+spring.jackson.date-format=eu.decideh2020.statemachine.server.RFC3339DateFormat
+spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false
+
+spring.jpa.hibernate.ddl-auto=update
+spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
+spring.datasource.url=jdbc:mysql://85.91.40.245:3506/db_statemachine?useSSL=false
+spring.datasource.username=root
+spring.datasource.password=root
+
+decide.vh.REPOSITORY_PATH = /decide-projects
+decide.vh.vaultUrl = http://85.91.40.245:8200
+decide.vh.vaultToken = s.DnyGwJETRWdP6EVIbE6ZLIkv
+decide.vh.optimusUrl = http://85.91.40.245:8090/optimussimulation
+
+spring.data.mongodb.host=85.91.40.245
+spring.data.mongodb.port=27017
+spring.data.mongodb.database=decideapp
\ No newline at end of file
diff --git a/StateMachine b/StateMachine
deleted file mode 160000
index c2b5faf3de3b7acc0fa69e71075bd494b4284b2a..0000000000000000000000000000000000000000
--- a/StateMachine
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit c2b5faf3de3b7acc0fa69e71075bd494b4284b2a