Skip to content
This repository has been archived by the owner on Jul 21, 2021. It is now read-only.

Commit

Permalink
Merge pull request #193 from International-Data-Spaces-Association/de…
Browse files Browse the repository at this point in the history
…velopment

Release v7.1.0
  • Loading branch information
tmberthold authored Jun 29, 2021
2 parents a600e9f + 7959a70 commit 12c5055
Show file tree
Hide file tree
Showing 73 changed files with 1,566 additions and 129 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ All notable changes to this project will be documented in this file.

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [7.1.0] - 2021-06-29

### Added
- Minor Change: New Feature: Camel Support
- Minor Change: New API POST /api/ui/route/error caches error messages of the routes until they are fetched by the corresponding GET API (takes every String as RequestBody)
- Minor Change: New API GET /api/ui/route/error all intermediate errors of the routes can be queried, once queried these are deleted in the backend (only cached until GET API called)

### Dependency Maintenance
- Upgrade: org.springframework.security:spring-security-test 5.5.0 -> 5.5.1
- Upgrade: org.postgresql:postgresql 42.2.20 -> 42.2.22
- Upgrade: org.springframework.boot:spring-boot-starter-parent 2.5.0 -> 2.5.2

## [7.0.0] - 2021-05-26
### Major Changes
- Remove 20 unused APIs (= 1.150 lines of code) (unused by ConfigManager-UI project)
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ LABEL org.opencontainers.image.source="https://github.com/International-Data-Spa

RUN mkdir /app

