change packages
This commit is contained in:
parent
062d636572
commit
1bf492b488
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs;
|
||||
package eu.dnetlib.broker;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
@ -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;
|
|
@ -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")
|
|
@ -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;
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.controllers.objects;
|
||||
package eu.dnetlib.broker.controllers.objects;
|
||||
|
||||
public class BufferStatus implements Comparable<BufferStatus> {
|
||||
|
|
@ -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 {
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.controllers.objects;
|
||||
package eu.dnetlib.broker.controllers.objects;
|
||||
|
||||
public class DispatcherStatus implements Comparable<DispatcherStatus> {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.controllers.objects;
|
||||
package eu.dnetlib.broker.controllers.objects;
|
||||
|
||||
public class ThreadStatus implements Comparable<ThreadStatus> {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.controllers.objects;
|
||||
package eu.dnetlib.broker.controllers.objects;
|
||||
|
||||
public class Tool {
|
||||
|
|
@ -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")
|
|
@ -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 {
|
||||
|
|
@ -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 {
|
|
@ -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 {
|
||||
|
|
@ -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 {
|
|
@ -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> {
|
|
@ -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")
|
|
@ -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();
|
||||
}
|
|
@ -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
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.metrics;
|
||||
package eu.dnetlib.broker.metrics;
|
||||
|
||||
public interface MetricInterceptor {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.metrics;
|
||||
package eu.dnetlib.broker.metrics;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import javax.servlet.http.HttpServletRequest;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.metrics;
|
||||
package eu.dnetlib.broker.metrics;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import javax.servlet.http.HttpServletRequest;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.metrics;
|
||||
package eu.dnetlib.broker.metrics;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -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 {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.openaire;
|
||||
package eu.dnetlib.broker.openaire;
|
||||
|
||||
public class BrowseEntry implements Comparable<BrowseEntry> {
|
||||
|
|
@ -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 {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.openaire;
|
||||
package eu.dnetlib.broker.openaire;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -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;
|
|
@ -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;
|
||||
|
|
@ -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 {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.openaire;
|
||||
package eu.dnetlib.broker.openaire;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.openaire;
|
||||
package eu.dnetlib.broker.openaire;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.openaire;
|
||||
package eu.dnetlib.broker.openaire;
|
||||
|
||||
import java.util.Date;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.properties;
|
||||
package eu.dnetlib.broker.properties;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
|
@ -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> {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.utils;
|
||||
package eu.dnetlib.broker.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.utils;
|
||||
package eu.dnetlib.broker.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.utils;
|
||||
package eu.dnetlib.broker.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -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();
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs;
|
||||
package eu.dnetlib.broker;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
|
@ -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 {
|
||||
|
|
@ -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)
|
|
@ -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">
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs;
|
||||
package eu.dnetlib.broker;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
@ -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;
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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<>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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 * ?
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.elasticsearch;
|
||||
package eu.dnetlib.broker.common.elasticsearch;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
@ -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;
|
|
@ -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 {
|
|
@ -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 {
|
|
@ -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;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.properties;
|
||||
package eu.dnetlib.broker.common.properties;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.properties;
|
||||
package eu.dnetlib.broker.common.properties;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.subscriptions;
|
||||
package eu.dnetlib.broker.common.subscriptions;
|
||||
|
||||
public enum ConditionOperator {
|
||||
EXACT, MATCH_ANY, MATCH_ALL, RANGE
|
|
@ -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 {
|
||||
|
|
@ -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 {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.subscriptions;
|
||||
package eu.dnetlib.broker.common.subscriptions;
|
||||
|
||||
public enum NotificationFrequency {
|
||||
never, realtime, daily, weekly, monthly
|
|
@ -0,0 +1,5 @@
|
|||
package eu.dnetlib.broker.common.subscriptions;
|
||||
|
||||
public enum NotificationMode {
|
||||
MOCK, EMAIL
|
||||
}
|
|
@ -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")
|
|
@ -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);
|
|
@ -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")
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.topics;
|
||||
package eu.dnetlib.broker.common.topics;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.utils;
|
||||
package eu.dnetlib.broker.common.utils;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
|
@ -1,4 +1,4 @@
|
|||
package eu.dnetlib.lbs.utils;
|
||||
package eu.dnetlib.broker.common.utils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
|
@ -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;
|
|
@ -1,5 +0,0 @@
|
|||
package eu.dnetlib.lbs.subscriptions;
|
||||
|
||||
public enum NotificationMode {
|
||||
MOCK, EMAIL
|
||||
}
|
|
@ -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)
|
|
@ -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 {
|
|
@ -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 {
|
||||
|
|
@ -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">
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue