refactoring
This commit is contained in:
parent
eefbaf0607
commit
7b5d26ada1
|
@ -3,10 +3,43 @@ package eu.dnetlib.broker;
|
|||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
import eu.dnetlib.common.app.AbstractDnetApp;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.Tag;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
|
||||
@SpringBootApplication
|
||||
public class LiteratureBrokerServiceApplication {
|
||||
public class LiteratureBrokerServiceApplication extends AbstractDnetApp {
|
||||
|
||||
public static final String TAG_EVENTS = "Events";
|
||||
public static final String TAG_SUBSCRIPTIONS = "Subscriptions";
|
||||
public static final String TAG_NOTIFICATIONS = "Notifications";
|
||||
public static final String TAG_TOPIC_TYPES = "Topic Types";
|
||||
public static final String TAG_OPENAIRE = "OpenAIRE";
|
||||
public static final String TAG_MATCHING = "Subscription-Event Matching";
|
||||
|
||||
public static void main(final String[] args) {
|
||||
SpringApplication.run(LiteratureBrokerServiceApplication.class, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configSwagger(final Docket docket) {
|
||||
docket.select()
|
||||
.apis(RequestHandlerSelectors.any())
|
||||
.paths(p -> p.startsWith("/api/"))
|
||||
.build()
|
||||
.tags(new Tag(TAG_EVENTS, "Events management"), new Tag(TAG_SUBSCRIPTIONS, "Subscriptions management"), new Tag(TAG_NOTIFICATIONS,
|
||||
"Notifications management"), new Tag(TAG_TOPIC_TYPES, "Topic types management"), new Tag(TAG_OPENAIRE, "OpenAIRE use case"))
|
||||
.apiInfo(new ApiInfoBuilder()
|
||||
.title("Literature Broker Service")
|
||||
.description("APIs documentation")
|
||||
.version("1.1")
|
||||
.contact(ApiInfo.DEFAULT_CONTACT)
|
||||
.license("Apache 2.0")
|
||||
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0")
|
||||
.build());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +1,9 @@
|
|||
package eu.dnetlib.broker;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
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.elasticsearch.client.RestHighLevelClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.data.elasticsearch.client.ClientConfiguration;
|
||||
import org.springframework.data.elasticsearch.client.RestClients;
|
||||
import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration;
|
||||
|
@ -25,21 +11,9 @@ import org.springframework.data.elasticsearch.repository.config.EnableElasticsea
|
|||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import eu.dnetlib.broker.common.elasticsearch.Event;
|
||||
import eu.dnetlib.broker.common.elasticsearch.Notification;
|
||||
import eu.dnetlib.broker.common.properties.ElasticSearchProperties;
|
||||
import io.micrometer.core.instrument.ImmutableTag;
|
||||
import io.micrometer.core.instrument.Metrics;
|
||||
import io.prometheus.client.exporter.MetricsServlet;
|
||||
import io.prometheus.client.hotspot.DefaultExports;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.Tag;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@Configuration
|
||||
|
@ -51,39 +25,9 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|||
})
|
||||
public class LiteratureBrokerServiceConfiguration extends AbstractElasticsearchConfiguration {
|
||||
|
||||
private static final Log log = LogFactory.getLog(LiteratureBrokerServiceConfiguration.class);
|
||||
|
||||
@Autowired
|
||||
private ElasticSearchProperties elasticSearchProperties;
|
||||
|
||||
@Value("pom.xml")
|
||||
private ClassPathResource pom;
|
||||
|
||||
public static final String TAG_EVENTS = "Events";
|
||||
public static final String TAG_SUBSCRIPTIONS = "Subscriptions";
|
||||
public static final String TAG_NOTIFICATIONS = "Notifications";
|
||||
public static final String TAG_TOPIC_TYPES = "Topic Types";
|
||||
public static final String TAG_OPENAIRE = "OpenAIRE";
|
||||
public static final String TAG_MATCHING = "Subscription-Event Matching";
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
final MavenXpp3Reader reader = new MavenXpp3Reader();
|
||||
try {
|
||||
final Model model = reader.read(new InputStreamReader(pom.getInputStream()));
|
||||
|
||||
log.info(String.format("registering metric for %s", model.getArtifactId()));
|
||||
|
||||
final ImmutableTag tag1 = new ImmutableTag("component", model.getGroupId() + ":" + model.getArtifactId());
|
||||
// final ImmutableTag tag2 = new ImmutableTag("version", model.getVersion());
|
||||
// final ImmutableTag tag3 = new ImmutableTag("scmtag", model.getScm().getTag());
|
||||
|
||||
Metrics.gauge("micrometer_info", Lists.newArrayList(tag1), 1);
|
||||
} catch (IOException | XmlPullParserException e) {
|
||||
log.error("Error registering metric", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
public RestHighLevelClient elasticsearchClient() {
|
||||
|
@ -95,32 +39,4 @@ public class LiteratureBrokerServiceConfiguration extends AbstractElasticsearchC
|
|||
return RestClients.create(clientConfiguration).rest();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public static Docket newSwaggerDocket() {
|
||||
log.info("Initializing SWAGGER...");
|
||||
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.any())
|
||||
.paths(p -> p.startsWith("/api/"))
|
||||
.build()
|
||||
.tags(new Tag(TAG_EVENTS, "Events management"), new Tag(TAG_SUBSCRIPTIONS, "Subscriptions management"), new Tag(TAG_NOTIFICATIONS,
|
||||
"Notifications management"), new Tag(TAG_TOPIC_TYPES, "Topic types management"), new Tag(TAG_OPENAIRE, "OpenAIRE use case"))
|
||||
.apiInfo(new ApiInfoBuilder()
|
||||
.title("Literature Broker Service")
|
||||
.description("APIs documentation")
|
||||
.version("1.1")
|
||||
.contact(ApiInfo.DEFAULT_CONTACT)
|
||||
.license("Apache 2.0")
|
||||
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0")
|
||||
.build());
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "prometheusMetricsServletRegistrationBean")
|
||||
ServletRegistrationBean<MetricsServlet> prometheusMetricsServletRegistrationBean(@Value("${prometheus.metrics.path:/metrics}") final String metricsPath) {
|
||||
DefaultExports.initialize();
|
||||
return new ServletRegistrationBean<>(new MetricsServlet(), metricsPath);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import eu.dnetlib.broker.common.controllers.AbstractLbsController;
|
||||
import eu.dnetlib.broker.common.elasticsearch.EventRepository;
|
||||
import eu.dnetlib.broker.common.elasticsearch.NotificationRepository;
|
||||
import eu.dnetlib.broker.common.subscriptions.SubscriptionRepository;
|
||||
|
@ -25,10 +24,11 @@ import eu.dnetlib.broker.events.output.NotificationDispatcher;
|
|||
import eu.dnetlib.broker.utils.LbsQueue;
|
||||
import eu.dnetlib.broker.utils.QueueManager;
|
||||
import eu.dnetlib.broker.utils.ThreadManager;
|
||||
import eu.dnetlib.common.controller.AbstractDnetController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/ajax")
|
||||
public class AjaxController extends AbstractLbsController {
|
||||
public class AjaxController extends AbstractDnetController {
|
||||
|
||||
@Autowired
|
||||
private EventRepository eventRepository;
|
||||
|
|
|
@ -23,23 +23,23 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import eu.dnetlib.broker.LiteratureBrokerServiceConfiguration;
|
||||
import eu.dnetlib.broker.common.controllers.AbstractLbsController;
|
||||
import eu.dnetlib.broker.LiteratureBrokerServiceApplication;
|
||||
import eu.dnetlib.broker.common.elasticsearch.Event;
|
||||
import eu.dnetlib.broker.common.elasticsearch.EventRepository;
|
||||
import eu.dnetlib.broker.common.elasticsearch.EventStatsManager;
|
||||
import eu.dnetlib.broker.common.elasticsearch.EventStatsManager.BrowseEntry;
|
||||
import eu.dnetlib.broker.common.subscriptions.Subscription;
|
||||
import eu.dnetlib.broker.common.subscriptions.SubscriptionRepository;
|
||||
import eu.dnetlib.common.controller.AbstractDnetController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/events")
|
||||
@Api(tags = LiteratureBrokerServiceConfiguration.TAG_EVENTS)
|
||||
public class EventsController extends AbstractLbsController {
|
||||
@Api(tags = LiteratureBrokerServiceApplication.TAG_EVENTS)
|
||||
public class EventsController extends AbstractDnetController {
|
||||
|
||||
private static final Log log = LogFactory.getLog(EventsController.class);
|
||||
private static final Log log = LogFactory.getLog(AbstractDnetController.class);
|
||||
|
||||
@Autowired
|
||||
private EventRepository eventRepository;
|
||||
|
|
|
@ -14,17 +14,17 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import eu.dnetlib.broker.LiteratureBrokerServiceConfiguration;
|
||||
import eu.dnetlib.broker.common.controllers.AbstractLbsController;
|
||||
import eu.dnetlib.broker.LiteratureBrokerServiceApplication;
|
||||
import eu.dnetlib.broker.common.elasticsearch.Notification;
|
||||
import eu.dnetlib.broker.common.elasticsearch.NotificationRepository;
|
||||
import eu.dnetlib.common.controller.AbstractDnetController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/notifications")
|
||||
@Api(tags = LiteratureBrokerServiceConfiguration.TAG_NOTIFICATIONS)
|
||||
public class NotificationsController extends AbstractLbsController {
|
||||
@Api(tags = LiteratureBrokerServiceApplication.TAG_NOTIFICATIONS)
|
||||
public class NotificationsController extends AbstractDnetController {
|
||||
|
||||
private static final Log log = LogFactory.getLog(NotificationsController.class);
|
||||
|
||||
|
|
|
@ -11,19 +11,19 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import eu.dnetlib.broker.LiteratureBrokerServiceConfiguration;
|
||||
import eu.dnetlib.broker.common.controllers.AbstractLbsController;
|
||||
import eu.dnetlib.broker.LiteratureBrokerServiceApplication;
|
||||
import eu.dnetlib.broker.common.subscriptions.Subscription;
|
||||
import eu.dnetlib.broker.common.subscriptions.SubscriptionRepository;
|
||||
import eu.dnetlib.broker.matchers.SubscriptionEventMatcher;
|
||||
import eu.dnetlib.common.controller.AbstractDnetController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@Profile("!openaire")
|
||||
@RestController
|
||||
@RequestMapping("/api/matching")
|
||||
@Api(tags = LiteratureBrokerServiceConfiguration.TAG_MATCHING)
|
||||
public class StartMatchingController extends AbstractLbsController {
|
||||
@Api(tags = LiteratureBrokerServiceApplication.TAG_MATCHING)
|
||||
public class StartMatchingController extends AbstractDnetController {
|
||||
|
||||
@Autowired
|
||||
private SubscriptionRepository subscriptionRepo;
|
||||
|
|
|
@ -21,21 +21,21 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import eu.dnetlib.broker.LiteratureBrokerServiceConfiguration;
|
||||
import eu.dnetlib.broker.common.controllers.AbstractLbsController;
|
||||
import eu.dnetlib.broker.LiteratureBrokerServiceApplication;
|
||||
import eu.dnetlib.broker.common.elasticsearch.NotificationRepository;
|
||||
import eu.dnetlib.broker.common.subscriptions.MapCondition;
|
||||
import eu.dnetlib.broker.common.subscriptions.NotificationFrequency;
|
||||
import eu.dnetlib.broker.common.subscriptions.NotificationMode;
|
||||
import eu.dnetlib.broker.common.subscriptions.Subscription;
|
||||
import eu.dnetlib.broker.common.subscriptions.SubscriptionRepository;
|
||||
import eu.dnetlib.common.controller.AbstractDnetController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/subscriptions")
|
||||
@Api(tags = LiteratureBrokerServiceConfiguration.TAG_SUBSCRIPTIONS)
|
||||
public class SubscriptionsController extends AbstractLbsController {
|
||||
@Api(tags = LiteratureBrokerServiceApplication.TAG_SUBSCRIPTIONS)
|
||||
public class SubscriptionsController extends AbstractDnetController {
|
||||
|
||||
@Autowired
|
||||
private SubscriptionRepository subscriptionRepo;
|
||||
|
|
|
@ -18,17 +18,17 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import eu.dnetlib.broker.LiteratureBrokerServiceConfiguration;
|
||||
import eu.dnetlib.broker.common.controllers.AbstractLbsController;
|
||||
import eu.dnetlib.broker.LiteratureBrokerServiceApplication;
|
||||
import eu.dnetlib.broker.common.topics.TopicType;
|
||||
import eu.dnetlib.broker.common.topics.TopicTypeRepository;
|
||||
import eu.dnetlib.common.controller.AbstractDnetController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/topic-types")
|
||||
@Api(tags = LiteratureBrokerServiceConfiguration.TAG_TOPIC_TYPES)
|
||||
public class TopicsController extends AbstractLbsController {
|
||||
@Api(tags = LiteratureBrokerServiceApplication.TAG_TOPIC_TYPES)
|
||||
public class TopicsController extends AbstractDnetController {
|
||||
|
||||
@Autowired
|
||||
private TopicTypeRepository topicTypeRepo;
|
||||
|
|
|
@ -45,8 +45,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import eu.dnetlib.broker.LiteratureBrokerServiceConfiguration;
|
||||
import eu.dnetlib.broker.common.controllers.AbstractLbsController;
|
||||
import eu.dnetlib.broker.LiteratureBrokerServiceApplication;
|
||||
import eu.dnetlib.broker.common.elasticsearch.Event;
|
||||
import eu.dnetlib.broker.common.elasticsearch.Notification;
|
||||
import eu.dnetlib.broker.common.elasticsearch.NotificationRepository;
|
||||
|
@ -56,14 +55,15 @@ import eu.dnetlib.broker.common.subscriptions.Subscription;
|
|||
import eu.dnetlib.broker.common.subscriptions.SubscriptionRepository;
|
||||
import eu.dnetlib.broker.events.output.DispatcherManager;
|
||||
import eu.dnetlib.broker.objects.OaBrokerEventPayload;
|
||||
import eu.dnetlib.common.controller.AbstractDnetController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@Profile("openaire")
|
||||
@RestController
|
||||
@RequestMapping("/api/openaireBroker")
|
||||
@Api(tags = LiteratureBrokerServiceConfiguration.TAG_OPENAIRE)
|
||||
public class OpenaireBrokerController extends AbstractLbsController {
|
||||
@Api(tags = LiteratureBrokerServiceApplication.TAG_OPENAIRE)
|
||||
public class OpenaireBrokerController extends AbstractDnetController {
|
||||
|
||||
@Autowired
|
||||
private ElasticsearchOperations esOperations;
|
||||
|
|
|
@ -1,23 +1,9 @@
|
|||
package eu.dnetlib.broker;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
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.elasticsearch.client.RestHighLevelClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.data.elasticsearch.client.ClientConfiguration;
|
||||
import org.springframework.data.elasticsearch.client.RestClients;
|
||||
import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration;
|
||||
|
@ -25,21 +11,9 @@ import org.springframework.data.elasticsearch.repository.config.EnableElasticsea
|
|||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import eu.dnetlib.broker.common.elasticsearch.Event;
|
||||
import eu.dnetlib.broker.common.elasticsearch.Notification;
|
||||
import eu.dnetlib.broker.common.properties.ElasticSearchProperties;
|
||||
import io.micrometer.core.instrument.ImmutableTag;
|
||||
import io.micrometer.core.instrument.Metrics;
|
||||
import io.prometheus.client.exporter.MetricsServlet;
|
||||
import io.prometheus.client.hotspot.DefaultExports;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.Tag;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@Configuration
|
||||
|
@ -51,34 +25,9 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|||
})
|
||||
public class BrokerConfiguration extends AbstractElasticsearchConfiguration {
|
||||
|
||||
private static final Log log = LogFactory.getLog(BrokerConfiguration.class);
|
||||
|
||||
@Autowired
|
||||
private ElasticSearchProperties elasticSearchProperties;
|
||||
|
||||
@Value("pom.xml")
|
||||
private ClassPathResource pom;
|
||||
|
||||
public static final String OA_PUBLIC_APIS = "Openaire Broker Public API";
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
final MavenXpp3Reader reader = new MavenXpp3Reader();
|
||||
try {
|
||||
final Model model = reader.read(new InputStreamReader(pom.getInputStream()));
|
||||
|
||||
log.info(String.format("registering metric for %s", model.getArtifactId()));
|
||||
|
||||
final ImmutableTag tag1 = new ImmutableTag("component", model.getGroupId() + ":" + model.getArtifactId());
|
||||
// final ImmutableTag tag2 = new ImmutableTag("version", model.getVersion());
|
||||
// final ImmutableTag tag3 = new ImmutableTag("scmtag", model.getScm().getTag());
|
||||
|
||||
Metrics.gauge("micrometer_info", Lists.newArrayList(tag1), 1);
|
||||
} catch (IOException | XmlPullParserException e) {
|
||||
log.error("Error registering metric", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
public RestHighLevelClient elasticsearchClient() {
|
||||
|
@ -90,32 +39,4 @@ public class BrokerConfiguration extends AbstractElasticsearchConfiguration {
|
|||
return RestClients.create(clientConfiguration).rest();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public static Docket newSwaggerDocket() {
|
||||
log.info("Initializing SWAGGER...");
|
||||
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.any())
|
||||
.paths(p -> p.startsWith("/"))
|
||||
.build()
|
||||
.tags(new Tag(OA_PUBLIC_APIS, OA_PUBLIC_APIS))
|
||||
.apiInfo(new ApiInfoBuilder()
|
||||
.title("OpenAIRE Public Broker API")
|
||||
.description("APIs documentation")
|
||||
.version("1.1")
|
||||
.contact(ApiInfo.DEFAULT_CONTACT)
|
||||
.license("Apache 2.0")
|
||||
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0")
|
||||
.build());
|
||||
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "prometheusMetricsServletRegistrationBean")
|
||||
ServletRegistrationBean<MetricsServlet> prometheusMetricsServletRegistrationBean(@Value("${prometheus.metrics.path:/metrics}") final String metricsPath) {
|
||||
DefaultExports.initialize();
|
||||
return new ServletRegistrationBean<>(new MetricsServlet(), metricsPath);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,10 +3,38 @@ package eu.dnetlib.broker;
|
|||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
import eu.dnetlib.common.app.AbstractDnetApp;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.Tag;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
|
||||
@SpringBootApplication
|
||||
public class BrokerPublicApplication {
|
||||
public class BrokerPublicApplication extends AbstractDnetApp {
|
||||
|
||||
public static final String OA_PUBLIC_APIS = "Openaire Broker Public API";
|
||||
|
||||
public static void main(final String[] args) {
|
||||
SpringApplication.run(BrokerPublicApplication.class, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configSwagger(final Docket docket) {
|
||||
|
||||
docket.select()
|
||||
.apis(RequestHandlerSelectors.any())
|
||||
.paths(p -> p.startsWith("/"))
|
||||
.build()
|
||||
.tags(new Tag(OA_PUBLIC_APIS, OA_PUBLIC_APIS))
|
||||
.apiInfo(new ApiInfoBuilder()
|
||||
.title("OpenAIRE Public Broker API")
|
||||
.description("APIs documentation")
|
||||
.version("1.1")
|
||||
.contact(ApiInfo.DEFAULT_CONTACT)
|
||||
.license("Apache 2.0")
|
||||
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0")
|
||||
.build());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,9 +51,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import eu.dnetlib.broker.BrokerConfiguration;
|
||||
import eu.dnetlib.broker.BrokerPublicApplication;
|
||||
import eu.dnetlib.broker.api.ShortEventMessage;
|
||||
import eu.dnetlib.broker.common.controllers.AbstractLbsController;
|
||||
import eu.dnetlib.broker.common.elasticsearch.EventRepository;
|
||||
import eu.dnetlib.broker.common.elasticsearch.Notification;
|
||||
import eu.dnetlib.broker.common.elasticsearch.NotificationRepository;
|
||||
|
@ -61,14 +60,15 @@ import eu.dnetlib.broker.common.properties.ElasticSearchProperties;
|
|||
import eu.dnetlib.broker.common.subscriptions.Subscription;
|
||||
import eu.dnetlib.broker.common.subscriptions.SubscriptionRepository;
|
||||
import eu.dnetlib.broker.objects.OaBrokerEventPayload;
|
||||
import eu.dnetlib.common.controller.AbstractDnetController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@Profile("openaire")
|
||||
@RestController
|
||||
@RequestMapping("/")
|
||||
@Api(tags = BrokerConfiguration.OA_PUBLIC_APIS)
|
||||
public class OpenairePublicController extends AbstractLbsController {
|
||||
@Api(tags = BrokerPublicApplication.OA_PUBLIC_APIS)
|
||||
public class OpenairePublicController extends AbstractDnetController {
|
||||
|
||||
@Autowired
|
||||
private ElasticsearchOperations esOperations;
|
||||
|
|
|
@ -1,47 +1,39 @@
|
|||
package eu.dnetlib.data.mdstore.manager;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
import eu.dnetlib.common.app.AbstractDnetApp;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableSwagger2
|
||||
@EnableCaching
|
||||
public class MainApplication {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MainApplication.class);
|
||||
public class MainApplication extends AbstractDnetApp {
|
||||
|
||||
public static void main(final String[] args) {
|
||||
SpringApplication.run(MainApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public static Docket newSwaggerDocket() {
|
||||
log.info("Initializing SWAGGER...");
|
||||
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.any())
|
||||
.paths(p -> p.startsWith("/mdstores"))
|
||||
.build().apiInfo(new ApiInfoBuilder()
|
||||
.title("MDStore Manager APIs")
|
||||
.description("APIs documentation")
|
||||
.version("1.1")
|
||||
.contact(ApiInfo.DEFAULT_CONTACT)
|
||||
.license("Apache 2.0")
|
||||
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0")
|
||||
.build());
|
||||
|
||||
@Override
|
||||
protected void configSwagger(final Docket docket) {
|
||||
docket.select()
|
||||
.apis(RequestHandlerSelectors.any())
|
||||
.paths(p -> p.startsWith("/mdstores"))
|
||||
.build()
|
||||
.apiInfo(new ApiInfoBuilder()
|
||||
.title("MDStore Manager APIs")
|
||||
.description("APIs documentation")
|
||||
.version("1.1")
|
||||
.contact(ApiInfo.DEFAULT_CONTACT)
|
||||
.license("Apache 2.0")
|
||||
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0")
|
||||
.build());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import eu.dnetlib.common.controller.AbstractDnetController;
|
||||
import eu.dnetlib.data.mdstore.manager.common.model.MDStoreVersion;
|
||||
import eu.dnetlib.data.mdstore.manager.common.model.MDStoreWithInfo;
|
||||
import eu.dnetlib.data.mdstore.manager.exceptions.MDStoreManagerException;
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
spring.main.banner-mode = console
|
||||
logging.level.root = INFO
|
||||
|
||||
management.endpoints.web.exposure.include = prometheus,health
|
||||
management.endpoints.web.base-path = /
|
||||
management.endpoints.web.path-mapping.prometheus = metrics
|
||||
management.endpoints.web.path-mapping.health = health
|
||||
|
||||
spring.datasource.url=jdbc:postgresql://localhost:5432/mdstoremanager
|
||||
spring.datasource.username=dnet
|
||||
spring.datasource.password=dnetPwd
|
||||
|
|
|
@ -1,36 +1,28 @@
|
|||
package eu.dnetlib.organizations;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
import eu.dnetlib.common.app.AbstractDnetApp;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableSwagger2
|
||||
@EnableCaching
|
||||
public class MainApplication {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MainApplication.class);
|
||||
public class MainApplication extends AbstractDnetApp {
|
||||
|
||||
public static void main(final String[] args) {
|
||||
SpringApplication.run(MainApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public static Docket newSwaggerDocket() {
|
||||
log.info("Initializing SWAGGER...");
|
||||
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.select()
|
||||
@Override
|
||||
protected void configSwagger(final Docket docket) {
|
||||
docket.select()
|
||||
.apis(RequestHandlerSelectors.any())
|
||||
.paths(p -> p.startsWith("/api/") || p.startsWith("/oa_api"))
|
||||
.build()
|
||||
|
@ -42,7 +34,6 @@ public class MainApplication {
|
|||
.license("Apache 2.0")
|
||||
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0")
|
||||
.build());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,8 +8,10 @@ import org.springframework.stereotype.Controller;
|
|||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
|
||||
import eu.dnetlib.common.controller.AbstractDnetController;
|
||||
|
||||
@Controller
|
||||
public class HomeController {
|
||||
public class HomeController extends AbstractDnetController {
|
||||
|
||||
@Autowired
|
||||
private Environment env;
|
||||
|
|
|
@ -13,11 +13,12 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import eu.dnetlib.common.controller.AbstractDnetController;
|
||||
import eu.dnetlib.organizations.utils.DatabaseUtils;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/oa_api")
|
||||
public class OpenaireInternalApiController {
|
||||
public class OpenaireInternalApiController extends AbstractDnetController {
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import eu.dnetlib.common.controller.AbstractDnetController;
|
||||
import eu.dnetlib.organizations.model.OpenaireDuplicate;
|
||||
import eu.dnetlib.organizations.model.utils.BrowseEntry;
|
||||
import eu.dnetlib.organizations.model.utils.OrganizationConflict;
|
||||
|
@ -46,7 +47,7 @@ import eu.dnetlib.organizations.utils.OrganizationStatus;
|
|||
|
||||
@RestController
|
||||
@RequestMapping("/api/organizations")
|
||||
public class OrganizationController {
|
||||
public class OrganizationController extends AbstractDnetController {
|
||||
|
||||
@Autowired
|
||||
private OrganizationViewRepository organizationViewRepository;
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import eu.dnetlib.common.controller.AbstractDnetController;
|
||||
import eu.dnetlib.organizations.model.utils.VocabularyTerm;
|
||||
import eu.dnetlib.organizations.model.view.UserView;
|
||||
import eu.dnetlib.organizations.repository.UserRepository;
|
||||
|
@ -23,7 +24,7 @@ import eu.dnetlib.organizations.repository.readonly.UserViewRepository;
|
|||
import eu.dnetlib.organizations.utils.DatabaseUtils;
|
||||
|
||||
@RestController
|
||||
public class UserController {
|
||||
public class UserController extends AbstractDnetController {
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.springframework.security.core.Authentication;
|
|||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import eu.dnetlib.common.controller.AbstractDnetController;
|
||||
import eu.dnetlib.organizations.model.utils.VocabularyTerm;
|
||||
import eu.dnetlib.organizations.utils.DatabaseUtils;
|
||||
import eu.dnetlib.organizations.utils.DatabaseUtils.VocabularyTable;
|
||||
|
@ -19,7 +20,7 @@ import eu.dnetlib.organizations.utils.RelationType;
|
|||
import eu.dnetlib.organizations.utils.SimilarityType;
|
||||
|
||||
@RestController
|
||||
public class VocabulariesController {
|
||||
public class VocabulariesController extends AbstractDnetController {
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
|
34
apps/pom.xml
34
apps/pom.xml
|
@ -1,4 +1,6 @@
|
|||
<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">
|
||||
<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.dhp</groupId>
|
||||
|
@ -29,39 +31,19 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- for /metrics and /health controllers -->
|
||||
<!-- Openaire -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
<groupId>eu.dnetlib.dhp</groupId>
|
||||
<artifactId>dnet-apps-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.micrometer</groupId>
|
||||
<artifactId>micrometer-registry-prometheus</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-model</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -0,0 +1,233 @@
|
|||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven2 Start Up Batch script
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# M2_HOME - location of maven2's installed home dir
|
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
# e.g. to debug Maven itself, use
|
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
||||
if [ -f /etc/mavenrc ] ; then
|
||||
. /etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.mavenrc" ] ; then
|
||||
. "$HOME/.mavenrc"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# OS specific support. $var _must_ be set to either true or false.
|
||||
cygwin=false;
|
||||
darwin=false;
|
||||
mingw=false
|
||||
case "`uname`" in
|
||||
CYGWIN*) cygwin=true ;;
|
||||
MINGW*) mingw=true;;
|
||||
Darwin*) darwin=true
|
||||
#
|
||||
# Look for the Apple JDKs first to preserve the existing behaviour, and then look
|
||||
# for the new JDKs provided by Oracle.
|
||||
#
|
||||
if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
|
||||
#
|
||||
# Apple JDKs
|
||||
#
|
||||
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
|
||||
#
|
||||
# Apple JDKs
|
||||
#
|
||||
export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
|
||||
#
|
||||
# Oracle JDKs
|
||||
#
|
||||
export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
|
||||
#
|
||||
# Apple JDKs
|
||||
#
|
||||
export JAVA_HOME=`/usr/libexec/java_home`
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=`java-config --jre-home`
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$M2_HOME" ] ; then
|
||||
## resolve links - $0 may be a link to maven's home
|
||||
PRG="$0"
|
||||
|
||||
# need this for relative symlinks
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG="`dirname "$PRG"`/$link"
|
||||
fi
|
||||
done
|
||||
|
||||
saveddir=`pwd`
|
||||
|
||||
M2_HOME=`dirname "$PRG"`/..
|
||||
|
||||
# make it fully qualified
|
||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||
|
||||
cd "$saveddir"
|
||||
# echo Using m2 at $M2_HOME
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||
fi
|
||||
|
||||
# For Migwn, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||
# TODO classpath?
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
javaExecutable="`which javac`"
|
||||
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
|
||||
# readlink(1) is not available as standard on Solaris 10.
|
||||
readLink=`which readlink`
|
||||
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
|
||||
if $darwin ; then
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
|
||||
else
|
||||
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
||||
fi
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
||||
JAVA_HOME="$javaHome"
|
||||
export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVACMD" ] ; then
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
else
|
||||
JAVACMD="`which java`"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||
echo " We cannot execute $JAVACMD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
||||
fi
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
local basedir=$(pwd)
|
||||
local wdir=$(pwd)
|
||||
while [ "$wdir" != '/' ] ; do
|
||||
if [ -d "$wdir"/.mvn ] ; then
|
||||
basedir=$wdir
|
||||
break
|
||||
fi
|
||||
wdir=$(cd "$wdir/.."; pwd)
|
||||
done
|
||||
echo "${basedir}"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "$(tr -s '\n' ' ' < "$1")"
|
||||
fi
|
||||
}
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
|
||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||
|
||||
# Provide a "standardized" way to retrieve the CLI args that will
|
||||
# work with both Windows and non-Windows executions.
|
||||
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
|
||||
export MAVEN_CMD_LINE_ARGS
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} "$@"
|
|
@ -0,0 +1,145 @@
|
|||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM http://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Maven2 Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
set MAVEN_CMD_LINE_ARGS=%*
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
|
||||
set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar""
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%" == "on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
|
||||
|
||||
exit /B %ERROR_CODE%
|
|
@ -0,0 +1,95 @@
|
|||
<?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.dhp</groupId>
|
||||
<artifactId>libs</artifactId>
|
||||
<version>3.1.8-SNAPSHOT</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>dnet-apps-common</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>dnet-apps-common</name>
|
||||
<description>D-Net Broker Apps common library</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- for /metrics and /health controllers -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.micrometer</groupId>
|
||||
<artifactId>micrometer-registry-prometheus</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-model</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- for /metrics and /health controllers -->
|
||||
<dependency>
|
||||
<groupId>io.prometheus</groupId>
|
||||
<artifactId>simpleclient_spring_boot</artifactId>
|
||||
<version>${prometheus.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.prometheus</groupId>
|
||||
<artifactId>simpleclient_hotspot</artifactId>
|
||||
<version>${prometheus.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.prometheus</groupId>
|
||||
<artifactId>simpleclient_servlet</artifactId>
|
||||
<version>${prometheus.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.prometheus</groupId>
|
||||
<artifactId>simpleclient_spring_web</artifactId>
|
||||
<version>0.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JUNIT -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.organizations;
|
||||
package eu.dnetlib.common.app;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
@ -11,22 +11,23 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import io.micrometer.core.instrument.ImmutableTag;
|
||||
import io.micrometer.core.instrument.Metrics;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
|
||||
@Configuration
|
||||
public class MainConfiguration {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MainConfiguration.class);
|
||||
public abstract class AbstractDnetApp {
|
||||
|
||||
@Value("pom.xml")
|
||||
private ClassPathResource pom;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AbstractDnetApp.class);
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
final MavenXpp3Reader reader = new MavenXpp3Reader();
|
||||
|
@ -44,4 +45,18 @@ public class MainConfiguration {
|
|||
log.error("Error registering metric", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Docket newSwaggerDocket() {
|
||||
log.info("Initializing SWAGGER...");
|
||||
|
||||
final Docket docket = new Docket(DocumentationType.SWAGGER_2);
|
||||
|
||||
configSwagger(docket);
|
||||
|
||||
return docket;
|
||||
}
|
||||
|
||||
protected abstract void configSwagger(final Docket docket);
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.data.mdstore.manager.controller;
|
||||
package eu.dnetlib.common.controller;
|
||||
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.springframework.http.HttpStatus;
|
|
@ -1,41 +0,0 @@
|
|||
package eu.dnetlib.broker.common.controllers;
|
||||
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
public abstract class AbstractLbsController {
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
public @ResponseBody ErrorMessage handleException(final Exception e) {
|
||||
return new ErrorMessage(e);
|
||||
}
|
||||
|
||||
public class ErrorMessage {
|
||||
|
||||
private final String message;
|
||||
private final String stacktrace;
|
||||
|
||||
public ErrorMessage(final Exception e) {
|
||||
this(e.getMessage(), ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
|
||||
public ErrorMessage(final String message, final String stacktrace) {
|
||||
this.message = message;
|
||||
this.stacktrace = stacktrace;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public String getStacktrace() {
|
||||
return this.stacktrace;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -13,6 +13,7 @@
|
|||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>dnet-apps-common</module>
|
||||
<module>dnet-openaire-broker-common</module>
|
||||
<module>dnet-broker-apps-common</module>
|
||||
</modules>
|
||||
|
|
Loading…
Reference in New Issue