COPY --from=maven /tmp/target/*.jar /app/configurationmanager-7.0.0.jar
COPY --from=maven /tmp/target/*.jar /app/configurationmanager-7.1.0.jar

WORKDIR /app/

ENTRYPOINT ["java","-Dfile.encoding=UTF-8","-jar","configurationmanager-7.0.0.jar"]
ENTRYPOINT ["java","-Dfile.encoding=UTF-8","-jar","configurationmanager-7.1.0.jar"]
15 changes: 11 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<!-- License: Apache License, Version 2.0 -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.0</version>
<version>2.5.2</version>
<relativePath/>
</parent>

<groupId>de.fraunhofer.isst</groupId>
<artifactId>configurationmanager</artifactId>
<version>7.0.0</version>
<version>7.1.0</version>
<name>Configuration Manager</name>
<description>Configuration Manager developed by the Fraunhofer ISST</description>

Expand Down Expand Up @@ -149,7 +149,7 @@
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<version>5.5.0</version>
<version>5.5.1</version>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -209,9 +209,16 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.20</version>
<version>42.2.22</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.velocity/velocity -->
<!-- License: Apache License, Version 2.0 -->
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>

<!-- Infomodel -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@EnableScheduling
@SpringBootApplication
public class ConfigmanagerApplication {
public static final String CURRENT_VERSION = "7.0.0";
public static final String CURRENT_VERSION = "7.1.0";

public static void main(final String[] args) {
if (log.isInfoEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.net.URI;
Expand Down Expand Up @@ -73,4 +74,14 @@ ResponseEntity<String> getEndpointInformation(@RequestParam(value = "routeId") U
@ApiResponse(responseCode = "200", description = "Returns the list of the app routes")
@ApiResponse(responseCode = "500", description = "Internal server error")
ResponseEntity<String> getAppRoutes();

@PostMapping(value = "/route/error", produces = "application/ld+json")
@Operation(summary = "Save route related errors in the ConfigManager-backend")
@ApiResponse(responseCode = "200", description = "Saved Route-Error in ConfigManager-backend.")
ResponseEntity<String> setRouteError(@RequestBody String policy);

@GetMapping(value = "/route/error", produces = "application/ld+json")
@Operation(summary = "Get new route related errors")
@ApiResponse(responseCode = "200", description = "Loaded and returned cached Route-Errors.")
ResponseEntity<String> getRouteErrors();
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.stream.Collectors;

/**
* The api class implements the AppRouteApi and offers the possibilities to manage
Expand All @@ -44,6 +46,8 @@ public class AppRouteController implements AppRouteApi {
transient RouteDeployMethodRepository routeDeployMethodRepository;
transient ObjectMapper objectMapper;

LinkedList<String> routeErrors = new LinkedList<>();

@Autowired
public AppRouteController(final ConfigModelService configModelService,
final AppRouteService appRouteService,
Expand Down Expand Up @@ -399,4 +403,20 @@ private void updateDeployMethodFromRoutes(final RouteDeployMethod routeDeployMet
configModelService.saveState();
}
}

@Override
public ResponseEntity<String> setRouteError(String routeError) {
if (routeErrors.size() >= 100) {
routeErrors.remove(0);
}

routeErrors.add(routeError);

return ResponseEntity.ok("Saved Route-Error in ConfigManager-backend.");
}

@Override
public ResponseEntity<String> getRouteErrors() {
return ResponseEntity.ok(routeErrors.stream().collect(Collectors.joining(",", "[", "]")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
import de.fraunhofer.isst.configmanager.data.repositories.CustomAppRepository;
import de.fraunhofer.isst.configmanager.data.repositories.EndpointInformationRepository;
import de.fraunhofer.isst.configmanager.data.repositories.RouteDeployMethodRepository;
import de.fraunhofer.isst.configmanager.util.camel.RouteManager;
import de.fraunhofer.isst.configmanager.util.camel.exceptions.RouteCreationException;
import de.fraunhofer.isst.configmanager.util.camel.exceptions.RouteDeletionException;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -35,31 +40,18 @@
@Slf4j
@Service
@Transactional
@AllArgsConstructor(onConstructor = @__(@Autowired))
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
public class AppRouteService {

transient ConfigModelService configModelService;
transient EndpointService endpointService;
transient ResourceService resourceService;
transient RouteManager routeManager;
transient RouteDeployMethodRepository routeDeployMethodRepository;
transient EndpointInformationRepository endpointInformationRepository;
transient CustomAppRepository customAppRepository;

@Autowired
public AppRouteService(final ConfigModelService configModelService,
final RouteDeployMethodRepository routeDeployMethodRepository,
final EndpointInformationRepository endpointInformationRepository,
final CustomAppRepository customAppRepository,
final EndpointService endpointService,
final ResourceService resourceService) {
this.configModelService = configModelService;
this.routeDeployMethodRepository = routeDeployMethodRepository;
this.endpointInformationRepository = endpointInformationRepository;
this.customAppRepository = customAppRepository;
this.endpointService = endpointService;
this.resourceService = resourceService;
}

/**
* This method creates an app route.
*
Expand Down Expand Up @@ -112,6 +104,13 @@ public boolean deleteAppRoute(final URI routeId) {
deleted = configModelService.getConfigModel().getAppRoute().remove(appRoute);

if (deleted) {
try {
routeManager.deleteRoute(appRoute);
} catch (RouteDeletionException e) {
if (log.isErrorEnabled()){
log.error(e.getMessage(), e);
}
}
configModelService.saveState();
}
}
Expand All @@ -134,7 +133,7 @@ public AppRoute getAppRoute(final URI routeId) {
* @return list of app routes
*/
public List<AppRoute> getAppRoutes() {
return (List<AppRoute>) configModelService.getConfigModel().getAppRoute();
return configModelService.getConfigModel().getAppRoute();
}

