is service
This commit is contained in:
parent
a55d27e5bd
commit
a2382411fe
|
@ -1,51 +0,0 @@
|
|||
server {
|
||||
listen $API_PORT default_server;
|
||||
listen [::]:$API_PORT default_server;
|
||||
|
||||
root /var/www/html;
|
||||
|
||||
index index.html index.htm index.nginx-debian.html;
|
||||
|
||||
server_name _;
|
||||
|
||||
location /context-manager/ {
|
||||
proxy_pass http://context-manager:$SPRING_BOOT_PORT/context-manager/;
|
||||
}
|
||||
|
||||
location /dsm/ {
|
||||
proxy_pass http://dsm:$SPRING_BOOT_PORT/dsm/;
|
||||
}
|
||||
|
||||
location /mail-sender/ {
|
||||
proxy_pass http://mail-sender:$SPRING_BOOT_PORT/mail-sender/;
|
||||
}
|
||||
|
||||
location /index-manager/ {
|
||||
proxy_pass http://index-manager:$SPRING_BOOT_PORT/index-manager/;
|
||||
}
|
||||
|
||||
location /mdsm/ {
|
||||
proxy_pass http://mdsm:$SPRING_BOOT_PORT/mdsm/;
|
||||
}
|
||||
|
||||
location /oai-manager/ {
|
||||
proxy_pass http://oai-manager:$SPRING_BOOT_PORT/oai-manager/;
|
||||
}
|
||||
|
||||
location /resource-manager/ {
|
||||
proxy_pass http://resource-manager:$SPRING_BOOT_PORT/resource-manager/;
|
||||
}
|
||||
|
||||
location /vocabulary-manager/ {
|
||||
proxy_pass http://vocabulary-manager:$SPRING_BOOT_PORT/vocabulary-manager/;
|
||||
}
|
||||
|
||||
location /wf-aggregation-postgres/ {
|
||||
proxy_pass http://wf-aggregation-postgres:$SPRING_BOOT_PORT/wf-exec/;
|
||||
}
|
||||
|
||||
location /wf-manager/ {
|
||||
proxy_pass http://wf-manager:$SPRING_BOOT_PORT/wf-manager/;
|
||||
}
|
||||
|
||||
}
|
|
@ -12,44 +12,8 @@ server {
|
|||
proxy_pass http://angular-dev:4200/;
|
||||
}
|
||||
|
||||
location /ajax/context-manager/ {
|
||||
proxy_pass http://context-manager:$SPRING_BOOT_PORT/context-manager/ajax/;
|
||||
}
|
||||
|
||||
location /ajax/dsm/ {
|
||||
proxy_pass http://dsm:$SPRING_BOOT_PORT/dsm/ajax/;
|
||||
}
|
||||
|
||||
location /ajax/mail-sender/ {
|
||||
proxy_pass http://mail-sender:$SPRING_BOOT_PORT/mail-sender/ajax/;
|
||||
}
|
||||
|
||||
location /ajax/index-manager/ {
|
||||
proxy_pass http://index-manager:$SPRING_BOOT_PORT/index-manager/ajax/;
|
||||
}
|
||||
|
||||
location /ajax/mdsm/ {
|
||||
proxy_pass http://mdsm:$SPRING_BOOT_PORT/mdsm/ajax/;
|
||||
}
|
||||
|
||||
location /ajax/oai-manager/ {
|
||||
proxy_pass http://oai-manager:$SPRING_BOOT_PORT/oai-manager/ajax/;
|
||||
}
|
||||
|
||||
location /ajax/resource-manager/ {
|
||||
proxy_pass http://resource-manager:$SPRING_BOOT_PORT/resource-manager/ajax/;
|
||||
}
|
||||
|
||||
location /ajax/vocabulary-manager/ {
|
||||
proxy_pass http://vocabulary-manager:$SPRING_BOOT_PORT/vocabulary-manager/ajax/;
|
||||
}
|
||||
|
||||
location /ajax/wf-aggregation-postgres/ {
|
||||
proxy_pass http://wf-aggregation-postgres:$SPRING_BOOT_PORT/wf-exec/ajax/;
|
||||
}
|
||||
|
||||
location /ajax/wf-manager/ {
|
||||
proxy_pass http://wf-manager:$SPRING_BOOT_PORT/wf-manager/ajax/;
|
||||
location /ajax/ {
|
||||
proxy_pass http://is-manager:$SPRING_BOOT_PORT/is/ajax/;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Fetching latest version of Java
|
||||
FROM openjdk:18
|
||||
FROM openjdk:21
|
||||
|
||||
# Setting up work directory
|
||||
WORKDIR /app
|
||||
|
|
|
@ -18,7 +18,7 @@ import eu.dnetlib.errors.InformationServiceException;
|
|||
import eu.dnetlib.services.contexts.service.ContextService;
|
||||
|
||||
@RestController
|
||||
@RequestMapping({ "/ajax/contexts", "/api/contexts" })
|
||||
@RequestMapping("/api/contexts")
|
||||
public class ApiController extends DnetRestController {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Fetching latest version of Java
|
||||
FROM openjdk:18
|
||||
FROM openjdk:21
|
||||
|
||||
# Setting up work directory
|
||||
WORKDIR /app
|
||||
|
|
|
@ -25,7 +25,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
|||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@RestController
|
||||
@RequestMapping({ "/ajax/ds-api", "/api/ds-api" })
|
||||
@RequestMapping("/api/ds-api")
|
||||
@Tag(name = "OpenAIRE DSM API - datasource APIs methods", description = "the OpenAIRE Datasource Manager API - datasource APIs methods")
|
||||
public class DsApiController extends AbstractDsmController {
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||
import jakarta.validation.Valid;
|
||||
|
||||
@RestController
|
||||
@RequestMapping({ "/ajax/ds", "/api/ds" })
|
||||
@RequestMapping("/api/ds")
|
||||
@Tag(name = "OpenAIRE DSM API - datasource methods", description = "the OpenAIRE Datasource Manager API - datasource methods")
|
||||
public class DsController extends AbstractDsmController {
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import eu.dnetlib.services.dsm.service.ProtocolService;
|
|||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@RestController
|
||||
@RequestMapping({ "/ajax", "/api" })
|
||||
@RequestMapping("/api")
|
||||
@Tag(name = "OpenAIRE DSM API - other methods", description = "the OpenAIRE Datasource Manager API - other methods")
|
||||
public class OtherController extends AbstractDsmController {
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import eu.dnetlib.domain.protocol.ProtocolDesc;
|
|||
import eu.dnetlib.services.dsm.service.ProtocolService;
|
||||
|
||||
@RestController
|
||||
@RequestMapping({ "/api/protocols", "/ajax/protocols" })
|
||||
@RequestMapping("/api/protocols")
|
||||
public class ProtocolController extends DnetRestController {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -35,7 +35,7 @@ import eu.dnetlib.services.dsm.utils.ResponseUtils;
|
|||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@RestController
|
||||
@RequestMapping({ "/ajax", "/api" })
|
||||
@RequestMapping("/api")
|
||||
@Tag(name = "OpenAIRE DSM API - search methods", description = "the OpenAIRE Datasource Manager API - search methods")
|
||||
public class SearchController extends AbstractDsmController {
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Fetching latest version of Java
|
||||
FROM openjdk:18
|
||||
FROM openjdk:21
|
||||
|
||||
# Setting up work directory
|
||||
WORKDIR /app
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Fetching latest version of Java
|
||||
FROM openjdk:18
|
||||
FROM openjdk:21
|
||||
|
||||
# Setting up work directory
|
||||
WORKDIR /app
|
||||
|
|
|
@ -21,7 +21,7 @@ import eu.dnetlib.errors.InformationServiceException;
|
|||
import eu.dnetlib.services.index.repository.service.IndexConfigurationService;
|
||||
|
||||
@RestController
|
||||
@RequestMapping({ "/ajax/index", "/api/index" })
|
||||
@RequestMapping("/api/index")
|
||||
public class ApiController extends DnetRestController {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
# Fetching latest version of Java
|
||||
FROM openjdk:21
|
||||
|
||||
# Setting up work directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the jar file into our app
|
||||
COPY ./target/*.jar /app/app.jar
|
||||
|
||||
# Exposing port 8080
|
||||
EXPOSE 8080
|
||||
|
||||
# Starting the application
|
||||
CMD ["java", "-jar", "app.jar"]
|
|
@ -0,0 +1,75 @@
|
|||
<?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">
|
||||
|
||||
<parent>
|
||||
<groupId>eu.dnetlib.docker</groupId>
|
||||
<artifactId>apps</artifactId>
|
||||
<version>7.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>dnet-is-manager</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>dnet-app-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mail -->
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>mail</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- hot swapping, disable cache for template, enable live reload -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Tests -->
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-help-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,15 @@
|
|||
package eu.dnetlib.is;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
import eu.dnetlib.common.app.AbstractDnetApp;
|
||||
|
||||
@SpringBootApplication
|
||||
public class MainApplication extends AbstractDnetApp {
|
||||
|
||||
public static void main(final String[] args) {
|
||||
SpringApplication.run(MainApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package eu.dnetlib.is.controller;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.client.HttpStatusCodeException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import eu.dnetlib.is.service.ServiceRegistry;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/ajax")
|
||||
public class AjaxProxyController {
|
||||
|
||||
@Autowired
|
||||
private ServiceRegistry registry;
|
||||
|
||||
private static final Log log = LogFactory.getLog(AjaxProxyController.class);
|
||||
|
||||
@RequestMapping("/{service}/**")
|
||||
public ResponseEntity<?> mirrorRest(@PathVariable final String service,
|
||||
@RequestBody(required = false) final String body,
|
||||
final HttpMethod method,
|
||||
final HttpServletRequest request,
|
||||
final HttpServletResponse response)
|
||||
throws URISyntaxException {
|
||||
|
||||
try {
|
||||
log.info("* Received call for service " + service);
|
||||
|
||||
final String requestUrl = request.getRequestURI();
|
||||
|
||||
final String baseUrl = registry.findBaseUrl(service);
|
||||
|
||||
log.info("* Local Request URL: " + requestUrl);
|
||||
|
||||
if (StringUtils.isBlank(baseUrl)) { return ResponseEntity.status(HttpStatus.NOT_FOUND).body("The required service is not registered: " + service); }
|
||||
|
||||
final URI uri = UriComponentsBuilder.fromHttpUrl(baseUrl)
|
||||
.path(requestUrl)
|
||||
.query(request.getQueryString())
|
||||
.build(true)
|
||||
.toUri();
|
||||
|
||||
log.info("* Service Base URL: " + baseUrl);
|
||||
log.info("* Service Request URL: " + uri.toString());
|
||||
|
||||
final HttpHeaders headers = new HttpHeaders();
|
||||
final Enumeration<String> headerNames = request.getHeaderNames();
|
||||
while (headerNames.hasMoreElements()) {
|
||||
final String headerName = headerNames.nextElement();
|
||||
headers.set(headerName, request.getHeader(headerName));
|
||||
}
|
||||
|
||||
final HttpEntity<String> httpEntity = new HttpEntity<>(body, headers);
|
||||
final RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
return restTemplate.exchange(uri, method, httpEntity, String.class);
|
||||
} catch (final HttpStatusCodeException e) {
|
||||
return ResponseEntity.status(e.getStatusCode())
|
||||
.headers(e.getResponseHeaders())
|
||||
.body(e.getResponseBodyAsString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package eu.dnetlib.is.controller;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import eu.dnetlib.common.controller.DnetRestController;
|
||||
import eu.dnetlib.domain.service.ServiceStatus;
|
||||
import eu.dnetlib.is.service.ServiceRegistry;
|
||||
|
||||
@Controller
|
||||
public class ApiController extends DnetRestController {
|
||||
|
||||
@Autowired
|
||||
private ServiceRegistry registry;
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/api/register/{service}", method = { RequestMethod.GET, RequestMethod.POST })
|
||||
public ServiceStatus registerService(@PathVariable final String service, @RequestParam final String baseUrl) {
|
||||
return registry.registerService(service, baseUrl);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@GetMapping("/api/services")
|
||||
public Map<String, ServiceStatus> services() {
|
||||
return registry.availableServices();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package eu.dnetlib.is.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import eu.dnetlib.common.controller.DnetMainController;
|
||||
|
||||
@Controller
|
||||
public class MainController extends DnetMainController {
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package eu.dnetlib.is.service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import eu.dnetlib.domain.service.ServiceStatus;
|
||||
|
||||
@Service
|
||||
public class ServiceRegistry {
|
||||
|
||||
private final Map<String, ServiceStatus> map = new HashMap<>();
|
||||
|
||||
public String findBaseUrl(final String service) {
|
||||
final ServiceStatus s = map.get(service);
|
||||
return s != null ? s.getBaseUrl() : null;
|
||||
}
|
||||
|
||||
public ServiceStatus registerService(final String service, final String baseUrl) {
|
||||
final ServiceStatus status = new ServiceStatus(baseUrl);
|
||||
map.put(service, status);
|
||||
return status;
|
||||
}
|
||||
|
||||
public Map<String, ServiceStatus> availableServices() {
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
server.title = D-NET Information Service
|
||||
server.description = D-NET Information Service
|
||||
server.servlet.context-path = /is
|
||||
server.public_url =
|
||||
|
||||
maven.pom.path = /META-INF/maven/eu.dnetlib.docker/dnet-is-manager/effective-pom.xml
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
# Fetching latest version of Java
|
||||
FROM openjdk:18
|
||||
FROM openjdk:21
|
||||
|
||||
# Setting up work directory
|
||||
WORKDIR /app
|
||||
|
|
|
@ -26,7 +26,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@RestController
|
||||
@RequestMapping({ "/ajax/mdstores", "/api/mdstores" })
|
||||
@RequestMapping("/api/mdstores")
|
||||
@Tag(name = "Metadata Stores")
|
||||
public class ApiController extends DnetRestController {
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ import java.util.stream.Collectors;
|
|||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -57,7 +57,7 @@ public class MDStoreService {
|
|||
@Autowired
|
||||
private MDStoreSqlBackend sqlBackend;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MDStoreService.class);
|
||||
private static final Log log = LogFactory.getLog(MDStoreService.class);
|
||||
|
||||
public static final String REFRESH_MODE = "REFRESH";
|
||||
public static final String INCREMENTAL_MODE = "INCREMENTAL";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Fetching latest version of Java
|
||||
FROM openjdk:18
|
||||
FROM openjdk:21
|
||||
|
||||
# Setting up work directory
|
||||
WORKDIR /app
|
||||
|
|
|
@ -19,7 +19,7 @@ import eu.dnetlib.services.oai.service.OaiService;
|
|||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
|
||||
@RestController
|
||||
@RequestMapping({ "/ajax/oai", "/api/oai" })
|
||||
@RequestMapping("/api/oai")
|
||||
public class ApiController extends DnetRestController {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Fetching latest version of Java
|
||||
FROM openjdk:18
|
||||
FROM openjdk:21
|
||||
|
||||
# Setting up work directory
|
||||
WORKDIR /app
|
||||
|
|
|
@ -26,7 +26,7 @@ import jakarta.servlet.http.HttpServletRequest;
|
|||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
@RestController
|
||||
@RequestMapping({ "/ajax", "/api" })
|
||||
@RequestMapping("/api")
|
||||
public class ApiController extends DnetRestController {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Fetching latest version of Java
|
||||
FROM openjdk:18
|
||||
FROM openjdk:21
|
||||
|
||||
# Setting up work directory
|
||||
WORKDIR /app
|
||||
|
|
|
@ -18,7 +18,7 @@ import eu.dnetlib.errors.InformationServiceException;
|
|||
import eu.dnetlib.services.vocabularies.service.VocabularyService;
|
||||
|
||||
@RestController
|
||||
@RequestMapping({ "/ajax/vocs", "/api/vocs" })
|
||||
@RequestMapping("/api/vocs")
|
||||
public class ApiController extends DnetRestController {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Fetching latest version of Java
|
||||
FROM openjdk:18
|
||||
FROM openjdk:21
|
||||
|
||||
# Setting up work directory
|
||||
WORKDIR /app
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Fetching latest version of Java
|
||||
FROM openjdk:18
|
||||
FROM openjdk:21
|
||||
|
||||
# Setting up work directory
|
||||
WORKDIR /app
|
||||
|
|
|
@ -22,7 +22,7 @@ import eu.dnetlib.domain.wfs.WfSubscription;
|
|||
import eu.dnetlib.wfs.manager.service.WorkflowManagerService;
|
||||
|
||||
@RestController
|
||||
@RequestMapping({ "/ajax", "/api" })
|
||||
@RequestMapping("/api")
|
||||
public class ApiController extends DnetRestController {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -18,7 +18,7 @@ import jakarta.servlet.http.HttpServletRequest;
|
|||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/ajax/mapping")
|
||||
@RequestMapping("/api/mapping")
|
||||
public class MappingAjaxController extends DnetRestController {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>dnet-is-manager</module>
|
||||
<module>dnet-resource-manager</module>
|
||||
<module>dnet-mdstore-manager</module>
|
||||
<module>dnet-context-manager</module>
|
||||
|
|
|
@ -3,25 +3,30 @@ package eu.dnetlib.common.app;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.InetAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springdoc.core.models.GroupedOpenApi;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import eu.dnetlib.common.clients.DnetServiceClientFactory;
|
||||
import eu.dnetlib.common.clients.IsManagerClient;
|
||||
import eu.dnetlib.domain.service.ServiceStatus;
|
||||
import eu.dnetlib.errors.DnetRuntimeException;
|
||||
import io.micrometer.core.instrument.ImmutableTag;
|
||||
import io.micrometer.core.instrument.Metrics;
|
||||
|
@ -43,6 +48,12 @@ public abstract class AbstractDnetApp {
|
|||
@Value("${maven.pom.path}")
|
||||
private ClassPathResource pom;
|
||||
|
||||
@Value("${server.port:8080}")
|
||||
private int serverPort;
|
||||
|
||||
@Value("${server.servlet.context-path}")
|
||||
private String serverContextPath;
|
||||
|
||||
@Value("${server.title}")
|
||||
private String serverTitle;
|
||||
|
||||
|
@ -52,7 +63,15 @@ public abstract class AbstractDnetApp {
|
|||
@Value("${server.public_url}")
|
||||
private String serverPublicUrl;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AbstractDnetApp.class);
|
||||
@Value("${dnet.service.name}")
|
||||
private String serviceName;
|
||||
|
||||
@Value("${dnet.is.url}")
|
||||
private String informationServiceUrl;
|
||||
|
||||
private static final Log log = LogFactory.getLog(AbstractDnetApp.class);
|
||||
|
||||
private static final ScheduledThreadPoolExecutor registrationThreadPoolExecutor = new ScheduledThreadPoolExecutor(1);
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
|
@ -70,6 +89,20 @@ public abstract class AbstractDnetApp {
|
|||
} catch (IOException | XmlPullParserException e) {
|
||||
log.error("Error registering metric", e);
|
||||
}
|
||||
|
||||
registrationThreadPoolExecutor.scheduleAtFixedRate(() -> {
|
||||
final IsManagerClient client = new IsManagerClient();
|
||||
client.setBaseUrl(informationServiceUrl);
|
||||
|
||||
try {
|
||||
final ServiceStatus status =
|
||||
client.registerService(serviceName, "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + serverPort + serverContextPath);
|
||||
|
||||
log.info("Service registered: " + status.getDate());
|
||||
} catch (final Throwable e) {
|
||||
log.warn("Error registering service", e);
|
||||
}
|
||||
}, 10, 300, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
@ -98,6 +131,8 @@ public abstract class AbstractDnetApp {
|
|||
|
||||
@Bean
|
||||
public DnetServiceClientFactory dnetServiceClientFactory() {
|
||||
// TODO (HIGH PRIORITY) - THIS VALUES SHOULD BE UPDATED DINAMYCALLY CONTACTING THE IS-MANAGER
|
||||
|
||||
try (InputStream input = getClass().getResourceAsStream("/dnet-services.properties")) {
|
||||
final Properties prop = new Properties();
|
||||
prop.load(input);
|
||||
|
|
|
@ -2,6 +2,11 @@ package eu.dnetlib.common.clients;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
public class DnetServiceClient {
|
||||
|
@ -22,22 +27,30 @@ public class DnetServiceClient {
|
|||
}
|
||||
|
||||
protected <T> T httpPostParams(final String path, final Map<String, Object> params, final Class<T> responseClazz) {
|
||||
return new RestTemplate().postForObject(baseUrl + path, params, responseClazz);
|
||||
final HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
||||
|
||||
final LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
|
||||
params.forEach((k, v) -> map.add(k, v));
|
||||
|
||||
final ResponseEntity<T> response = new RestTemplate().postForEntity(baseUrl + path, new HttpEntity<>(map, headers), responseClazz);
|
||||
|
||||
return response.getBody();
|
||||
}
|
||||
|
||||
protected final String getBaseUrl() {
|
||||
public final String getBaseUrl() {
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
protected final void setBaseUrl(final String baseUrl) {
|
||||
public final void setBaseUrl(final String baseUrl) {
|
||||
this.baseUrl = baseUrl;
|
||||
}
|
||||
|
||||
protected final DnetServiceClientFactory getFactory() {
|
||||
public final DnetServiceClientFactory getFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
protected final void setFactory(final DnetServiceClientFactory factory) {
|
||||
public final void setFactory(final DnetServiceClientFactory factory) {
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package eu.dnetlib.common.clients;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import eu.dnetlib.domain.service.ServiceStatus;
|
||||
|
||||
public class IsManagerClient extends DnetServiceClient {
|
||||
|
||||
public ServiceStatus registerService(final String serviceName, final String serviceBaseUrl) {
|
||||
final Map<String, Object> params = new HashMap<>();
|
||||
params.put("baseUrl", serviceBaseUrl);
|
||||
return httpPostParams("/api/register/" + URLEncoder.encode(serviceName, StandardCharsets.UTF_8), params, ServiceStatus.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package eu.dnetlib.common.controller;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
@ -11,7 +11,7 @@ import eu.dnetlib.common.controller.parts.ErrorMessage;
|
|||
|
||||
public class DnetRestController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(DnetRestController.class);
|
||||
private static final Log log = LogFactory.getLog(DnetRestController.class);
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#TODO (HIGH PRIORITY) - THIS VALUES SHOULD BE OBTAINED BY THE IS-MANAGER
|
||||
dnet.services.context-manager.baseUrl = http://context-manager:8080/context-manager
|
||||
dnet.services.datasource-manager.baseUrl = http://dsm:8080/dsm
|
||||
dnet.services.mail-sender.baseUrl = http://mail-sender:8080/mail-sender
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
package eu.dnetlib.domain.service;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class ServiceStatus implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4913228769231373286L;
|
||||
|
||||
private String baseUrl;
|
||||
|
||||
private LocalDateTime date;
|
||||
|
||||
public ServiceStatus() {}
|
||||
|
||||
public ServiceStatus(final String baseUrl, final LocalDateTime date) {
|
||||
this.baseUrl = baseUrl;
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public ServiceStatus(final String baseUrl) {
|
||||
this.baseUrl = baseUrl;
|
||||
date = LocalDateTime.now();
|
||||
}
|
||||
|
||||
public String getBaseUrl() {
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
public LocalDateTime getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setBaseUrl(final String baseUrl) {
|
||||
this.baseUrl = baseUrl;
|
||||
}
|
||||
|
||||
public void setDate(final LocalDateTime date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
}
|
|
@ -251,8 +251,8 @@
|
|||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven.compiler.plugin.version}</version>
|
||||
<configuration>
|
||||
<source>18</source>
|
||||
<target>18</target>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
<forceJavacCompilerUse>true</forceJavacCompilerUse>
|
||||
</configuration>
|
||||
|
|
|
@ -1,5 +1,18 @@
|
|||
version: "3"
|
||||
services:
|
||||
is-manager:
|
||||
build: ./dnet-app/apps/dnet-is-manager
|
||||
expose:
|
||||
- ${SPRING_BOOT_PORT}
|
||||
networks:
|
||||
- backend
|
||||
- frontend
|
||||
environment:
|
||||
- DNET_SERVICE_NAME=is-manager
|
||||
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}/is
|
||||
profiles:
|
||||
- base
|
||||
|
||||
context-manager:
|
||||
build: ./dnet-app/apps/dnet-context-manager
|
||||
expose:
|
||||
|
@ -7,8 +20,11 @@ services:
|
|||
networks:
|
||||
- backend
|
||||
depends_on:
|
||||
- is-manager
|
||||
- db-main
|
||||
environment:
|
||||
- DNET_SERVICE_NAME=context-manager
|
||||
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}/is
|
||||
- SPRING_DATASOURCE_URL=jdbc:postgresql://db-main:${PG_PORT}/${PG_CONTEXTS_DB}
|
||||
- SPRING_DATASOURCE_USERNAME=${PG_USER}
|
||||
- SPRING_DATASOURCE_PASSWORD=${PG_PASSWORD}
|
||||
|
@ -22,8 +38,11 @@ services:
|
|||
networks:
|
||||
- backend
|
||||
depends_on:
|
||||
- is-manager
|
||||
- db-main
|
||||
environment:
|
||||
- DNET_SERVICE_NAME=vocabulary-manager
|
||||
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}/is
|
||||
- SPRING_DATASOURCE_URL=jdbc:postgresql://db-main:${PG_PORT}/${PG_VOCS_DB}
|
||||
- SPRING_DATASOURCE_USERNAME=${PG_USER}
|
||||
- SPRING_DATASOURCE_PASSWORD=${PG_PASSWORD}
|
||||
|
@ -38,7 +57,10 @@ services:
|
|||
- backend
|
||||
depends_on:
|
||||
- db-main
|
||||
- is-manager
|
||||
environment:
|
||||
- DNET_SERVICE_NAME=dsm
|
||||
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}/is
|
||||
- SPRING_DATASOURCE_URL=jdbc:postgresql://db-main:${PG_PORT}/${PG_DSM_DB}
|
||||
- SPRING_DATASOURCE_USERNAME=${PG_USER}
|
||||
- SPRING_DATASOURCE_PASSWORD=${PG_PASSWORD}
|
||||
|
@ -53,7 +75,10 @@ services:
|
|||
- backend
|
||||
depends_on:
|
||||
- db-main
|
||||
- is-manager
|
||||
environment:
|
||||
- DNET_SERVICE_NAME=index-manager
|
||||
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}/is
|
||||
- SPRING_DATASOURCE_URL=jdbc:postgresql://db-main:${PG_PORT}/${PG_INDEX_DB}
|
||||
- SPRING_DATASOURCE_USERNAME=${PG_USER}
|
||||
- SPRING_DATASOURCE_PASSWORD=${PG_PASSWORD}
|
||||
|
@ -71,7 +96,10 @@ services:
|
|||
depends_on:
|
||||
- db-main
|
||||
- db-mdstores-data
|
||||
- is-manager
|
||||
environment:
|
||||
- DNET_SERVICE_NAME=mdsm
|
||||
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}/is
|
||||
- SPRING_DATASOURCE_URL=jdbc:postgresql://db-main:${PG_PORT}/${PG_MAIN_DB}
|
||||
- SPRING_DATASOURCE_USERNAME=${PG_USER}
|
||||
- SPRING_DATASOURCE_PASSWORD=${PG_PASSWORD}
|
||||
|
@ -89,7 +117,10 @@ services:
|
|||
- backend
|
||||
depends_on:
|
||||
- db-oai
|
||||
- is-manager
|
||||
environment:
|
||||
- DNET_SERVICE_NAME=oai-manager
|
||||
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}/is
|
||||
- SPRING_DATASOURCE_URL=jdbc:postgresql://db-oai:${PG_PORT}/${PG_OAI_DB}
|
||||
- SPRING_DATASOURCE_USERNAME=${PG_USER}
|
||||
- SPRING_DATASOURCE_PASSWORD=${PG_PASSWORD}
|
||||
|
@ -104,7 +135,10 @@ services:
|
|||
- backend
|
||||
depends_on:
|
||||
- db-main
|
||||
- is-manager
|
||||
environment:
|
||||
- DNET_SERVICE_NAME=resource-manager
|
||||
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}/is
|
||||
- SPRING_DATASOURCE_URL=jdbc:postgresql://db-main:${PG_PORT}/${PG_MAIN_DB}
|
||||
- SPRING_DATASOURCE_USERNAME=${PG_USER}
|
||||
- SPRING_DATASOURCE_PASSWORD=${PG_PASSWORD}
|
||||
|
@ -120,7 +154,10 @@ services:
|
|||
depends_on:
|
||||
- db-main
|
||||
- db-mdstores-data
|
||||
- is-manager
|
||||
environment:
|
||||
- DNET_SERVICE_NAME=wf-aggregation-postgres
|
||||
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}/is
|
||||
- SPRING_DATASOURCE_URL=jdbc:postgresql://db-main:${PG_PORT}/${PG_WFS_DB}
|
||||
- SPRING_DATASOURCE_USERNAME=${PG_USER}
|
||||
- SPRING_DATASOURCE_PASSWORD=${PG_PASSWORD}
|
||||
|
@ -143,7 +180,10 @@ services:
|
|||
- backend
|
||||
depends_on:
|
||||
- db-main
|
||||
- is-manager
|
||||
environment:
|
||||
- DNET_SERVICE_NAME=wf-manager
|
||||
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}/is
|
||||
- SPRING_DATASOURCE_URL=jdbc:postgresql://db-main:${PG_PORT}/${PG_WFS_DB}
|
||||
- SPRING_DATASOURCE_USERNAME=${PG_USER}
|
||||
- SPRING_DATASOURCE_PASSWORD=${PG_PASSWORD}
|
||||
|
@ -156,6 +196,11 @@ services:
|
|||
- ${SPRING_BOOT_PORT}
|
||||
networks:
|
||||
- backend
|
||||
depends_on:
|
||||
- is-manager
|
||||
environment:
|
||||
- DNET_SERVICE_NAME=mail-sender
|
||||
- DNET_IS_URL=http://is-manager:${SPRING_BOOT_PORT}/is
|
||||
profiles:
|
||||
- mail
|
||||
|
||||
|
@ -280,7 +325,6 @@ services:
|
|||
image: nginx
|
||||
volumes:
|
||||
- ./data/nginx-templates/development.conf.template:/etc/nginx/templates/default.conf.template
|
||||
- ./data/nginx-templates/api.conf.template:/etc/nginx/templates/api.conf.template
|
||||
ports:
|
||||
- ${PUBLIC_PORT}:${PUBLIC_PORT}
|
||||
- ${PUBLIC_API_PORT}:${PUBLIC_API_PORT}
|
||||
|
@ -292,16 +336,7 @@ services:
|
|||
- API_PORT=${PUBLIC_API_PORT}
|
||||
- SPRING_BOOT_PORT=${SPRING_BOOT_PORT}
|
||||
depends_on:
|
||||
- context-manager
|
||||
- dsm
|
||||
- mail-sender
|
||||
- index-manager
|
||||
- mdsm
|
||||
- oai-manager
|
||||
- resource-manager
|
||||
- vocabulary-manager
|
||||
- wf-aggregation-postgres
|
||||
- wf-manager
|
||||
- is-manager
|
||||
- angular-dev
|
||||
profiles:
|
||||
- ui
|
||||
|
|
2
start.sh
2
start.sh
|
@ -19,7 +19,7 @@ export PG_MDSTORES_DATA_DB=dnet_mdstores_data
|
|||
export PG_INDEX_DB=dnet_index_configs
|
||||
export PG_OAI_DB=dnet_oai
|
||||
|
||||
#export COMPOSE_PROFILES=base,index,oai
|
||||
#export COMPOSE_PROFILES=base
|
||||
export COMPOSE_PROFILES=base,mail,dsm,vocs,mdstores,wfs,index,contexts,oai,ui
|
||||
|
||||
docker-compose -f docker-compose.dev.yml up --force-recreate --build
|
||||
|
|
Loading…
Reference in New Issue