Added AppController M24

parent 8df826a5
/classes/
*.class
*.lst
# Created by .ignore support plugin (hsz.mobi)
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
*.iml
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
# Gradle:
.idea/**/gradle.xml
.idea/**/libraries
# CMake
cmake-build-debug/
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### Maven template
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
pom.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
!/.mvn/wrapper/maven-wrapper.jar
### Eclipse template
.project
.classpath
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
/classes/
*.class
*.lst
# Created by .ignore support plugin (hsz.mobi)
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
*.iml
.idea/
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
# Gradle:
.idea/**/gradle.xml
.idea/**/libraries
# CMake
cmake-build-debug/
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### Maven template
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
pom.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
!/.mvn/wrapper/maven-wrapper.jar
### Eclipse template
.project
.classpath
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
#Windows specific
*~
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<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>app-controller</artifactId>
<version>0.0.12</version>
<repositories>
<repository>
<id>jgit-repository</id>
<url>https://repo.eclipse.org/content/groups/releases/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>4.11.0.201803080745-r</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.5</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>com.github.everit-org.json-schema</groupId>
<artifactId>org.everit.json.schema</artifactId>
<version>1.9.1</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<outputFile>${project.build.directory}/${project.artifactId}-${project.version}-fat.jar</outputFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<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>app-controller</artifactId>
<version>0.0.16-SNAPSHOT</version>
<distributionManagement>
<repository>
<id>paca</id>
<name>Paca Releases Repo</name>
<url>https://paca.fokus.fraunhofer.de/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>paca</id>
<url>https://paca.fokus.fraunhofer.de/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<scm>
<connection>scm:git:https://${GITLAB_USER_LDAP}:${GITLAB_USER_PASSWORD}@gitlab.fokus.fraunhofer.de/${CI_PROJECT_PATH}</connection>
<url>https://${GITLAB_USER_LDAP}:${GITLAB_USER_PASSWORD}@gitlab.fokus.fraunhofer.de/${CI_PROJECT_PATH}</url>
<developerConnection>scm:git:https://${GITLAB_USER_LDAP}:${GITLAB_USER_PASSWORD}@gitlab.fokus.fraunhofer.de/${CI_PROJECT_PATH}</developerConnection>
<tag>HEAD</tag>
</scm>
<repositories>
<repository>
<id>jgit-repository</id>
<url>https://repo.eclipse.org/content/groups/releases/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>5.1.1.201809181055-r</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.6</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.6</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.6</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>com.github.everit-org.json-schema</groupId>
<artifactId>org.everit.json.schema</artifactId>
<version>1.9.1</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<tagNameFormat>v@{project.version}</tagNameFormat>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>true</minimizeJar>
<shadedArtifactAttached>true</shadedArtifactAttached>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package eu.DECIDEh2020.appManager;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.util.Collections;
import java.util.UUID;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.DECIDEh2020.appManager.exceptions.DECIDEValidationException;
import eu.DECIDEh2020.appManager.models.AppDescription;
import eu.DECIDEh2020.appManager.models.Microservice;
import org.everit.json.schema.Schema;
import org.everit.json.schema.ValidationException;
import org.everit.json.schema.loader.SchemaLoader;
import org.json.JSONObject;
import org.json.JSONTokener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AppDescriptionFactory {
private static Logger log = LoggerFactory.getLogger(AppDescriptionFactory.class);
private static Schema schema;
static {
try (InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("application_description.schema.json")) {
JSONObject rawSchema = new JSONObject(new JSONTokener(inputStream));
schema = SchemaLoader.load(rawSchema);
} catch (IOException e) {
log.error("reading schema", e);
}
/*
JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("application_description.schema.json");
try {
schema = factory.getJsonSchema(new ObjectMapper().readTree(is));
} catch (ProcessingException | IOException e) {
log.error("reading json schema", e);
}
*/
}
public static AppDescription createAppDescription(String name) {
AppDescription appDescription = new AppDescription();
appDescription.setId(UUID.randomUUID().toString());
appDescription.setName(name);
appDescription.setVersion("0.2.2-alpha");
appDescription.setHighTechnologicalRisk(false);
appDescription.setMicroservices(Collections.singletonList(createMicroservice("Default")));
return appDescription;
}
public static Microservice createMicroservice(String name) {
Microservice microservice = new Microservice();
microservice.setId(UUID.randomUUID().toString());
microservice.setName(name);
microservice.setEndpoints(Collections.singletonList("http://mircroservice1.com/service"));
return microservice;
}
public static AppDescription loadAppDescription(Path path) {
try {
return new ObjectMapper().readValue(path.toFile(), AppDescription.class);
} catch (IOException e) {
log.error("reading app description file", e);
return null;
}
}
public static AppDescription fromJson(String jsonString) throws JsonParseException, JsonMappingException, IOException {
return new ObjectMapper().readValue(jsonString, AppDescription.class);
}
public static void validateAppDescription(AppDescription appDescription) throws DECIDEValidationException {
try {
schema.validate(new JSONObject(new ObjectMapper().writeValueAsString(appDescription)));
} catch (JsonProcessingException e) {
log.error("json to string", e);
throw new DECIDEValidationException(e);
} catch (ValidationException e) {
log.error("validating json", e);
throw new DECIDEValidationException(e);
}
}
public static void validateAppDescription(JsonNode appDescription) throws DECIDEValidationException {
try {
validateAppDescription(new ObjectMapper().treeToValue(appDescription, AppDescription.class));
} catch (JsonProcessingException e) {
log.error("json to value", e);
throw new DECIDEValidationException(e);
}
}
}
/*
* Copyright (c) 2017 Fraunhofer FOKUS.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the
* GNU AGPL v3 which accompanies
* this distribution, and is available at
* http://www.gnu.org/licenses/agpl.txt
*
* Contributors:
* Simon Dutkowski Fraunhofer FOKUS
*
* Initially developed in the context of DECIDE EU project www.DECIDE-h2020.eu
*/
package eu.DECIDEh2020.appManager;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.util.UUID;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.DECIDEh2020.appManager.exceptions.DECIDEValidationException;
import eu.DECIDEh2020.appManager.models.AppDescription;
import eu.DECIDEh2020.appManager.models.Microservice;
import org.everit.json.schema.Schema;
import org.everit.json.schema.ValidationException;
import org.everit.json.schema.loader.SchemaLoader;
import org.json.JSONObject;
import org.json.JSONTokener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AppDescriptionFactory {
private static Logger log = LoggerFactory.getLogger(AppDescriptionFactory.class);
private static Schema schema;
static {
try (InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("application_description.schema.json")) {
JSONObject rawSchema = new JSONObject(new JSONTokener(inputStream));
schema = SchemaLoader.load(rawSchema);
} catch (IOException e) {
log.error("reading schema", e);
}
/*
JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("application_description.schema.json");
try {
schema = factory.getJsonSchema(new ObjectMapper().readTree(is));
} catch (ProcessingException | IOException e) {
log.error("reading json schema", e);
}
*/
}
public static AppDescription createAppDescription(String name) {
AppDescription appDescription = new AppDescription();
appDescription.setId(UUID.randomUUID().toString());
appDescription.setName(name);
appDescription.setVersion("0.2.2-alpha");
appDescription.setHighTechnologicalRisk(false);
appDescription.getMicroservices().add(createMicroservice("Default"));
return appDescription;
}
public static Microservice createMicroservice(String name) {
Microservice microservice = new Microservice();
microservice.setId(UUID.randomUUID().toString());
microservice.setName(name);
microservice.getEndpoints().add("http://mircroservice1.com/service");
return microservice;
}
public static AppDescription loadAppDescription(Path path) {
try {
return new ObjectMapper().readValue(path.toFile(), AppDescription.class);
} catch (IOException e) {
log.error("reading app description file", e);
return null;
}
}
public static AppDescription fromJson(String jsonString) throws JsonParseException, JsonMappingException, IOException {
return new ObjectMapper().readValue(jsonString, AppDescription.class);
}
public static void validateAppDescription(AppDescription appDescription) throws DECIDEValidationException {
try {
schema.validate(new JSONObject(new ObjectMapper().writeValueAsString(appDescription)));
} catch (JsonProcessingException e) {
log.error("json to string", e);
throw new DECIDEValidationException(e);
} catch (ValidationException e) {
log.error("validating json", e);
throw new DECIDEValidationException(e);
}
}
public static void validateAppDescription(JsonNode appDescription) throws DECIDEValidationException {
try {
validateAppDescription(new ObjectMapper().treeToValue(appDescription, AppDescription.class));
} catch (JsonProcessingException e) {
log.error("json to value", e);
throw new DECIDEValidationException(e);
}
}
}
package eu.DECIDEh2020.appManager;
import eu.DECIDEh2020.appManager.models.AppDescription;
import eu.DECIDEh2020.appManager.models.Microservice;
import eu.DECIDEh2020.appManager.models.Nfr;
import eu.DECIDEh2020.appManager.models.Pattern;
import java.util.HashSet;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;