/**
Expand Down Expand Up @@ -219,6 +218,15 @@ public RouteStep createAppRouteStep(final URI routeId, final URI startId,
._appRouteEnd_(Util.asList(endpoint))
._appRouteOutput_(Util.asList(resourceImpl))
.build();

// Creating camel route
try {
routeManager.createAndDeployXMLRoute(configModelService.getConfigModel(), appRouteImpl);
} catch (RouteCreationException e) {
if (log.isErrorEnabled()){
log.error(e.getMessage(), e);
}
}
} else {
routeStep = new RouteStepBuilder()._routeDeployMethod_(deployMethod)
._appRouteStart_(Util.asList(startEndpoint))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package de.fraunhofer.isst.configmanager.connector.dataspaceconnector.util;

import de.fraunhofer.iais.eis.AppRoute;
import de.fraunhofer.iais.eis.ConnectorEndpoint;
import de.fraunhofer.iais.eis.GenericEndpoint;
import lombok.AccessLevel;
import lombok.Setter;
import lombok.experimental.FieldDefaults;
import org.apache.commons.codec.binary.Base64;
import org.apache.velocity.VelocityContext;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Component;

/**
* Utility class for configuring Camel routes for the Dataspace Connector.
*/
@Component
@FieldDefaults(level = AccessLevel.PRIVATE)
public class DataspaceConnectorRouteConfigurer {

/**
* Username for the Dataspace Connector.
*/
@Setter
@Value("${dataspace.connector.api.username}")
String dataSpaceConnectorApiUsername;

/**
* Password for the Dataspace Connector.
*/
@Setter
@Value("${dataspace.connector.api.password}")
String dataSpaceConnectorApiPassword;

/**
* ResourceLoader for loading Camel route templates from the classpath.
*/
final ResourceLoader RESOURCE_LOADER = new DefaultResourceLoader();

/**
* Adds basic authentication information for the Dataspace Connector to the Velocity context
* for creating a Camel XML route to be used with the Dataspace Connector.
*
* @param velocityContext the context containing the values to insert into the route template
*/
public void addBasicAuthToContext(final VelocityContext velocityContext) {
final var auth = dataSpaceConnectorApiUsername + ":" + dataSpaceConnectorApiPassword;
final var encodedAuth = Base64.encodeBase64(auth.getBytes());
final var authHeader = "Basic " + new String(encodedAuth);
velocityContext.put("connectorAuthHeader", authHeader);
}

/**
* Chooses and returns the route template for the Dataspace Connector based on the app route.
*
* @param appRoute the app route
* @return the route template
*/
public Resource getRouteTemplate(final AppRoute appRoute) {
final var routeStart = appRoute.getAppRouteStart();

Resource resource;
if (routeStart.get(0) instanceof GenericEndpoint) {
resource = RESOURCE_LOADER.getResource("classpath:camel-templates/dataspaceconnector/http_to_connector_template.vm");
} else if (routeStart.get(0) instanceof ConnectorEndpoint) {
resource = RESOURCE_LOADER.getResource("classpath:camel-templates/dataspaceconnector/connector_to_http_template.vm");
} else {
resource = null;
}

return resource;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package de.fraunhofer.isst.configmanager.connector.trustedconnector;

import de.fraunhofer.iais.eis.BaseConnector;
import de.fraunhofer.iais.eis.ConfigurationModel;
import de.fraunhofer.iais.eis.ConfigurationModelBuilder;
import de.fraunhofer.iais.eis.ConnectorDeployMode;
import de.fraunhofer.iais.eis.ConnectorStatus;
import de.fraunhofer.iais.eis.LogLevel;
import de.fraunhofer.isst.configmanager.connector.clients.DefaultConnectorClient;
import de.fraunhofer.isst.configmanager.data.util.QueryInput;
import lombok.NoArgsConstructor;
import okhttp3.Response;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.stereotype.Service;

import java.net.URI;

@Service
@NoArgsConstructor
@ConditionalOnExpression("${dataspace.connector.enabled:false} == false")
public class TrustedConnectorClient implements DefaultConnectorClient {

@Override
public boolean sendConfiguration(final String configurationModel) {
return false;
}

@Override
public void getConnectorStatus() {

}

@Override
public ConfigurationModel getConfiguration() {
return new ConfigurationModelBuilder()
._configurationModelLogLevel_(LogLevel.NO_LOGGING)
._connectorStatus_(ConnectorStatus.CONNECTOR_ONLINE)
._connectorDeployMode_(ConnectorDeployMode.TEST_DEPLOYMENT)
._keyStorePassword_("password")
._keyStore_(URI.create("file://cert-stores/keystore.p12"))
._trustStorePassword_("password")
._trustStore_(URI.create("file://cert-stores/truststore.p12"))
.build();
}

@Override
public BaseConnector getBaseConnector(final String accessURL, final String resourceId) {
return null;
}

@Override
public String getPolicyPattern(final String policy) {
return null;
}

@Override
public BaseConnector getSelfDeclaration() {
return null;
}

@Override
public String requestContractAgreement(final String recipientId,
final String requestedArtifactId,
final String contractOffer) {
return null;
}

@Override
public Response requestData(final String recipientId,
final String requestedArtifactId,
final String contractId,
final String key,
final QueryInput queryInput) {
return null;
}
}
Loading

0 comments on commit 12c5055

Please sign in to comment.