This repository has been archived by the owner on Jul 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' for 1.0.0
- Loading branch information
Showing
49 changed files
with
1,302 additions
and
429 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,17 @@ | ||
FROM azul/zulu-openjdk-alpine:8-jre | ||
FROM openjdk:8 | ||
|
||
ARG BUILD_DATE | ||
ARG BUILD_VERSION | ||
|
||
LABEL maintainer="[email protected]" | ||
LABEL org.label-schema.schema-version="1.0" | ||
LABEL org.label-schema.build-date=$BUILD_DATE | ||
LABEL org.label-schema.name="5GEVE/-exp-nsd-composer" | ||
LABEL org.label-schema.description="A REST API module to compose experiment NSDs. It can also validate blueprints and generate NSDs from them." | ||
LABEL org.label-schema.vcs-url="https://github.com/5GEVE/-exp-nsd-composer" | ||
LABEL org.label-schema.version=$BUILD_VERSION | ||
LABEL org.label-schema.docker.cmd="docker run -p 8086:8086 mpergolesi/exp-nsd-composer" | ||
|
||
EXPOSE 8086 | ||
COPY ./target/*.jar /app.jar | ||
CMD java -jar app.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/it/cnit/blueprint/composer/CorsConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package it.cnit.blueprint.composer; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.servlet.config.annotation.CorsRegistry; | ||
import org.springframework.web.servlet.config.annotation.EnableWebMvc; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
@Configuration | ||
public class CorsConfiguration implements WebMvcConfigurer { | ||
|
||
@Override | ||
public void addCorsMappings(CorsRegistry registry) { | ||
registry.addMapping("/**"); | ||
} | ||
|
||
} |
38 changes: 25 additions & 13 deletions
38
src/main/java/it/cnit/blueprint/composer/OpenApiConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,31 @@ | ||
package it.cnit.blueprint.composer; | ||
|
||
import io.swagger.v3.oas.annotations.OpenAPIDefinition; | ||
import io.swagger.v3.oas.annotations.info.Info; | ||
import io.swagger.v3.oas.annotations.info.License; | ||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.oas.models.info.Contact; | ||
import org.springframework.boot.info.BuildProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@OpenAPIDefinition( | ||
info = @Info( | ||
title = "5G EVE Experiment NSD composer", | ||
description = | ||
"A REST API module to compose experiment NSDs. It can also validate blueprints and" | ||
+ " generate NSDs from them.", | ||
version = "v0.1.0", | ||
license = @License(name = "Apache 2.0") | ||
) | ||
) | ||
@Configuration | ||
public class OpenApiConfiguration { | ||
|
||
final BuildProperties buildProperties; | ||
|
||
public OpenApiConfiguration(BuildProperties buildProperties) { | ||
this.buildProperties = buildProperties; | ||
} | ||
|
||
@Bean | ||
public OpenAPI customOpenAPI() { | ||
return new OpenAPI().info(new io.swagger.v3.oas.models.info.Info() | ||
.title("5G EVE Experiment NSD composer") | ||
.description("A REST API module to compose experiment NSDs. " | ||
+ "It can also validate blueprints and generate NSDs from them.") | ||
.version(buildProperties.getVersion()) | ||
.license(new io.swagger.v3.oas.models.info.License().name("Apache 2.0")) | ||
.contact(new Contact() | ||
.name("GitHub") | ||
.url("https://github.com/5GEVE/-exp-nsd-composer/"))); | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/it/cnit/blueprint/composer/commons/ObjectMapperService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package it.cnit.blueprint.composer.commons; | ||
|
||
import com.fasterxml.jackson.databind.DeserializationFeature; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.ObjectReader; | ||
import com.fasterxml.jackson.databind.ObjectWriter; | ||
import com.fasterxml.jackson.databind.SerializationFeature; | ||
import it.nextworks.nfvmano.catalogue.blueprint.elements.Blueprint; | ||
import it.nextworks.nfvmano.libs.ifa.descriptors.nsd.Nsd; | ||
import lombok.AllArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@Slf4j | ||
@AllArgsConstructor | ||
public class ObjectMapperService { | ||
|
||
private final ObjectMapper objectMapper; | ||
|
||
/** | ||
* @return An ObjectMapper with FAIL_ON_UNKNOWN_PROPERTIES=false | ||
*/ | ||
public ObjectReader createSafeBlueprintReader() { | ||
return objectMapper.readerFor(Blueprint.class) | ||
.without(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); | ||
} | ||
|
||
/** | ||
* @return An ObjectMapper with INDENT_OUTPUT=true | ||
*/ | ||
public ObjectWriter createIndentNsdWriter() { | ||
return objectMapper.writerFor(Nsd.class).with(SerializationFeature.INDENT_OUTPUT); | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/it/cnit/blueprint/composer/commons/ZipService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package it.cnit.blueprint.composer.commons; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.util.List; | ||
import java.util.zip.ZipEntry; | ||
import java.util.zip.ZipOutputStream; | ||
import lombok.AllArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.core.io.InputStreamResource; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@Slf4j | ||
@AllArgsConstructor | ||
public class ZipService { | ||
|
||
@SuppressWarnings("ResultOfMethodCallIgnored") | ||
public ResponseEntity<InputStreamResource> getZipResponse(List<File> files, boolean cleanUp) | ||
throws IOException { | ||
File zipFile = Files.createTempFile("enc-output-", ".zip").toFile(); | ||
ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(zipFile)); | ||
for (File f : files) { | ||
zipOut.putNextEntry(new ZipEntry(f.getName())); | ||
FileInputStream fis = new FileInputStream(f); | ||
byte[] bytes = new byte[1024]; | ||
int length; | ||
while ((length = fis.read(bytes)) >= 0) { | ||
zipOut.write(bytes, 0, length); | ||
} | ||
fis.close(); | ||
} | ||
zipOut.close(); | ||
ResponseEntity<InputStreamResource> response = ResponseEntity.ok() | ||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + zipFile.getName()) | ||
.contentType(MediaType.APPLICATION_OCTET_STREAM) | ||
.contentLength(zipFile.length()) | ||
.body(new InputStreamResource(new FileInputStream(zipFile))); | ||
if (cleanUp){ | ||
for (File f : files) { | ||
f.delete(); | ||
} | ||
zipFile.delete(); | ||
} | ||
return response; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
src/main/java/it/cnit/blueprint/composer/nsd/graph/GraphExporter.java
This file was deleted.
Oops, something went wrong.
72 changes: 0 additions & 72 deletions
72
src/main/java/it/cnit/blueprint/composer/nsd/graph/GraphVizExporter.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.