change packages

This commit is contained in:
Michele Artini 2020-09-04 14:33:19 +02:00
parent 062d636572
commit 1bf492b488
82 changed files with 381 additions and 315 deletions

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs;
package eu.dnetlib.broker;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs;
package eu.dnetlib.broker;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -16,9 +16,9 @@ import org.springframework.data.elasticsearch.repository.config.EnableElasticsea
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import eu.dnetlib.lbs.elasticsearch.Event;
import eu.dnetlib.lbs.elasticsearch.Notification;
import eu.dnetlib.lbs.properties.ElasticSearchProperties;
import eu.dnetlib.broker.common.elasticsearch.Event;
import eu.dnetlib.broker.common.elasticsearch.Notification;
import eu.dnetlib.broker.common.properties.ElasticSearchProperties;
import io.prometheus.client.exporter.MetricsServlet;
import io.prometheus.client.hotspot.DefaultExports;
import springfox.documentation.builders.RequestHandlerSelectors;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.controllers;
package eu.dnetlib.broker.controllers;
import java.util.ArrayList;
import java.util.List;
@ -10,20 +10,21 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import eu.dnetlib.lbs.controllers.objects.BufferStatus;
import eu.dnetlib.lbs.controllers.objects.CurrentStatus;
import eu.dnetlib.lbs.controllers.objects.DispatcherStatus;
import eu.dnetlib.lbs.controllers.objects.ThreadStatus;
import eu.dnetlib.lbs.controllers.objects.Tool;
import eu.dnetlib.lbs.elasticsearch.EventRepository;
import eu.dnetlib.lbs.elasticsearch.NotificationRepository;
import eu.dnetlib.lbs.events.output.DispatcherManager;
import eu.dnetlib.lbs.events.output.NotificationDispatcher;
import eu.dnetlib.lbs.subscriptions.SubscriptionRepository;
import eu.dnetlib.lbs.topics.TopicTypeRepository;
import eu.dnetlib.lbs.utils.LbsQueue;
import eu.dnetlib.lbs.utils.QueueManager;
import eu.dnetlib.lbs.utils.ThreadManager;
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;
import eu.dnetlib.broker.common.topics.TopicTypeRepository;
import eu.dnetlib.broker.controllers.objects.BufferStatus;
import eu.dnetlib.broker.controllers.objects.CurrentStatus;
import eu.dnetlib.broker.controllers.objects.DispatcherStatus;
import eu.dnetlib.broker.controllers.objects.ThreadStatus;
import eu.dnetlib.broker.controllers.objects.Tool;
import eu.dnetlib.broker.events.output.DispatcherManager;
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;
@RestController
@RequestMapping("/ajax")

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.controllers;
package eu.dnetlib.broker.controllers;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.controllers;
package eu.dnetlib.broker.controllers;
import java.util.Date;
import java.util.HashMap;
@ -23,13 +23,14 @@ import org.springframework.web.bind.annotation.RestController;
import com.google.common.collect.Lists;
import eu.dnetlib.lbs.LiteratureBrokerServiceConfiguration;
import eu.dnetlib.lbs.elasticsearch.Event;
import eu.dnetlib.lbs.elasticsearch.EventRepository;
import eu.dnetlib.lbs.elasticsearch.EventStatsManager;
import eu.dnetlib.lbs.elasticsearch.EventStatsManager.BrowseEntry;
import eu.dnetlib.lbs.subscriptions.Subscription;
import eu.dnetlib.lbs.subscriptions.SubscriptionRepository;
import eu.dnetlib.broker.LiteratureBrokerServiceConfiguration;
import eu.dnetlib.broker.common.controllers.AbstractLbsController;
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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.controllers;
package eu.dnetlib.broker.controllers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
@ -9,9 +9,10 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import eu.dnetlib.lbs.LiteratureBrokerServiceConfiguration;
import eu.dnetlib.lbs.elasticsearch.Notification;
import eu.dnetlib.lbs.elasticsearch.NotificationRepository;
import eu.dnetlib.broker.LiteratureBrokerServiceConfiguration;
import eu.dnetlib.broker.common.controllers.AbstractLbsController;
import eu.dnetlib.broker.common.elasticsearch.Notification;
import eu.dnetlib.broker.common.elasticsearch.NotificationRepository;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.controllers;
package eu.dnetlib.broker.controllers;
import java.util.Arrays;
import java.util.List;
@ -11,10 +11,11 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import eu.dnetlib.lbs.LiteratureBrokerServiceConfiguration;
import eu.dnetlib.lbs.matchers.SubscriptionEventMatcher;
import eu.dnetlib.lbs.subscriptions.Subscription;
import eu.dnetlib.lbs.subscriptions.SubscriptionRepository;
import eu.dnetlib.broker.LiteratureBrokerServiceConfiguration;
import eu.dnetlib.broker.common.controllers.AbstractLbsController;
import eu.dnetlib.broker.common.subscriptions.Subscription;
import eu.dnetlib.broker.common.subscriptions.SubscriptionRepository;
import eu.dnetlib.broker.matchers.SubscriptionEventMatcher;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.controllers;
package eu.dnetlib.broker.controllers;
import java.util.Date;
import java.util.HashMap;
@ -21,13 +21,14 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import eu.dnetlib.lbs.LiteratureBrokerServiceConfiguration;
import eu.dnetlib.lbs.elasticsearch.NotificationRepository;
import eu.dnetlib.lbs.subscriptions.MapCondition;
import eu.dnetlib.lbs.subscriptions.NotificationFrequency;
import eu.dnetlib.lbs.subscriptions.NotificationMode;
import eu.dnetlib.lbs.subscriptions.Subscription;
import eu.dnetlib.lbs.subscriptions.SubscriptionRepository;
import eu.dnetlib.broker.LiteratureBrokerServiceConfiguration;
import eu.dnetlib.broker.common.controllers.AbstractLbsController;
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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.controllers;
package eu.dnetlib.broker.controllers;
import java.util.Arrays;
import java.util.HashMap;
@ -18,9 +18,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import eu.dnetlib.lbs.LiteratureBrokerServiceConfiguration;
import eu.dnetlib.lbs.topics.TopicType;
import eu.dnetlib.lbs.topics.TopicTypeRepository;
import eu.dnetlib.broker.LiteratureBrokerServiceConfiguration;
import eu.dnetlib.broker.common.controllers.AbstractLbsController;
import eu.dnetlib.broker.common.topics.TopicType;
import eu.dnetlib.broker.common.topics.TopicTypeRepository;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -33,7 +34,7 @@ public class TopicsController extends AbstractLbsController {
private TopicTypeRepository topicTypeRepo;
private final Predicate<String> verifyExpression =
Pattern.compile("^([a-zA-Z0-9._-]+|<[a-zA-Z0-9._-]+>)(\\/([a-zA-Z0-9._-]+|<[a-zA-Z0-9._-]+>))+$").asPredicate();
Pattern.compile("^([a-zA-Z0-9._-]+|<[a-zA-Z0-9._-]+>)(\\/([a-zA-Z0-9._-]+|<[a-zA-Z0-9._-]+>))+$").asPredicate();
@ApiOperation("Return the list of topic types")
@GetMapping("")
@ -44,9 +45,9 @@ public class TopicsController extends AbstractLbsController {
@ApiOperation("Register a new topic type")
@PostMapping("/add")
public TopicType registerTopicType(@RequestParam final String name,
@RequestParam final String expression,
@RequestParam final String producerId,
@RequestParam final String mapKeys) {
@RequestParam final String expression,
@RequestParam final String producerId,
@RequestParam final String mapKeys) {
if (StringUtils.isBlank(name)) { throw new IllegalArgumentException("name is empty"); }
if (StringUtils.isBlank(expression)) { throw new IllegalArgumentException("expression is empty"); }

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.controllers.objects;
package eu.dnetlib.broker.controllers.objects;
public class BufferStatus implements Comparable<BufferStatus> {

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.controllers.objects;
package eu.dnetlib.broker.controllers.objects;
import java.util.ArrayList;
import java.util.HashMap;
@ -8,9 +8,9 @@ import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import eu.dnetlib.lbs.properties.DatabaseProperties;
import eu.dnetlib.lbs.properties.ElasticSearchProperties;
import eu.dnetlib.lbs.properties.EmailProperties;
import eu.dnetlib.broker.common.properties.DatabaseProperties;
import eu.dnetlib.broker.common.properties.ElasticSearchProperties;
import eu.dnetlib.broker.properties.EmailProperties;
@Component
public class CurrentStatus {

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.controllers.objects;
package eu.dnetlib.broker.controllers.objects;
public class DispatcherStatus implements Comparable<DispatcherStatus> {

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.controllers.objects;
package eu.dnetlib.broker.controllers.objects;
public class ThreadStatus implements Comparable<ThreadStatus> {

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.controllers.objects;
package eu.dnetlib.broker.controllers.objects;
public class Tool {

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.cron;
package eu.dnetlib.broker.cron;
import java.util.Date;
@ -9,9 +9,9 @@ import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import eu.dnetlib.lbs.elasticsearch.EventRepository;
import eu.dnetlib.lbs.matchers.SubscriptionEventMatcher;
import eu.dnetlib.lbs.subscriptions.SubscriptionRepository;
import eu.dnetlib.broker.common.elasticsearch.EventRepository;
import eu.dnetlib.broker.common.subscriptions.SubscriptionRepository;
import eu.dnetlib.broker.matchers.SubscriptionEventMatcher;
@Component
@Profile("!openaire")

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.events.manager;
package eu.dnetlib.broker.events.manager;
import java.util.List;
import java.util.stream.StreamSupport;
@ -6,15 +6,15 @@ import java.util.stream.StreamSupport;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import eu.dnetlib.lbs.elasticsearch.Event;
import eu.dnetlib.lbs.elasticsearch.EventRepository;
import eu.dnetlib.lbs.elasticsearch.Notification;
import eu.dnetlib.lbs.elasticsearch.NotificationRepository;
import eu.dnetlib.lbs.events.output.DispatcherManager;
import eu.dnetlib.lbs.subscriptions.NotificationFrequency;
import eu.dnetlib.lbs.subscriptions.Subscription;
import eu.dnetlib.lbs.subscriptions.SubscriptionRepository;
import eu.dnetlib.lbs.utils.LbsQueue;
import eu.dnetlib.broker.common.elasticsearch.Event;
import eu.dnetlib.broker.common.elasticsearch.EventRepository;
import eu.dnetlib.broker.common.elasticsearch.Notification;
import eu.dnetlib.broker.common.elasticsearch.NotificationRepository;
import eu.dnetlib.broker.common.subscriptions.NotificationFrequency;
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.utils.LbsQueue;
public class EventManager implements Runnable {
@ -27,9 +27,9 @@ public class EventManager implements Runnable {
private static final Log log = LogFactory.getLog(EventManager.class);
public EventManager(final EventRepository eventRepository, final NotificationRepository notificationRepository,
final SubscriptionRepository subscriptionRepo,
final DispatcherManager dispatcherManager,
final LbsQueue<String, Event> queue) {
final SubscriptionRepository subscriptionRepo,
final DispatcherManager dispatcherManager,
final LbsQueue<String, Event> queue) {
this.eventRepository = eventRepository;
this.notificationRepository = notificationRepository;
this.subscriptionRepo = subscriptionRepo;
@ -52,13 +52,13 @@ public class EventManager implements Runnable {
list.stream().filter(Event::isInstantMessage).forEach(e -> {
final Iterable<Subscription> iter = this.subscriptionRepo.findByTopic(e.getTopic());
StreamSupport.stream(iter.spliterator(), false)
.filter(s -> s.verifyEventConditions(e))
.filter(s -> s.getFrequency() == NotificationFrequency.realtime)
.forEach(s -> {
final Notification n = new Notification(s, e);
this.notificationRepository.save(n);
this.dispatcherManager.dispatch(s, e);
});
.filter(s -> s.verifyEventConditions(e))
.filter(s -> s.getFrequency() == NotificationFrequency.realtime)
.forEach(s -> {
final Notification n = new Notification(s, e);
this.notificationRepository.save(n);
this.dispatcherManager.dispatch(s, e);
});
});
}
}

View File

@ -1,14 +1,14 @@
package eu.dnetlib.lbs.events.manager;
package eu.dnetlib.broker.events.manager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import eu.dnetlib.lbs.elasticsearch.Event;
import eu.dnetlib.lbs.elasticsearch.EventRepository;
import eu.dnetlib.lbs.elasticsearch.NotificationRepository;
import eu.dnetlib.lbs.events.output.DispatcherManager;
import eu.dnetlib.lbs.subscriptions.SubscriptionRepository;
import eu.dnetlib.lbs.utils.LbsQueue;
import eu.dnetlib.broker.common.elasticsearch.Event;
import eu.dnetlib.broker.common.elasticsearch.EventRepository;
import eu.dnetlib.broker.common.elasticsearch.NotificationRepository;
import eu.dnetlib.broker.common.subscriptions.SubscriptionRepository;
import eu.dnetlib.broker.events.output.DispatcherManager;
import eu.dnetlib.broker.utils.LbsQueue;
@Component
public class EventManagerFactory {

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.events.output;
package eu.dnetlib.broker.events.output;
import java.util.concurrent.atomic.AtomicLong;
@ -10,11 +10,11 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.annotation.Autowired;
import eu.dnetlib.lbs.elasticsearch.Event;
import eu.dnetlib.lbs.subscriptions.Subscription;
import eu.dnetlib.lbs.utils.LbsQueue;
import eu.dnetlib.lbs.utils.QueueManager;
import eu.dnetlib.lbs.utils.ThreadManager;
import eu.dnetlib.broker.common.elasticsearch.Event;
import eu.dnetlib.broker.common.subscriptions.Subscription;
import eu.dnetlib.broker.utils.LbsQueue;
import eu.dnetlib.broker.utils.QueueManager;
import eu.dnetlib.broker.utils.ThreadManager;
public abstract class AbstractNotificationDispatcher<T> implements NotificationDispatcher, BeanNameAware, Runnable {

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.events.output;
package eu.dnetlib.broker.events.output;
import java.util.ArrayList;
import java.util.List;
@ -9,8 +9,8 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import eu.dnetlib.lbs.elasticsearch.Event;
import eu.dnetlib.lbs.subscriptions.Subscription;
import eu.dnetlib.broker.common.elasticsearch.Event;
import eu.dnetlib.broker.common.subscriptions.Subscription;
@Component
public class DispatcherManager {
@ -22,9 +22,9 @@ public class DispatcherManager {
public void dispatch(final Subscription s, final Event... events) {
final Optional<NotificationDispatcher> dispatcher = this.dispatchers
.stream()
.filter(d -> d.getMode() == s.getMode())
.findFirst();
.stream()
.filter(d -> d.getMode() == s.getMode())
.findFirst();
if (dispatcher.isPresent()) {
dispatcher.get().sendNotification(s, events);

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.events.output;
package eu.dnetlib.broker.events.output;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@ -27,10 +27,10 @@ import org.springframework.stereotype.Component;
import com.google.common.base.Splitter;
import eu.dnetlib.lbs.elasticsearch.Event;
import eu.dnetlib.lbs.properties.EmailProperties;
import eu.dnetlib.lbs.subscriptions.NotificationMode;
import eu.dnetlib.lbs.subscriptions.Subscription;
import eu.dnetlib.broker.common.elasticsearch.Event;
import eu.dnetlib.broker.common.subscriptions.NotificationMode;
import eu.dnetlib.broker.common.subscriptions.Subscription;
import eu.dnetlib.broker.properties.EmailProperties;
@Component
public class EmailDispatcher extends AbstractNotificationDispatcher<Message> {
@ -117,7 +117,7 @@ public class EmailDispatcher extends AbstractNotificationDispatcher<Message> {
return new Authenticator() {
private final PasswordAuthentication authentication =
new PasswordAuthentication(props.getSmtpUser(), props.getSmtpPassword());
new PasswordAuthentication(props.getSmtpUser(), props.getSmtpPassword());
@Override
protected PasswordAuthentication getPasswordAuthentication() {

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.events.output;
package eu.dnetlib.broker.events.output;
import java.io.StringWriter;
@ -7,9 +7,9 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
import eu.dnetlib.lbs.elasticsearch.Event;
import eu.dnetlib.lbs.subscriptions.NotificationMode;
import eu.dnetlib.lbs.subscriptions.Subscription;
import eu.dnetlib.broker.common.elasticsearch.Event;
import eu.dnetlib.broker.common.subscriptions.NotificationMode;
import eu.dnetlib.broker.common.subscriptions.Subscription;
@Component
@Profile("dev")

View File

@ -0,0 +1,18 @@
package eu.dnetlib.broker.events.output;
import eu.dnetlib.broker.common.elasticsearch.Event;
import eu.dnetlib.broker.common.subscriptions.NotificationMode;
import eu.dnetlib.broker.common.subscriptions.Subscription;
public interface NotificationDispatcher {
void sendNotification(Subscription subscription, Event... events);
void resetCount();
String getDispatcherName();
long count();
NotificationMode getMode();
}

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.matchers;
package eu.dnetlib.broker.matchers;
import java.util.ArrayList;
import java.util.Date;
@ -25,17 +25,17 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilde
import org.springframework.data.util.CloseableIterator;
import org.springframework.stereotype.Component;
import eu.dnetlib.lbs.elasticsearch.Event;
import eu.dnetlib.lbs.elasticsearch.Notification;
import eu.dnetlib.lbs.elasticsearch.NotificationRepository;
import eu.dnetlib.lbs.events.output.DispatcherManager;
import eu.dnetlib.lbs.properties.ElasticSearchProperties;
import eu.dnetlib.lbs.subscriptions.MapCondition;
import eu.dnetlib.lbs.subscriptions.Subscription;
import eu.dnetlib.lbs.subscriptions.SubscriptionRepository;
import eu.dnetlib.lbs.utils.LbsQueue;
import eu.dnetlib.lbs.utils.QueueManager;
import eu.dnetlib.lbs.utils.ThreadManager;
import eu.dnetlib.broker.common.elasticsearch.Event;
import eu.dnetlib.broker.common.elasticsearch.Notification;
import eu.dnetlib.broker.common.elasticsearch.NotificationRepository;
import eu.dnetlib.broker.common.properties.ElasticSearchProperties;
import eu.dnetlib.broker.common.subscriptions.MapCondition;
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.utils.LbsQueue;
import eu.dnetlib.broker.utils.QueueManager;
import eu.dnetlib.broker.utils.ThreadManager;
@Profile("!openaire")
@Component

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.metrics;
package eu.dnetlib.broker.metrics;
public interface MetricInterceptor {

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.metrics;
package eu.dnetlib.broker.metrics;
import java.lang.reflect.Method;
import javax.servlet.http.HttpServletRequest;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.metrics;
package eu.dnetlib.broker.metrics;
import java.lang.reflect.Method;
import javax.servlet.http.HttpServletRequest;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.metrics;
package eu.dnetlib.broker.metrics;
import java.util.List;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.openaire;
package eu.dnetlib.broker.openaire;
import java.util.ArrayList;
import java.util.Arrays;
@ -7,10 +7,10 @@ import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import eu.dnetlib.lbs.subscriptions.ConditionOperator;
import eu.dnetlib.lbs.subscriptions.ConditionParams;
import eu.dnetlib.lbs.subscriptions.MapCondition;
import eu.dnetlib.lbs.utils.MapValueType;
import eu.dnetlib.broker.common.subscriptions.ConditionOperator;
import eu.dnetlib.broker.common.subscriptions.ConditionParams;
import eu.dnetlib.broker.common.subscriptions.MapCondition;
import eu.dnetlib.broker.common.utils.MapValueType;
public class AdvQueryObject {
@ -25,7 +25,7 @@ public class AdvQueryObject {
public AdvQueryObject() {}
public AdvQueryObject(final String datasource, final String topic, final List<String> titles, final List<String> subjects, final List<String> authors,
final List<Range> dates, final Range trust) {
final List<Range> dates, final Range trust) {
super();
this.datasource = datasource;
this.topic = topic;
@ -96,32 +96,32 @@ public class AdvQueryObject {
final List<MapCondition> list = new ArrayList<>();
final List<ConditionParams> list_dates = this.dates.stream()
.filter(Range::isValid)
.map(d -> new ConditionParams(d.getMin(), d.getMax()))
.collect(Collectors.toList());
.filter(Range::isValid)
.map(d -> new ConditionParams(d.getMin(), d.getMax()))
.collect(Collectors.toList());
final List<ConditionParams> list_titles = this.titles.stream()
.filter(StringUtils::isNotBlank)
.map(t -> new ConditionParams(t, null))
.collect(Collectors.toList());
.filter(StringUtils::isNotBlank)
.map(t -> new ConditionParams(t, null))
.collect(Collectors.toList());
final List<ConditionParams> list_authors = this.authors.stream()
.filter(StringUtils::isNotBlank)
.map(aut -> new ConditionParams(aut, null))
.collect(Collectors.toList());
.filter(StringUtils::isNotBlank)
.map(aut -> new ConditionParams(aut, null))
.collect(Collectors.toList());
final List<ConditionParams> list_subjects = this.subjects.stream()
.filter(StringUtils::isNotBlank)
.map(s -> new ConditionParams(s, null))
.collect(Collectors.toList());
.filter(StringUtils::isNotBlank)
.map(s -> new ConditionParams(s, null))
.collect(Collectors.toList());
if (StringUtils.isNotBlank(this.datasource)) {
list.add(new MapCondition("targetDatasourceName", MapValueType.STRING, ConditionOperator.EXACT,
Arrays.asList(new ConditionParams(this.datasource, null))));
Arrays.asList(new ConditionParams(this.datasource, null))));
}
if (this.trust.isValid()) {
list.add(new MapCondition("trust", MapValueType.FLOAT, ConditionOperator.RANGE,
Arrays.asList(new ConditionParams(this.trust.getMin(), this.trust.getMax()))));
Arrays.asList(new ConditionParams(this.trust.getMin(), this.trust.getMax()))));
}
if (!list_dates.isEmpty()) {
list.add(new MapCondition("targetDateofacceptance", MapValueType.DATE, ConditionOperator.RANGE, list_dates));

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.openaire;
package eu.dnetlib.broker.openaire;
public class BrowseEntry implements Comparable<BrowseEntry> {

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.openaire;
package eu.dnetlib.broker.openaire;
import java.util.Date;
import java.util.List;
@ -10,7 +10,7 @@ import org.elasticsearch.index.query.Operator;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.search.MatchQuery.ZeroTermsQuery;
import eu.dnetlib.lbs.utils.DateParser;
import eu.dnetlib.broker.common.utils.DateParser;
public class ElasticSearchQueryUtils {

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.openaire;
package eu.dnetlib.broker.openaire;
import java.util.List;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.openaire;
package eu.dnetlib.broker.openaire;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.openaire;
package eu.dnetlib.broker.openaire;
import java.util.ArrayList;
import java.util.Arrays;
@ -41,16 +41,16 @@ import org.springframework.web.bind.annotation.RestController;
import com.google.gson.Gson;
import eu.dnetlib.broker.LiteratureBrokerServiceConfiguration;
import eu.dnetlib.broker.common.controllers.AbstractLbsController;
import eu.dnetlib.broker.common.elasticsearch.Event;
import eu.dnetlib.broker.common.elasticsearch.Notification;
import eu.dnetlib.broker.common.elasticsearch.NotificationRepository;
import eu.dnetlib.broker.common.properties.ElasticSearchProperties;
import eu.dnetlib.broker.common.subscriptions.MapCondition;
import eu.dnetlib.broker.common.subscriptions.Subscription;
import eu.dnetlib.broker.common.subscriptions.SubscriptionRepository;
import eu.dnetlib.broker.objects.OaBrokerEventPayload;
import eu.dnetlib.lbs.LiteratureBrokerServiceConfiguration;
import eu.dnetlib.lbs.controllers.AbstractLbsController;
import eu.dnetlib.lbs.elasticsearch.Event;
import eu.dnetlib.lbs.elasticsearch.Notification;
import eu.dnetlib.lbs.elasticsearch.NotificationRepository;
import eu.dnetlib.lbs.properties.ElasticSearchProperties;
import eu.dnetlib.lbs.subscriptions.MapCondition;
import eu.dnetlib.lbs.subscriptions.Subscription;
import eu.dnetlib.lbs.subscriptions.SubscriptionRepository;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

View File

@ -1,13 +1,13 @@
package eu.dnetlib.lbs.openaire;
package eu.dnetlib.broker.openaire;
import java.util.Date;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
import eu.dnetlib.lbs.subscriptions.NotificationFrequency;
import eu.dnetlib.lbs.subscriptions.NotificationMode;
import eu.dnetlib.lbs.subscriptions.Subscription;
import eu.dnetlib.broker.common.subscriptions.NotificationFrequency;
import eu.dnetlib.broker.common.subscriptions.NotificationMode;
import eu.dnetlib.broker.common.subscriptions.Subscription;
public class OpenaireSubscription {
@ -19,7 +19,7 @@ public class OpenaireSubscription {
public OpenaireSubscription() {}
public OpenaireSubscription(final String subscriber, final NotificationFrequency frequency, final NotificationMode mode,
final AdvQueryObject query) {
final AdvQueryObject query) {
this.subscriber = subscriber;
this.frequency = frequency;
this.mode = mode;
@ -65,7 +65,7 @@ public class OpenaireSubscription {
final String subscriptionId = "sub-" + UUID.randomUUID();
return new Subscription(subscriptionId, this.subscriber, this.query.getTopic(), this.frequency, this.mode, null, new Date(),
this.query.asListOfConditions());
this.query.asListOfConditions());
}
}

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.openaire;
package eu.dnetlib.broker.openaire;
import org.apache.commons.lang3.StringUtils;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.openaire;
package eu.dnetlib.broker.openaire;
import java.util.List;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.properties;
package eu.dnetlib.broker.properties;
import javax.validation.constraints.NotNull;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.utils;
package eu.dnetlib.broker.utils;
import java.time.Duration;
import java.time.Instant;
@ -12,9 +12,9 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import eu.dnetlib.lbs.elasticsearch.Event;
import eu.dnetlib.lbs.topics.TopicType;
import eu.dnetlib.lbs.topics.TopicTypeRepository;
import eu.dnetlib.broker.common.elasticsearch.Event;
import eu.dnetlib.broker.common.topics.TopicType;
import eu.dnetlib.broker.common.topics.TopicTypeRepository;
public class EventVerifier implements Predicate<Event> {

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.utils;
package eu.dnetlib.broker.utils;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.utils;
package eu.dnetlib.broker.utils;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.utils;
package eu.dnetlib.broker.utils;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,18 +0,0 @@
package eu.dnetlib.lbs.events.output;
import eu.dnetlib.lbs.elasticsearch.Event;
import eu.dnetlib.lbs.subscriptions.NotificationMode;
import eu.dnetlib.lbs.subscriptions.Subscription;
public interface NotificationDispatcher {
void sendNotification(Subscription subscription, Event... events);
void resetCount();
String getDispatcherName();
long count();
NotificationMode getMode();
}

View File

@ -1,11 +1,11 @@
package eu.dnetlib.lbs.integration;
package eu.dnetlib.broker.integration;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.web.client.RestTemplate;
import eu.dnetlib.broker.objects.OaBrokerEventPayload;
import eu.dnetlib.lbs.controllers.ScrollPage;
import eu.dnetlib.broker.openaire.ScrollPage;
public class ScrollTest {

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.tests;
package eu.dnetlib.broker.tests;
import java.util.Arrays;
@ -22,12 +22,12 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilde
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import eu.dnetlib.broker.common.elasticsearch.Event;
import eu.dnetlib.broker.objects.OaBrokerEventPayload;
import eu.dnetlib.broker.objects.OaBrokerMainEntity;
import eu.dnetlib.lbs.elasticsearch.Event;
import eu.dnetlib.lbs.openaire.AdvQueryObject;
import eu.dnetlib.lbs.openaire.ElasticSearchQueryUtils;
import eu.dnetlib.lbs.openaire.Range;
import eu.dnetlib.broker.openaire.AdvQueryObject;
import eu.dnetlib.broker.openaire.ElasticSearchQueryUtils;
import eu.dnetlib.broker.openaire.Range;
@Ignore
@RunWith(SpringJUnit4ClassRunner.class)

View File

@ -10,7 +10,7 @@
cluster-name="elasticsearch_michele" />
<elasticsearch:repositories
base-package="eu.dnetlib.lbs.elasticsearch"
base-package="eu.dnetlib.broker.elasticsearch"
elasticsearch-template-ref="elasticsearchTemplate" />
<bean id="elasticsearchTemplate" class="org.springframework.data.elasticsearch.core.ElasticsearchTemplate">

View File

@ -7,7 +7,7 @@
<logger name="root" level="OFF">
<appender-ref ref="CONSOLE" />
</logger>
<logger name="eu.dnetlib.lbs" level="INFO">
<logger name="eu.dnetlib.broker" level="INFO">
<appender-ref ref="CONSOLE" />
</logger>
</configuration>

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs;
package eu.dnetlib.broker;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -16,9 +16,9 @@ import org.springframework.data.elasticsearch.repository.config.EnableElasticsea
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import eu.dnetlib.lbs.elasticsearch.Event;
import eu.dnetlib.lbs.elasticsearch.Notification;
import eu.dnetlib.lbs.properties.ElasticSearchProperties;
import eu.dnetlib.broker.common.elasticsearch.Event;
import eu.dnetlib.broker.common.elasticsearch.Notification;
import eu.dnetlib.broker.common.properties.ElasticSearchProperties;
import io.prometheus.client.exporter.MetricsServlet;
import io.prometheus.client.hotspot.DefaultExports;
import springfox.documentation.builders.RequestHandlerSelectors;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs;
package eu.dnetlib.broker;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.controllers;
package eu.dnetlib.broker.oa.controllers;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

View File

@ -0,0 +1,40 @@
package eu.dnetlib.broker.oa.controllers;
import java.io.Serializable;
import com.google.gson.Gson;
import eu.dnetlib.broker.common.elasticsearch.Notification;
import eu.dnetlib.broker.objects.OaBrokerEventPayload;
public class NotificationMessage implements Serializable {
/**
*
*/
private static final long serialVersionUID = 7302363775341307950L;
private String topic;
public static NotificationMessage fromNotification(final Notification n) {
final Gson gson = new Gson();
final OaBrokerEventPayload payload = gson.fromJson(n.getPayload(), OaBrokerEventPayload.class);
final NotificationMessage res = new NotificationMessage();
res.setTopic(n.getTopic());
// TODO Auto-generated method stub
return res;
}
public String getTopic() {
return topic;
}
public void setTopic(final String topic) {
this.topic = topic;
}
}

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.controllers;
package eu.dnetlib.broker.oa.controllers;
import java.util.ArrayList;
import java.util.Arrays;
@ -6,8 +6,10 @@ import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.lucene.search.join.ScoreMode;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.beans.factory.annotation.Autowired;
@ -24,15 +26,12 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.google.gson.Gson;
import eu.dnetlib.broker.objects.OaBrokerEventPayload;
import eu.dnetlib.lbs.BrokerConfiguration;
import eu.dnetlib.lbs.elasticsearch.Notification;
import eu.dnetlib.lbs.elasticsearch.NotificationRepository;
import eu.dnetlib.lbs.properties.ElasticSearchProperties;
import eu.dnetlib.lbs.subscriptions.Subscription;
import eu.dnetlib.lbs.subscriptions.SubscriptionRepository;
import eu.dnetlib.broker.BrokerConfiguration;
import eu.dnetlib.broker.common.controllers.AbstractLbsController;
import eu.dnetlib.broker.common.elasticsearch.Notification;
import eu.dnetlib.broker.common.properties.ElasticSearchProperties;
import eu.dnetlib.broker.common.subscriptions.Subscription;
import eu.dnetlib.broker.common.subscriptions.SubscriptionRepository;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -40,14 +39,11 @@ import io.swagger.annotations.ApiOperation;
@RestController
@RequestMapping("/api/openaireBroker")
@Api(tags = BrokerConfiguration.TAG_OPENAIRE)
public class OpenaireBrokerController extends AbstractLbsController {
public class OpenairePublicController extends AbstractLbsController {
@Autowired
private ElasticsearchOperations esOperations;
@Autowired
private NotificationRepository notificationRepository;
@Autowired
private SubscriptionRepository subscriptionRepo;
@ -56,11 +52,11 @@ public class OpenaireBrokerController extends AbstractLbsController {
private static final long SCROLL_TIMEOUT_IN_MILLIS = 5 * 60 * 1000;
private static final Log log = LogFactory.getLog(OpenaireBrokerController.class);
private static final Log log = LogFactory.getLog(OpenairePublicController.class);
@ApiOperation("Returns notifications using scrolls (first page)")
@GetMapping("/scroll/notifications/start/{subscrId}")
public ScrollPage prepareScrollNotifications(@PathVariable final String subscrId) {
@ApiOperation("Returns notifications by subscription using scrolls (first page)")
@GetMapping("/scroll/notifications/bySubscriptionId/{subscrId}")
public ScrollPage<NotificationMessage> prepareScrollNotificationsBySubscrId(@PathVariable final String subscrId) {
final Optional<Subscription> optSub = subscriptionRepo.findById(subscrId);
@ -77,50 +73,75 @@ public class OpenaireBrokerController extends AbstractLbsController {
final SearchScrollHits<Notification> scroll =
esTemplate.searchScrollStart(SCROLL_TIMEOUT_IN_MILLIS, searchQuery, Notification.class, IndexCoordinates.of(props.getNotificationsIndexName()));
if (scroll.hasSearchHits()) {
final List<OaBrokerEventPayload> values = calculateEventPayloads(scroll);
return new ScrollPage(scroll.getScrollId(), values.isEmpty() || scroll.getScrollId() == null, values);
final List<NotificationMessage> values = calculateNotificationMessages(scroll);
return new ScrollPage<>(scroll.getScrollId(), values.isEmpty() || scroll.getScrollId() == null, values);
} else {
esTemplate.searchScrollClear(Arrays.asList(scroll.getScrollId()));
return new ScrollPage(null, true, new ArrayList<>());
return new ScrollPage<>(null, true, new ArrayList<>());
}
} else {
log.warn("Invalid subscription: " + subscrId);
return new ScrollPage();
return new ScrollPage<>();
}
}
@ApiOperation("Returns notifications by opendorar Id (for example: 301) using scrolls (first page)")
@GetMapping("/scroll/notifications/byOpenDoarId/{opendoarId}")
public ScrollPage<NotificationMessage> prepareScrollNotificationsByOpendoarId(@PathVariable final String opendoarId) {
final ElasticsearchRestTemplate esTemplate = (ElasticsearchRestTemplate) esOperations;
final String dsId = calculateDsIdFromOpenDoarId(opendoarId);
final NativeSearchQuery searchQuery = new NativeSearchQueryBuilder()
.withQuery(QueryBuilders.nestedQuery("map", QueryBuilders.matchQuery("map.targetDatasourceId", dsId), ScoreMode.None))
.withSearchType(SearchType.DEFAULT)
.withFields("payload")
.build();
final SearchScrollHits<Notification> scroll =
esTemplate.searchScrollStart(SCROLL_TIMEOUT_IN_MILLIS, searchQuery, Notification.class, IndexCoordinates.of(props.getNotificationsIndexName()));
if (scroll.hasSearchHits()) {
final List<NotificationMessage> values = calculateNotificationMessages(scroll);
return new ScrollPage<>(scroll.getScrollId(), values.isEmpty() || scroll.getScrollId() == null, values);
} else {
esTemplate.searchScrollClear(Arrays.asList(scroll.getScrollId()));
return new ScrollPage<>(null, true, new ArrayList<>());
}
}
private String calculateDsIdFromOpenDoarId(final String opendoarId) {
return "10|opendoar____::" + DigestUtils.md5Hex(opendoarId);
}
@ApiOperation("Returns notifications using scrolls (other pages)")
@GetMapping("/scroll/notifications/{scrollId}")
public ScrollPage scrollNotifications(@PathVariable final String scrollId) {
public ScrollPage<NotificationMessage> scrollNotifications(@PathVariable final String scrollId) {
final ElasticsearchRestTemplate esTemplate = (ElasticsearchRestTemplate) esOperations;
final SearchScrollHits<Notification> scroll =
esTemplate.searchScrollContinue(scrollId, SCROLL_TIMEOUT_IN_MILLIS, Notification.class, IndexCoordinates.of(props.getNotificationsIndexName()));
if (scroll.hasSearchHits()) {
final List<OaBrokerEventPayload> values = calculateEventPayloads(scroll);
return new ScrollPage(scroll.getScrollId(), values.isEmpty() || scroll.getScrollId() == null, values);
final List<NotificationMessage> values = calculateNotificationMessages(scroll);
return new ScrollPage<>(scroll.getScrollId(), values.isEmpty() || scroll.getScrollId() == null, values);
} else {
esTemplate.searchScrollClear(Arrays.asList(scroll.getScrollId()));
return new ScrollPage(null, true, new ArrayList<>());
return new ScrollPage<>(null, true, new ArrayList<>());
}
}
private List<OaBrokerEventPayload> calculateEventPayloads(final SearchScrollHits<Notification> scroll) {
private List<NotificationMessage> calculateNotificationMessages(final SearchScrollHits<Notification> scroll) {
if (scroll.getSearchHits().size() > 0) {
final Gson gson = new Gson();
return scroll.stream()
.map(SearchHit::getContent)
.map(Notification::getPayload)
.map(s -> gson.fromJson(s, OaBrokerEventPayload.class))
.map(NotificationMessage::fromNotification)
.collect(Collectors.toList());
} else {
return new ArrayList<>();
}
}
}

View File

@ -1,20 +1,18 @@
package eu.dnetlib.lbs.controllers;
package eu.dnetlib.broker.oa.controllers;
import java.util.List;
import eu.dnetlib.broker.objects.OaBrokerEventPayload;
public class ScrollPage {
public class ScrollPage<T> {
private String id;
private boolean completed;
private List<OaBrokerEventPayload> values;
private List<T> values;
public ScrollPage() {}
public ScrollPage(final String id, final boolean completed, final List<OaBrokerEventPayload> values) {
public ScrollPage(final String id, final boolean completed, final List<T> values) {
this.id = id;
this.completed = completed;
this.values = values;
@ -36,11 +34,11 @@ public class ScrollPage {
this.completed = completed;
}
public List<OaBrokerEventPayload> getValues() {
public List<T> getValues() {
return values;
}
public void setValues(final List<OaBrokerEventPayload> values) {
public void setValues(final List<T> values) {
this.values = values;
}

View File

@ -23,7 +23,6 @@ lbs.database.url = ${spring.datasource.url}
#lbs.elastic.clusterNodes = broker1-dev-dnet.d4science.org:9300
#lbs.elastic.homepage = http://broker1-dev-dnet.d4science.org:9200/_plugin/hq
# for localhost
lbs.elastic.clusterNodes = 127.0.0.1:9200
lbs.elastic.homepage = http://
@ -32,8 +31,6 @@ lbs.elastic.connectionTimeout = 30000
lbs.elastic.eventsIndexName = oa_events_beta
lbs.elastic.notificationsIndexName = oa_notifications_beta
lbs.queues.maxReturnedValues = 1000
lbs.task.deleteOldEvents.cron = 0 0 4 1/1 * ?

View File

@ -1,11 +1,11 @@
package eu.dnetlib.lbs.integration;
package eu.dnetlib.broker.oa.integration;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.web.client.RestTemplate;
import eu.dnetlib.broker.objects.OaBrokerEventPayload;
import eu.dnetlib.lbs.openaire.ScrollPage;
import eu.dnetlib.broker.oa.controllers.NotificationMessage;
import eu.dnetlib.broker.oa.controllers.ScrollPage;
public class ScrollTest {
@ -15,19 +15,21 @@ public class ScrollTest {
private static final String subscriptionId = "sub-c9767c84-3597-462b-803b-2d3e09de44c4";
public class TestScrollPage extends ScrollPage<NotificationMessage> {}
@Test
@Ignore
public void testScroll() {
int total = 0;
ScrollPage page = getPage(baseUrl + "/api/openaireBroker/scroll/notifications/start/ " + subscriptionId);
TestScrollPage page = getPage(baseUrl + "/api/openaireBroker/scroll/notifications/start/ " + subscriptionId);
total += page.getValues().size();
while (!page.isCompleted()) {
page = getPage(baseUrl + "/api/openaireBroker/scroll/notifications/ " + page.getId());
total += page.getValues().size();
for (final OaBrokerEventPayload p : page.getValues()) {
for (final NotificationMessage p : page.getValues()) {
// DO SOMETHING
}
}
@ -35,9 +37,9 @@ public class ScrollTest {
System.out.println("\nTOTAL: " + total);
}
private ScrollPage getPage(final String url) {
private TestScrollPage getPage(final String url) {
System.out.println(url);
final ScrollPage p = new RestTemplate().getForObject(url, ScrollPage.class);
final TestScrollPage p = new RestTemplate().getForObject(url, TestScrollPage.class);
System.out.println("Page size: " + p.getValues().size());
return p;
}

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.controllers;
package eu.dnetlib.broker.common.controllers;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.http.HttpStatus;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.elasticsearch;
package eu.dnetlib.broker.common.elasticsearch;
import java.util.Map;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.elasticsearch;
package eu.dnetlib.broker.common.elasticsearch;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.elasticsearch;
package eu.dnetlib.broker.common.elasticsearch;
import java.util.List;
import java.util.stream.Collectors;
@ -18,7 +18,7 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.stereotype.Component;
import eu.dnetlib.lbs.properties.ElasticSearchProperties;
import eu.dnetlib.broker.common.properties.ElasticSearchProperties;
@Component
public class EventStatsManager {

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.elasticsearch;
package eu.dnetlib.broker.common.elasticsearch;
import java.util.Date;
import java.util.Map;
@ -9,7 +9,7 @@ import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import eu.dnetlib.lbs.subscriptions.Subscription;
import eu.dnetlib.broker.common.subscriptions.Subscription;
@Document(indexName = "#{elasticSearchProperties.notificationsIndexName}", shards = 48, replicas = 1, refreshInterval = "600s")
public class Notification {

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.elasticsearch;
package eu.dnetlib.broker.common.elasticsearch;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.properties;
package eu.dnetlib.broker.common.properties;
import javax.validation.constraints.NotNull;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.properties;
package eu.dnetlib.broker.common.properties;
import javax.validation.constraints.NotNull;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.subscriptions;
package eu.dnetlib.broker.common.subscriptions;
public enum ConditionOperator {
EXACT, MATCH_ANY, MATCH_ALL, RANGE

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.subscriptions;
package eu.dnetlib.broker.common.subscriptions;
import java.util.Arrays;
import java.util.Date;
@ -8,7 +8,7 @@ import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import eu.dnetlib.lbs.utils.DateParser;
import eu.dnetlib.broker.common.utils.DateParser;
public class ConditionParams {

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.subscriptions;
package eu.dnetlib.broker.common.subscriptions;
import java.util.ArrayList;
import java.util.Date;
@ -14,9 +14,9 @@ import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.search.MatchQuery.ZeroTermsQuery;
import eu.dnetlib.lbs.elasticsearch.Event;
import eu.dnetlib.lbs.utils.DateParser;
import eu.dnetlib.lbs.utils.MapValueType;
import eu.dnetlib.broker.common.elasticsearch.Event;
import eu.dnetlib.broker.common.utils.DateParser;
import eu.dnetlib.broker.common.utils.MapValueType;
public class MapCondition {

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.subscriptions;
package eu.dnetlib.broker.common.subscriptions;
public enum NotificationFrequency {
never, realtime, daily, weekly, monthly

View File

@ -0,0 +1,5 @@
package eu.dnetlib.broker.common.subscriptions;
public enum NotificationMode {
MOCK, EMAIL
}

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.subscriptions;
package eu.dnetlib.broker.common.subscriptions;
import java.util.Date;
import java.util.List;
@ -14,7 +14,7 @@ import javax.persistence.Table;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import eu.dnetlib.lbs.elasticsearch.Event;
import eu.dnetlib.broker.common.elasticsearch.Event;
@Entity(name = "subscriptions")
@Table(name = "subscriptions")

View File

@ -1,7 +1,9 @@
package eu.dnetlib.lbs.subscriptions;
package eu.dnetlib.broker.common.subscriptions;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface SubscriptionRepository extends CrudRepository<Subscription, String> {
Iterable<Subscription> findByTopic(String topic);

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.topics;
package eu.dnetlib.broker.common.topics;
import java.util.Set;
import java.util.function.Predicate;
@ -15,7 +15,7 @@ import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.Sets;
import eu.dnetlib.lbs.elasticsearch.Event;
import eu.dnetlib.broker.common.elasticsearch.Event;
@Entity(name = "topic_types")
@Table(name = "topic_types")

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.topics;
package eu.dnetlib.broker.common.topics;
import org.springframework.data.repository.CrudRepository;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.utils;
package eu.dnetlib.broker.common.utils;
import java.text.ParseException;
import java.util.Date;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.utils;
package eu.dnetlib.broker.common.utils;
import java.util.List;
import java.util.stream.Collectors;

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.utils;
package eu.dnetlib.broker.common.utils;
public enum MapValueType {
STRING, INTEGER, FLOAT, DATE, BOOLEAN, LIST_STRING, LIST_INTEGER, LIST_FLOAT, LIST_DATE, LIST_BOOLEAN;

View File

@ -1,5 +0,0 @@
package eu.dnetlib.lbs.subscriptions;
public enum NotificationMode {
MOCK, EMAIL
}

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.clients;
package eu.dnetlib.broker.common.clients;
import java.util.Date;
import java.util.Objects;
@ -19,12 +19,12 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.util.CloseableIterator;
import eu.dnetlib.lbs.elasticsearch.Event;
import eu.dnetlib.lbs.subscriptions.MapCondition;
import eu.dnetlib.lbs.subscriptions.NotificationFrequency;
import eu.dnetlib.lbs.subscriptions.NotificationMode;
import eu.dnetlib.lbs.subscriptions.Subscription;
import eu.dnetlib.lbs.utils.DateParser;
import eu.dnetlib.broker.common.elasticsearch.Event;
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.utils.DateParser;
@Ignore
// @RunWith(SpringJUnit4ClassRunner.class)

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.subscriptions;
package eu.dnetlib.broker.common.subscriptions;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@ -14,9 +14,9 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import eu.dnetlib.lbs.elasticsearch.Event;
import eu.dnetlib.lbs.utils.DateParser;
import eu.dnetlib.lbs.utils.MapValueType;
import eu.dnetlib.broker.common.elasticsearch.Event;
import eu.dnetlib.broker.common.utils.DateParser;
import eu.dnetlib.broker.common.utils.MapValueType;
@RunWith(MockitoJUnitRunner.class)
public class ConditionTest {

View File

@ -1,4 +1,4 @@
package eu.dnetlib.lbs.utils;
package eu.dnetlib.broker.common.utils;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@ -13,8 +13,8 @@ import java.util.List;
import org.junit.Before;
import org.junit.Test;
import eu.dnetlib.lbs.utils.MapValue;
import eu.dnetlib.lbs.utils.MapValueType;
import eu.dnetlib.broker.common.utils.MapValue;
import eu.dnetlib.broker.common.utils.MapValueType;
public class MapValueTest {

View File

@ -10,7 +10,7 @@
cluster-name="elasticsearch_michele" />
<elasticsearch:repositories
base-package="eu.dnetlib.lbs.elasticsearch"
base-package="eu.dnetlib.broker.common.elasticsearch"
elasticsearch-template-ref="elasticsearchTemplate" />
<bean id="elasticsearchTemplate" class="org.springframework.data.elasticsearch.core.ElasticsearchTemplate">

View File

@ -7,7 +7,7 @@
<logger name="root" level="OFF">
<appender-ref ref="CONSOLE" />
</logger>
<logger name="eu.dnetlib.lbs" level="INFO">
<logger name="eu.dnetlib.broker.common" level="INFO">
<appender-ref ref="CONSOLE" />
</logger>
</configuration>