Project

General

Profile

« Previous | Next » 

Revision 57561

cris branch

View differences:

modules/uoa-repository-manager-service/branches/cris/Dockerfile
1
FROM tomcat:7.0.90-jre8
2
MAINTAINER "pkanakakis@di.uoa.gr"
3
RUN ["rm", "-fr", "/usr/local/tomcat/webapps/ROOT"]
4
COPY ./target/uoa-repository-manager-service.war /usr/local/tomcat/webapps/uoa-repository-manager-service.war
5
#COPY src/main/resources/dnet-override-new.properties /usr/local/tomcat/lib/dnet-override.properties
6
COPY src/main/resources/application.properties /usr/local/tomcat/lib/dnet-override.properties
7
#COPY src/main/resources/application.properties /usr/local/tomcat/lib/application.properties
8
#COPY src/main/resources/email-texts.properties /usr/local/tomcat/lib/email-texts.properties
9
VOLUME /var/log/uoa-repository-manager-service:/var/log/uoa-repository-manager-service/
10
CMD ["catalina.sh", "run"]
11

  
modules/uoa-repository-manager-service/branches/cris/src/test/java/unitest/PiwikTest.java
1
/*
2
package unitest;
3

  
4
import com.fasterxml.jackson.databind.ObjectMapper;
5
import eu.dnetlib.repo.manager.config.RepoManagerContextLoaderListener;
6
import org.apache.commons.lang.StringEscapeUtils;
7
import org.junit.Test;
8
import org.junit.runner.RunWith;
9
import org.springframework.context.annotation.ComponentScan;
10
import org.springframework.test.context.ContextConfiguration;
11
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
12

  
13
import java.io.IOException;
14
import java.io.UnsupportedEncodingException;
15
import java.net.URL;
16
import java.net.URLEncoder;
17
import java.util.Map;
18

  
19
@RunWith(SpringJUnit4ClassRunner.class)
20
@ContextConfiguration(classes = RepoManagerContextLoaderListener.class)
21
public class PiwikTest {
22

  
23
    String analyticsURL = "https://analytics.openaire.eu/addsite.php?";
24

  
25
    @Test
26
    public void enableMetricsRepo1(){
27

  
28
        String officialName = "BỘ SƯU TẬP SỐ";
29
        String repoWebsite = "http://www.vnulib.edu.vn:8000/dspace/";
30

  
31
        enableMetrics(officialName, repoWebsite, analyticsURL);
32

  
33
    }
34

  
35
    @Test
36
    public void enableMetricsRepo2(){
37

  
38
        String officialName = "ILC4CLARIN repository of language resources and tools";
39
        String repoWebsite = "https://dspace-clarin-it.ilc.cnr.it/repository/xmlui";
40

  
41
        enableMetrics(officialName, repoWebsite, analyticsURL);
42
    }
43

  
44
    @Test
45
    public void enableMetricsRepo3(){
46

  
47
        String officialName = "ANSTO Publications Online";
48
        String repoWebsite = "http://apo.ansto.gov.au/dspace/";
49

  
50
        enableMetrics(officialName, repoWebsite, analyticsURL);
51
    }
52

  
53
    private void enableMetrics(String officialName, String repoWebsite, String analyticsURL) {
54
        String url;
55
        try {
56
            url = analyticsURL + "siteName=" + URLEncoder.encode(officialName, "UTF-8") + "&url="
57
                    + URLEncoder.encode(repoWebsite, "UTF-8");
58
            url = StringEscapeUtils.escapeJava(url);
59

  
60
            Map map = null;
61
            String siteId = null;
62

  
63
            URL u = new URL(url);
64
            map = new ObjectMapper().readValue(u, Map.class);
65
            if(map.get("value")!=null) {
66
                siteId = map.get("value").toString();
67
            }
68
        } catch (Exception e) {
69
            e.printStackTrace();
70
        }
71
    }
72
}*/
modules/uoa-repository-manager-service/branches/cris/src/test/java/unitest/ValidatorTest.java
1
//package unitest;
2
//
3
//import eu.dnetlib.repo.manager.config.RepoManagerContextLoaderListener;
4
//import eu.dnetlib.repo.manager.utils.OaiTools;
5
//import org.junit.Test;
6
//import org.junit.runner.RunWith;
7
//import org.springframework.test.context.ContextConfiguration;
8
//import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
9
//
10
//@RunWith(SpringJUnit4ClassRunner.class)
11
//@ContextConfiguration(classes = RepoManagerContextLoaderListener.class)
12
////@WebAppConfiguration
13
//public class ValidatorTest {
14
//
15
//
16
//    @Test
17
//    public void identiFy(){
18
//
19
//        String url = "https://repozitorij.srce.unizg.hr/oai";
20
//
21
//
22
//        System.out.println("Identify repository with url : " + url);
23
//        try {
24
//            System.out.println(OaiTools.identifyRepository(url));
25
//        } catch (Exception e) {
26
//            System.out.println(e);
27
//        }
28
//    }
29
//
30
//
31
//}
modules/uoa-repository-manager-service/branches/cris/src/test/resources/application-context.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<beans xmlns="http://www.springframework.org/schema/beans"
3
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
       xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
5
       xsi:schemaLocation="http://www.springframework.org/schema/beans
6
               http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
7

  
8

  
9
    <context:annotation-config/>
10
    <context:component-scan base-package="eu.dnetlib.repo.manager.service.*"/>
11
    <tx:annotation-driven transaction-manager="txManager"/>
12

  
13
    <bean class="eu.dnetlib.repo.manager.config.CascadingPropertyLoader"
14
          id="propertyLoader">
15
        <property name="order" value="2"/>
16
        <property name="properties">
17
            <bean class="eu.dnetlib.conf.WebappContextProperyFactory">
18
                <property name="propertyFetcher">
19
                    <bean class="eu.dnetlib.conf.PropertyFetcher"/>
20
                </property>
21
            </bean>
22
        </property>
23
        <property name="ignoreUnresolvablePlaceholders" value="true"/>
24
        <property name="locations">
25
            <list>
26
                <value>classpath*:/gr/**/springContext-*.properties</value>
27
                <value>classpath*:/eu/**/springContext-*.properties</value>
28

  
29
                <value>classpath*:/application.properties</value>
30
                <value>classpath*:/email-texts.properties</value>
31

  
32
<!--                <value>classpath*:dnet-site-wizard.properties</value>-->
33
<!--                <value>classpath*:dnet-site-override.properties</value>-->
34
<!--                <value>classpath*:dnet-wizard.properties</value>-->
35
<!--                <value>classpath*:dnet-override-new.properties</value>-->
36
<!--                <value>classpath*:dnet-validator-wizard.properties</value>-->
37
<!--                <value>classpath*:dnet-validator-override.properties</value>-->
38
<!--                <value>classpath*:dnet-site-force-override.properties</value>-->
39
<!--                <value>classpath*:dnet-force-override.properties</value>-->
40
            </list>
41
        </property>
42
    </bean>
43

  
44
    <bean id="repomanager.dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
45
        <property name="driverClassName" value="${repomanager.db.driverClassName}" />
46
        <property name="url" value="${repomanager.db.url}" />
47
        <property name="username" value="${repomanager.db.username}" />
48
        <property name="password" value="${repomanager.db.password}" />
49
        <property name="maxIdle" value="10" />
50
        <property name="maxActive" value="100" />
51
        <property name="maxWait" value="10000" />
52
        <property name="validationQuery" value="SELECT 1;" />
53
        <property name="testOnBorrow" value="true" />
54
        <property name="testOnReturn" value="true" />
55
        <property name="testWhileIdle" value="true" />
56
        <property name="timeBetweenEvictionRunsMillis" value="1200000" />
57
        <property name="minEvictableIdleTimeMillis" value="1800000" />
58
        <property name="numTestsPerEvictionRun" value="5" />
59
        <property name="poolPreparedStatements" value="true" />
60
        <property name="defaultAutoCommit" value="true" />
61
    </bean>
62

  
63
    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
64
        <property name="dataSource" ref="repomanager.dataSource"/>
65
    </bean>
66

  
67
</beans>
modules/uoa-repository-manager-service/branches/cris/src/test/resources/applicationContext.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<beans xmlns="http://www.springframework.org/schema/beans"
3
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
       xmlns:tx="http://www.springframework.org/schema/tx"
5
       xmlns:mvc="http://www.springframework.org/schema/mvc"
6
       xsi:schemaLocation="http://www.springframework.org/schema/beans
7

  
8
       http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
9
	http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
10
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
11

  
12
    <import resource="classpath*:/application-context.xml"/>
13

  
14
    <import resource="classpath*:/eu/dnetlib/soap/cxf/applicationContext-eprbuilders.xml"/>
15
    <import resource="classpath*:/eu/dnetlib/clients/ws/springContext-locatorFactory.xml"/>
16
    <import resource="classpath*:/gr/uoa/di/driver/util/springContext-locators.xml"/>
17
    <import resource="classpath*:/gr/uoa/di/driver/app/springContext-lookupFactory.xml"/>
18
    <import resource="classpath*:/gr/uoa/di/driver/app/springContext-lookupClients.xml"/>
19
    <import resource="classpath*:/eu/dnetlib/enabling/hcm/springContext-hcmService.xml"/>
20
    <import resource="classpath*:/gr/uoa/di/driver/app/springContext-commons.xml"/>
21

  
22
    <!--<import resource="classpath*:/gr/uoa/di/driver/app/springContext-registrator.xml"/>-->
23

  
24

  
25

  
26

  
27
    <bean id="maillib" class="eu.dnetlib.utils.MailLibrary" init-method="init">
28
        <property name="mailhost" value="${services.validator.mail.host}"/>
29
        <property name="smtpPort" value="${services.validator.mail.port}"/>
30
        <property name="authenticate" value="${services.validator.mail.authenticate}"/>
31
        <property name="username" value="${services.validator.mail.username}"/>
32
        <property name="password" value="${services.validator.mail.password}"/>
33
        <property name="from" value="${services.validator.mail.fromAddress}"/>
34
        <property name="replyTo" value="${services.validator.mail.replyToAddress}"/>
35
        <property name="mode" value="${services.validator.mail.mode}"/>
36
        <property name="debug" value="${services.validator.mail.debug}"/>
37
    </bean>
38

  
39
    <bean class="eu.dnetlib.repo.manager.config.CascadingPropertyLoader"
40
          id="propertyLoader">
41
        <property name="order" value="2"/>
42
        <property name="properties">
43
            <bean class="eu.dnetlib.conf.WebappContextProperyFactory">
44
                <property name="propertyFetcher">
45
                    <bean class="eu.dnetlib.conf.PropertyFetcher"/>
46
                </property>
47
            </bean>
48
        </property>
49
        <property name="ignoreUnresolvablePlaceholders" value="true"/>
50
        <property name="locations">
51
            <list>
52
                <value>classpath*:/gr/**/springContext-*.properties</value>
53
                <value>classpath*:/eu/**/springContext-*.properties</value>
54

  
55
                <value>classpath*:/application.properties</value>
56
                <value>classpath*:/email-texts.properties</value>
57

  
58
<!--                <value>classpath*:dnet-site-wizard.properties</value>-->
59
<!--                <value>classpath*:dnet-site-override.properties</value>-->
60
<!--                <value>classpath*:dnet-wizard.properties</value>-->
61
<!--                <value>classpath*:dnet-override-new.properties</value>-->
62
<!--                <value>classpath*:dnet-validator-wizard.properties</value>-->
63
<!--                <value>classpath*:dnet-validator-override.properties</value>-->
64
<!--                <value>classpath*:dnet-site-force-override.properties</value>-->
65
<!--                <value>classpath*:dnet-force-override.properties</value>-->
66
            </list>
67
        </property>
68
    </bean>
69

  
70
    <bean id="repomanager.dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
71
        <property name="driverClassName" value="${repomanager.db.driverClassName}" />
72
        <property name="url" value="${repomanager.db.url}" />
73
        <property name="username" value="${repomanager.db.username}" />
74
        <property name="password" value="${repomanager.db.password}" />
75
        <property name="maxIdle" value="10" />
76
        <property name="maxActive" value="100" />
77
        <property name="maxWait" value="10000" />
78
        <property name="validationQuery" value="SELECT 1;" />
79
        <property name="testOnBorrow" value="true" />
80
        <property name="testOnReturn" value="true" />
81
        <property name="testWhileIdle" value="true" />
82
        <property name="timeBetweenEvictionRunsMillis" value="1200000" />
83
        <property name="minEvictableIdleTimeMillis" value="1800000" />
84
        <property name="numTestsPerEvictionRun" value="5" />
85
        <property name="poolPreparedStatements" value="true" />
86
        <property name="defaultAutoCommit" value="true" />
87
    </bean>
88

  
89
    <tx:annotation-driven transaction-manager="txManager"/>
90

  
91
    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
92
        <property name="dataSource" ref="repomanager.dataSource"/>
93
    </bean>
94

  
95
    <mvc:resources mapping="swagger-ui.html" location="classpath:/META-INF/resources/"/>
96
    <mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>
97
    <bean class="eu.dnetlib.repo.manager.config.SwaggerConfig"/>
98

  
99
</beans>
modules/uoa-repository-manager-service/branches/cris/src/main/java/eu/dnetlib/repo/manager/service/UserService.java
1
package eu.dnetlib.repo.manager.service;
2

  
3
import org.springframework.http.ResponseEntity;
4

  
5

  
6
public interface UserService {
7

  
8
    ResponseEntity<Object> login();
9
}
modules/uoa-repository-manager-service/branches/cris/src/main/java/eu/dnetlib/repo/manager/service/RepositoryService.java
1
package eu.dnetlib.repo.manager.service;
2

  
3
import eu.dnetlib.api.functionality.ValidatorServiceException;
4
import eu.dnetlib.domain.data.Repository;
5
import eu.dnetlib.domain.data.RepositoryInterface;
6
import eu.dnetlib.repo.manager.domain.RepositorySnippet;
7
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
8
import eu.dnetlib.repo.manager.shared.*;
9
import org.json.JSONException;
10
import org.springframework.security.core.Authentication;
11
import java.io.IOException;
12
import java.util.List;
13
import java.util.Map;
14

  
15
public interface RepositoryService {
16

  
17

  
18
    Country[] getCountries() ;
19

  
20
    List<RepositorySnippet> getRepositoriesByCountry(String country, String mode, Boolean managed) throws JSONException, IOException;
21

  
22
    List<Repository> getRepositoriesOfUser(String userEmail,
23
                                           String page,
24
                                           String size) throws JSONException;
25

  
26
    Repository getRepositoryById(String id) throws JSONException, ResourceNotFoundException;
27

  
28
    List<AggregationDetails> getRepositoryAggregations(String id, int from, int size) throws JSONException;
29

  
30
    Map<String,List<AggregationDetails>> getRepositoryAggregationsByYear(String id) throws JSONException;
31

  
32
    List<Repository> getRepositoriesByName(String name,
33
                                           String page,
34
                                           String size) throws JSONException;
35

  
36
    List<RepositorySnippet> searchRegisteredRepositories(String country, String typology, String englishName,
37
                                                                String officialName, String requestSortBy, String order,
38
                                                                int page, int pageSize) throws Exception;
39

  
40
    List<RepositoryInterface> getRepositoryInterface(String id) throws JSONException;
41

  
42
    Repository addRepository(String datatype, Repository repository) throws Exception;
43

  
44
    void deleteRepositoryInterface(String id, String registeredBy);
45

  
46
    RepositoryInterface addRepositoryInterface(String datatype,
47
                                               String repoId,
48
                                               String registeredBy,
49
                                               RepositoryInterface iFace) throws JSONException, ResourceNotFoundException, ValidatorServiceException;
50

  
51
    List<String> getDnetCountries();
52

  
53
    List<String> getTypologies();
54

  
55
    List<Timezone> getTimezones();
56

  
57
    Repository updateRepository(Repository repository, Authentication authentication) throws Exception;
58

  
59
    List<String> getUrlsOfUserRepos(String user_email,
60
                                    String page,
61
                                    String size) throws JSONException;
62

  
63
    List<String> getDatasourceVocabularies(String mode);
64

  
65
    Map<String, String> getCompatibilityClasses(String mode);
66

  
67
    Map<String, String> getDatasourceClasses(String mode);
68

  
69
    String getCountryName(String countryCode);
70

  
71
    MetricsInfo getMetricsInfoForRepository(String repoId) throws RepositoryServiceException;
72

  
73
    Map<String, String> getListLatestUpdate(String mode) throws RepositoryServiceException, JSONException;
74

  
75
    RepositoryInterface updateRepositoryInterface(String repositoryId, String registeredBy, RepositoryInterface repositoryInterface) throws Exception;
76

  
77
}
modules/uoa-repository-manager-service/branches/cris/src/main/java/eu/dnetlib/repo/manager/service/StatsServiceImpl.java
1
package eu.dnetlib.repo.manager.service;
2

  
3
import eu.dnetlib.repo.manager.service.customHystrixCommands.*;
4
import org.springframework.beans.factory.annotation.Autowired;
5
import org.springframework.beans.factory.annotation.Value;
6
import org.springframework.stereotype.Service;
7
import org.springframework.web.client.RestTemplate;
8

  
9
import java.util.HashMap;
10
import java.util.Map;
11

  
12
@Service("statsService")
13
public class StatsServiceImpl implements StatsService {
14

  
15
    @Autowired
16
    RestTemplate restTemplate;
17

  
18
    @Value("${search.api.baseAddress}")
19
    private String baseAddress;
20
    @Value("${search.api.usagestats}")
21
    private String usagestatsBaseAddress;
22
    @Value("${search.api.usageEvents}")
23
    private String usagestatsEvents;
24

  
25
    @Override
26
    public Map getStatistics()  {
27

  
28
        UsageStatsTotalHystrixCommand usageStatsTotalHystrixCommand = new UsageStatsTotalHystrixCommand(usagestatsEvents,restTemplate);
29
        DataRepositoriesHystrixCommand dataRepositoriesHystrixCommand = new DataRepositoriesHystrixCommand(baseAddress,restTemplate);
30
        AggregatorsHystrixCommand aggregatorsHystrixCommand = new AggregatorsHystrixCommand(baseAddress,restTemplate);
31
        LiteratureHystrixCommand literatureHystrixCommand = new LiteratureHystrixCommand(baseAddress,restTemplate);
32
        JournalHystrixCommand journalHystrixCommand = new JournalHystrixCommand(baseAddress,restTemplate);
33
        PublicationHystrixCommand publicationHystrixCommand = new PublicationHystrixCommand(baseAddress,restTemplate);
34
        DatasetsHystrixCommand datasetsHystrixCommand = new DatasetsHystrixCommand(baseAddress,restTemplate);
35
        SoftwareHystrixCommand softwareHystrixCommand = new SoftwareHystrixCommand(baseAddress,restTemplate);
36
        LastYearUsageStatsHystrixCommand lastYearUsageStatsHystrixCommand = new LastYearUsageStatsHystrixCommand(usagestatsBaseAddress,restTemplate);
37

  
38
        Map<String,Object> stats = new HashMap<>();
39
        stats.put("aggregators",aggregatorsHystrixCommand.execute());
40
        stats.put("dataRepositories",dataRepositoriesHystrixCommand.execute());
41
        stats.put("literature",literatureHystrixCommand.execute());
42
        stats.put("journal",journalHystrixCommand.execute());
43
        stats.put("publications",publicationHystrixCommand.execute());
44
        stats.put("datasets",datasetsHystrixCommand.execute());
45
        stats.put("software",softwareHystrixCommand.execute());
46
        stats.put("lastYearUsagestats", lastYearUsageStatsHystrixCommand.execute());
47
        stats.put("usagestats",usageStatsTotalHystrixCommand.execute());
48
        return stats;
49
    }
50
}
modules/uoa-repository-manager-service/branches/cris/src/main/java/eu/dnetlib/repo/manager/service/PiWikService.java
1
package eu.dnetlib.repo.manager.service;
2

  
3

  
4
import eu.dnetlib.domain.data.PiwikInfo;
5
import eu.dnetlib.repo.manager.domain.OrderByField;
6
import eu.dnetlib.repo.manager.domain.OrderByType;
7
import eu.dnetlib.repo.manager.shared.RepositoryServiceException;
8
import org.springframework.http.ResponseEntity;
9

  
10
import java.util.List;
11

  
12

  
13
public interface PiWikService {
14

  
15
    PiwikInfo getPiwikSiteForRepo(String repositoryId);
16

  
17
    PiwikInfo savePiwikInfo(PiwikInfo piwikInfo);
18

  
19
    List<PiwikInfo> getPiwikSitesForRepos(OrderByField orderByField, OrderByType orderByType, int from, int quantity, String searchField);
20

  
21
    int getPiwikSitesTotals(String searchField);
22

  
23
    ResponseEntity<Object> approvePiwikSite(String repositoryId);
24

  
25
    String getOpenaireId(String repositoryid);
26

  
27
    ResponseEntity<Object> markPiwikSiteAsValidated(String repositoryId) throws RepositoryServiceException;
28

  
29
    PiwikInfo enableMetricsForRepository(String officialName, String repoWebsite, PiwikInfo piwikInfo) throws RepositoryServiceException;
30
}
modules/uoa-repository-manager-service/branches/cris/src/main/java/eu/dnetlib/repo/manager/service/BrokerService.java
1
package eu.dnetlib.repo.manager.service;
2

  
3
import eu.dnetlib.repo.manager.shared.BrokerException;
4
import eu.dnetlib.repo.manager.shared.Term;
5
import eu.dnetlib.repo.manager.shared.broker.*;
6
import io.swagger.annotations.Api;
7
import org.json.JSONException;
8
import org.springframework.http.MediaType;
9
import org.springframework.http.ResponseEntity;
10
import org.springframework.web.bind.annotation.RequestMapping;
11
import org.springframework.web.bind.annotation.RequestMethod;
12
import org.springframework.web.bind.annotation.ResponseBody;
13
import org.springframework.web.bind.annotation.RestController;
14

  
15
import java.io.IOException;
16
import java.util.List;
17
import java.util.Map;
18

  
19

  
20
public interface BrokerService {
21

  
22
    DatasourcesBroker getDatasourcesOfUser(String user, String includeShared, String includeByOthers) throws BrokerException, JSONException;
23

  
24
    List<BrowseEntry> getTopicsForDatasource(String datasourceName) throws BrokerException;
25

  
26
    EventsPage advancedShowEvents(String page,
27
                                  String size,
28
                                  AdvQueryObject advQueryObject) throws BrokerException, JSONException ,IOException;
29

  
30
    EventsPage showEvents(String datasourceName,
31
                          String topic,
32
                          String page,
33
                          String size) throws BrokerException, JSONException;
34

  
35
    Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser(String userEmail) throws BrokerException;
36

  
37
    Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUserByRepoId(String userEmail, String repoId) throws BrokerException;
38

  
39
    Subscription subscribe(OpenaireSubscription obj) throws BrokerException;
40

  
41
    ResponseEntity<Object> unsubscribe(String subscriptionId) throws BrokerException;
42

  
43
    Subscription getSubscription(String subscriptionId) throws BrokerException;
44

  
45
    Map<String, Term> getDnetTopics() throws BrokerException;
46

  
47
    EventsPage getNotificationsBySubscriptionId(String subscriptionId, String page, String size) throws BrokerException;
48

  
49
    Map<String, List<Subscription>> getSubscriptionsOfUser(String userEmail) throws BrokerException;
50
}
modules/uoa-repository-manager-service/branches/cris/src/main/java/eu/dnetlib/repo/manager/service/ValidatorService.java
1
package eu.dnetlib.repo.manager.service;
2

  
3
import eu.dnetlib.api.functionality.ValidatorServiceException;
4
import eu.dnetlib.domain.functionality.validator.JobForValidation;
5
import eu.dnetlib.domain.functionality.validator.JobResultEntry;
6
import eu.dnetlib.domain.functionality.validator.RuleSet;
7
import eu.dnetlib.domain.functionality.validator.StoredJob;
8
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
9
import eu.dnetlib.repo.manager.shared.InterfaceInformation;
10
import eu.dnetlib.repo.manager.shared.ValidationServiceException;
11
import org.json.JSONException;
12
import org.springframework.http.ResponseEntity;
13

  
14
import java.util.List;
15

  
16

  
17

  
18
public interface ValidatorService {
19

  
20

  
21
    JobForValidation submitJobForValidation(JobForValidation jobForValidation) throws ValidatorServiceException;
22

  
23
    ResponseEntity<Object> reSubmitJobForValidation(String email, String jobId) throws JSONException, ValidatorServiceException;
24

  
25
    List<RuleSet> getRuleSets(String mode);
26

  
27
    List<String> getSetsOfRepository(String url);
28

  
29
    boolean identifyRepo(String url);
30

  
31
    RuleSet getRuleSet(String acronym);
32

  
33
    List<StoredJob> getStoredJobsNew(String user,
34
                                     String jobType,
35
                                     String offset,
36
                                     String limit,
37
                                     String dateFrom,
38
                                     String dateTo,
39
                                     String validationStatus) throws ValidatorServiceException;
40

  
41
    int getStoredJobsTotalNumberNew(String user, String jobType, String validationStatus) throws ValidatorServiceException;
42

  
43
    InterfaceInformation getInterfaceInformation(String baseUrl) throws ValidationServiceException;
44

  
45
    List<StoredJob> getJobsSummary(String repoId, int limit) throws ValidatorServiceException, ResourceNotFoundException, JSONException;
46
}
modules/uoa-repository-manager-service/branches/cris/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/AggregatorsHystrixCommand.java
1
package eu.dnetlib.repo.manager.service.customHystrixCommands;
2

  
3
import com.netflix.hystrix.HystrixCommand;
4
import com.netflix.hystrix.HystrixCommandGroupKey;
5
import org.springframework.http.HttpMethod;
6
import org.springframework.http.ResponseEntity;
7
import org.springframework.web.client.RestTemplate;
8
import org.springframework.web.util.UriComponents;
9
import org.springframework.web.util.UriComponentsBuilder;
10

  
11
import java.util.Map;
12

  
13
public class AggregatorsHystrixCommand extends HystrixCommand<String> {
14

  
15
    RestTemplate restTemplate;
16
    String baseAddress;
17

  
18
    public AggregatorsHystrixCommand(String baseAddress, RestTemplate restTemplate) {
19
        super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
20
        this.baseAddress = baseAddress;
21
        this.restTemplate = restTemplate;
22
    }
23

  
24
    @Override
25
    protected String run() throws Exception {
26
        String url = baseAddress + "/resources" +
27
                "?query= " +
28
                " oaftype exact datasource and " +
29
                " ( datasourcetypename exact Institutional Repository Aggregator " +
30
                "     or datasourcetypename exact Publication Repository Aggregator )";
31

  
32
        UriComponents uriComponents = UriComponentsBuilder
33
                .fromHttpUrl(url)
34
                .queryParam("page", 0)
35
                .queryParam("size", 0)
36
                .queryParam("format", "json")
37
                .build().encode();
38

  
39
        ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
40
        Map metadata = (Map) ((Map) rs.getBody()).get("meta");
41
        return String.valueOf(metadata.get("total"));
42
    }
43

  
44
    @Override
45
    protected String getFallback() {
46
        return null;
47
    }
48
}
modules/uoa-repository-manager-service/branches/cris/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/UsageStatsTotalHystrixCommand.java
1
package eu.dnetlib.repo.manager.service.customHystrixCommands;
2

  
3
import com.netflix.hystrix.HystrixCommand;
4
import com.netflix.hystrix.HystrixCommandGroupKey;
5
import org.springframework.http.HttpMethod;
6
import org.springframework.http.ResponseEntity;
7
import org.springframework.web.client.RestTemplate;
8
import org.springframework.web.util.UriComponents;
9
import org.springframework.web.util.UriComponentsBuilder;
10

  
11
import java.util.Map;
12

  
13
public class UsageStatsTotalHystrixCommand extends HystrixCommand<Integer> {
14

  
15
    RestTemplate restTemplate ;
16
    String usagestatsEvents;
17

  
18
    public UsageStatsTotalHystrixCommand(String usagestatsEvents,RestTemplate restTemplate) {
19
        super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
20
        this.usagestatsEvents = usagestatsEvents;
21
        this.restTemplate = restTemplate;
22
    }
23

  
24
    @Override
25
    protected Integer run() {
26
        UriComponents uriComponents = UriComponentsBuilder
27
                .fromHttpUrl(usagestatsEvents)
28
                .build().encode();
29

  
30
        ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET,null,Map.class);
31
        Map metadata = (Map) ((Map)rs.getBody()).get("totals");
32
//        String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
33
//        JSONObject resultSet = new JSONObject(rs);
34
//        JSONObject totals = resultSet.getJSONObject("totals");
35
        return (Integer) metadata.get("events");
36
    }
37

  
38
    @Override
39
    protected Integer getFallback() {
40
        return null;
41
    }
42

  
43
}
modules/uoa-repository-manager-service/branches/cris/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/DatasetsHystrixCommand.java
1
package eu.dnetlib.repo.manager.service.customHystrixCommands;
2

  
3
import com.netflix.hystrix.HystrixCommand;
4
import com.netflix.hystrix.HystrixCommandGroupKey;
5
import org.springframework.http.HttpMethod;
6
import org.springframework.http.ResponseEntity;
7
import org.springframework.web.client.RestTemplate;
8
import org.springframework.web.util.UriComponents;
9
import org.springframework.web.util.UriComponentsBuilder;
10

  
11
import java.util.Map;
12

  
13
public class DatasetsHystrixCommand extends HystrixCommand<String> {
14

  
15
    RestTemplate restTemplate;
16
    String baseAddress;
17

  
18
    public DatasetsHystrixCommand(String baseAddress,RestTemplate restTemplate) {
19
        super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
20
        this.restTemplate = restTemplate;
21
        this.baseAddress = baseAddress;
22
    }
23

  
24
    @Override
25
    protected String run() throws Exception {
26
        String url = baseAddress+"/datasets/count";
27

  
28
        UriComponents uriComponents = UriComponentsBuilder
29
                .fromHttpUrl(url)
30
                .queryParam("page", 0)
31
                .queryParam("size", 0)
32
                .queryParam("format", "json")
33
                .build().encode();
34

  
35
        ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
36
        Map metadata = (Map) (rs.getBody());
37
        return String.valueOf(metadata.get("total"));
38
    }
39

  
40
    @Override
41
    protected String getFallback() {
42
        return null;
43
    }
44
}
modules/uoa-repository-manager-service/branches/cris/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/LastYearUsageStatsHystrixCommand.java
1
package eu.dnetlib.repo.manager.service.customHystrixCommands;
2

  
3
import com.netflix.hystrix.HystrixCommand;
4
import com.netflix.hystrix.HystrixCommandGroupKey;
5
import org.springframework.http.HttpMethod;
6
import org.springframework.http.ResponseEntity;
7
import org.springframework.web.client.RestTemplate;
8
import org.springframework.web.util.UriComponents;
9
import org.springframework.web.util.UriComponentsBuilder;
10

  
11
import java.util.HashMap;
12
import java.util.List;
13
import java.util.Map;
14

  
15
public class LastYearUsageStatsHystrixCommand extends HystrixCommand<Map> {
16

  
17
    RestTemplate restTemplate;
18
    String usagestatsBaseAddress;
19

  
20
    public LastYearUsageStatsHystrixCommand(String usagestatsBaseAddress,RestTemplate restTemplate) {
21
        super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
22
        this.usagestatsBaseAddress = usagestatsBaseAddress;
23
        this.restTemplate = restTemplate;
24
    }
25

  
26
    @Override
27
    protected Map run() throws Exception {
28
        UriComponents uriComponents = UriComponentsBuilder
29
                .fromHttpUrl(usagestatsBaseAddress + "/totals")
30
                .build().encode();
31

  
32
        ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET,null,Map.class);
33

  
34
        List yearly_stats = (List) ((Map)rs.getBody()).get("yearly_stats");
35
        Map lastYear = (Map) yearly_stats.get(yearly_stats.size()-1);
36
        Integer downloads = (Integer) lastYear.get("downloads");
37
        Integer views = (Integer) lastYear.get("views");
38
        Integer year = (Integer) lastYear.get("year");
39

  
40
        Map<String,Object> usagestats = new HashMap<>();
41
        usagestats.put("number",String.valueOf(downloads+views));
42
        usagestats.put("year",year);
43

  
44
        return usagestats;
45
    }
46

  
47
    @Override
48
    protected Map getFallback() {
49
        return null;
50
    }
51

  
52
}
modules/uoa-repository-manager-service/branches/cris/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/PublicationHystrixCommand.java
1
package eu.dnetlib.repo.manager.service.customHystrixCommands;
2

  
3
import com.netflix.hystrix.HystrixCommand;
4
import com.netflix.hystrix.HystrixCommandGroupKey;
5
import org.springframework.http.HttpMethod;
6
import org.springframework.http.ResponseEntity;
7
import org.springframework.web.client.RestTemplate;
8
import org.springframework.web.util.UriComponents;
9
import org.springframework.web.util.UriComponentsBuilder;
10

  
11
import java.util.Map;
12

  
13
public class PublicationHystrixCommand extends HystrixCommand<String> {
14

  
15
    RestTemplate restTemplate;
16
    private String baseAddress;
17

  
18
    public PublicationHystrixCommand(String baseAddress, RestTemplate restTemplate) {
19
        super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
20
        this.baseAddress = baseAddress;
21
        this.restTemplate = restTemplate;
22
    }
23

  
24
    @Override
25
    protected String run() throws Exception {
26
        String url = baseAddress + "/publications/count";
27

  
28
        UriComponents uriComponents = UriComponentsBuilder
29
                .fromHttpUrl(url)
30
                .queryParam("page", 0)
31
                .queryParam("size", 0)
32
                .queryParam("format", "json")
33
                .build().encode();
34

  
35
        ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
36
        Map metadata = (Map) (rs.getBody());
37
        return String.valueOf(metadata.get("total"));
38
    }
39

  
40
    @Override
41
    protected String getFallback() {
42
        return null;
43
    }
44

  
45
}
modules/uoa-repository-manager-service/branches/cris/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/JournalHystrixCommand.java
1
package eu.dnetlib.repo.manager.service.customHystrixCommands;
2

  
3
import com.netflix.hystrix.HystrixCommand;
4
import com.netflix.hystrix.HystrixCommandGroupKey;
5
import org.springframework.http.HttpMethod;
6
import org.springframework.http.ResponseEntity;
7
import org.springframework.web.client.RestTemplate;
8
import org.springframework.web.util.UriComponents;
9
import org.springframework.web.util.UriComponentsBuilder;
10

  
11
import java.util.Map;
12

  
13
public class JournalHystrixCommand extends HystrixCommand<String> {
14

  
15
    RestTemplate restTemplate;
16
    private String baseAddress;
17

  
18
    public JournalHystrixCommand(String baseAddress, RestTemplate restTemplate) {
19
        super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
20
        this.baseAddress = baseAddress;
21
        this.restTemplate = restTemplate;
22
    }
23

  
24
    @Override
25
    protected String run() throws Exception {
26
        String url = baseAddress+"/resources"+
27
                "?query= " +
28
                " oaftype exact datasource and " +
29
                " datasourcetypename exact Journal";
30

  
31
        UriComponents uriComponents = UriComponentsBuilder
32
                .fromHttpUrl(url)
33
                .queryParam("page", 0)
34
                .queryParam("size", 0)
35
                .queryParam("format", "json")
36
                .build().encode();
37

  
38
        ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
39
        Map metadata = (Map) ((Map) rs.getBody()).get("meta");
40
        return String.valueOf(metadata.get("total"));
41
    }
42

  
43
    @Override
44
    protected String getFallback() {
45
        return null;
46
    }
47

  
48
}
modules/uoa-repository-manager-service/branches/cris/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/SoftwareHystrixCommand.java
1
package eu.dnetlib.repo.manager.service.customHystrixCommands;
2

  
3
import com.netflix.hystrix.HystrixCommand;
4
import com.netflix.hystrix.HystrixCommandGroupKey;
5
import org.springframework.http.HttpMethod;
6
import org.springframework.http.ResponseEntity;
7
import org.springframework.web.client.RestTemplate;
8
import org.springframework.web.util.UriComponents;
9
import org.springframework.web.util.UriComponentsBuilder;
10

  
11
import java.util.Map;
12

  
13
public class SoftwareHystrixCommand extends HystrixCommand<String> {
14

  
15
    String baseAddress;
16
    RestTemplate restTemplate;
17

  
18
    public SoftwareHystrixCommand(String baseAddress, RestTemplate restTemplate) {
19
        super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
20
        this.baseAddress = baseAddress;
21
        this.restTemplate = restTemplate;
22
    }
23

  
24
    @Override
25
    protected String run() {
26
        String url = baseAddress + "/software/count";
27

  
28
        UriComponents uriComponents = UriComponentsBuilder
29
                .fromHttpUrl(url)
30
                .queryParam("page", 0)
31
                .queryParam("size", 0)
32
                .queryParam("format", "json")
33
                .build().encode();
34

  
35
        ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
36
        Map metadata = (Map) (rs.getBody());
37
        return String.valueOf(metadata.get("total"));
38
    }
39

  
40
    @Override
41
    protected String getFallback() {
42
        return null;
43
    }
44
}
modules/uoa-repository-manager-service/branches/cris/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/LiteratureHystrixCommand.java
1
package eu.dnetlib.repo.manager.service.customHystrixCommands;
2

  
3
import com.netflix.hystrix.HystrixCommand;
4
import com.netflix.hystrix.HystrixCommandGroupKey;
5
import org.springframework.http.HttpMethod;
6
import org.springframework.http.ResponseEntity;
7
import org.springframework.web.client.RestTemplate;
8
import org.springframework.web.util.UriComponents;
9
import org.springframework.web.util.UriComponentsBuilder;
10

  
11
import java.util.Map;
12

  
13
public class LiteratureHystrixCommand extends HystrixCommand<String> {
14

  
15
    RestTemplate restTemplate;
16
    private String baseAddress;
17

  
18
    public LiteratureHystrixCommand(String baseAddress , RestTemplate restTemplate) {
19
        super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
20
        this.baseAddress = baseAddress;
21
        this.restTemplate = restTemplate;
22
    }
23

  
24
    @Override
25
    protected String run() throws Exception {
26
        String url = baseAddress+"/resources"+
27
                "?query= " +
28
                " oaftype exact datasource and " +
29
                " ( datasourcetypename exact Institutional Repository  " +
30
                "     or datasourcetypename exact Publication Repository )";
31

  
32
        UriComponents uriComponents = UriComponentsBuilder
33
                .fromHttpUrl(url)
34
                .queryParam("page", 0)
35
                .queryParam("size", 0)
36
                .queryParam("format", "json")
37
                .build().encode();
38

  
39
        ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class);
40
        Map metadata = (Map) ((Map) rs.getBody()).get("meta");
41
        return String.valueOf(metadata.get("total"));
42
    }
43

  
44
    @Override
45
    protected String getFallback() {
46
        return null;
47
    }
48

  
49
}
modules/uoa-repository-manager-service/branches/cris/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/DataRepositoriesHystrixCommand.java
1
package eu.dnetlib.repo.manager.service.customHystrixCommands;
2

  
3
import com.netflix.hystrix.HystrixCommand;
4
import com.netflix.hystrix.HystrixCommandGroupKey;
5
import org.springframework.http.HttpMethod;
6
import org.springframework.http.ResponseEntity;
7
import org.springframework.web.client.RestTemplate;
8
import org.springframework.web.util.UriComponents;
9
import org.springframework.web.util.UriComponentsBuilder;
10

  
11
import java.util.Map;
12

  
13
public class DataRepositoriesHystrixCommand extends HystrixCommand<String> {
14

  
15
    RestTemplate restTemplate ;
16
    private String baseAddress;
17

  
18
    public DataRepositoriesHystrixCommand(String baseAddress,RestTemplate restTemplate) {
19
        super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup"));
20
        this.baseAddress = baseAddress;
21
        this.restTemplate = restTemplate;
22
    }
23

  
24
    @Override
25
    protected String run() {
26
        String url = baseAddress+"/resources" +
27
                "?query= " +
28
                " oaftype exact datasource and " +
29
                " datasourcetypename exact Data Repository ";
30

  
31
        UriComponents uriComponents = UriComponentsBuilder
32
                .fromHttpUrl(url)
33
                .queryParam("page",0)
34
                .queryParam("size",0)
35
                .queryParam("format","json")
36
                .build().encode();
37

  
38
        ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET,null,Map.class);
39
        Map metadata = (Map) ((Map)rs.getBody()).get("meta");
40
        return String.valueOf(metadata.get("total"));
41
    }
42

  
43
    @Override
44
    protected String getFallback() {
45
        return null;
46
    }
47
}
modules/uoa-repository-manager-service/branches/cris/src/main/java/eu/dnetlib/repo/manager/service/MonitorService.java
1
package eu.dnetlib.repo.manager.service;
2

  
3
import eu.dnetlib.api.functionality.ValidatorServiceException;
4
import eu.dnetlib.domain.functionality.validator.StoredJob;
5
import eu.dnetlib.repo.manager.shared.JobsOfUser;
6
import io.swagger.annotations.Api;
7
import org.json.JSONException;
8
import org.springframework.http.MediaType;
9
import org.springframework.web.bind.annotation.*;
10

  
11

  
12
public interface MonitorService {
13

  
14

  
15
    JobsOfUser getJobsOfUser(String user,
16
                             String jobType,
17
                             String offset,
18
                             String limit,
19
                             String dateFrom,
20
                             String dateTo,
21
                             String validationStatus,
22
                             String includeJobsTotal) throws JSONException, ValidatorServiceException;
23

  
24
    int getJobsOfUserPerValidationStatus(String user,
25
                                         String jobType,
26
                                         String validationStatus) throws JSONException;
27

  
28

  
29
    StoredJob getJobSummary(String jobId,
30
                            String groupBy) throws JSONException;
31

  
32
}
modules/uoa-repository-manager-service/branches/cris/src/main/java/eu/dnetlib/repo/manager/service/EmailUtils.java
1
package eu.dnetlib.repo.manager.service;
2

  
3
import eu.dnetlib.domain.data.PiwikInfo;
4
import eu.dnetlib.domain.data.Repository;
5
import eu.dnetlib.domain.data.RepositoryInterface;
6
import eu.dnetlib.domain.functionality.validator.JobForValidation;
7
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
8
import eu.dnetlib.repo.manager.shared.ValidationServiceException;
9
import org.json.JSONException;
10
import org.springframework.security.core.Authentication;
11

  
12
public interface EmailUtils {
13

  
14

  
15
    void reportException(Exception exception);
16

  
17
    void sendAdministratorRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception;
18

  
19
    void sendUserRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception;
20

  
21
    void sendAdministratorMetricsEnabled(PiwikInfo piwikInfo) throws Exception;
22

  
23
    void sendUserMetricsEnabled(PiwikInfo piwikInfo) throws Exception;
24

  
25
    /****USER REGISTRATION REQUEST EMAILS****/
26
    void sendAdminRegistrationEmail(Repository repository, Authentication authentication) throws Exception;
27

  
28
    void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception;
29

  
30
    /****SUCCESSFUL REGISTRATION RESULTS EMAILS****/
31
    void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
32

  
33
    void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
34

  
35
    /****FAILURE REGISTRATION RESULTS EMAILS****/
36
    void sendUserRegistrationResultsFailureEmail(String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
37

  
38
    void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
39

  
40
    /****SUCCESSFUL UPDATE RESULTS EMAILS****/
41
    void sendUserUpdateResultsSuccessEmail(String issuer, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
42

  
43
    void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
44

  
45
    /****FAILURE UPDATE RESULTS EMAILS****/
46
    void sendUserUpdateResultsFailureEmail(String issuer, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
47

  
48
    void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
49

  
50
    /****VALIDATION OF CONTENT PROVIDER EMAILS****/
51
    void sendUserValidationResults(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
52

  
53
    void sendAdminValidationResults(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
54

  
55
    /****GENERAL FAILURE OF VALIDATOR****/
56
    void sendAdminGeneralFailure(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
57

  
58

  
59
    void sendAdminUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception;
60

  
61
    void sendUserUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception;
62

  
63
    void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation) throws Exception;
64

  
65
    void sendUponJobCompletion(String repoId,
66
                               String repoInterfaceId,
67
                               int scoreUsage,
68
                               int scoreContent,
69
                               boolean isSuccess,
70
                               boolean isUpdate,
71
                               String issuerEmail,
72
                               String jobId) throws Exception;
73
}
modules/uoa-repository-manager-service/branches/cris/src/main/java/eu/dnetlib/repo/manager/service/DashboardService.java
1
package eu.dnetlib.repo.manager.service;
2

  
3
import eu.dnetlib.repo.manager.domain.RepositorySummaryInfo;
4
import org.json.JSONException;
5
import org.springframework.web.bind.annotation.PathVariable;
6

  
7
import java.util.List;
8

  
9
public interface DashboardService {
10

  
11
    List<RepositorySummaryInfo> getRepositoriesSummaryInfo(@PathVariable("userEmail") String userEmail,
12
                                                           @PathVariable("page") String page,
13
                                                           @PathVariable("size") String size) throws JSONException;
14
}
modules/uoa-repository-manager-service/branches/cris/src/main/java/eu/dnetlib/repo/manager/service/SushiliteServiceImpl.java
1
package eu.dnetlib.repo.manager.service;
2

  
3
import eu.dnetlib.usagestats.sushilite.domain.ReportItem;
4
import eu.dnetlib.usagestats.sushilite.domain.ReportResponseWrapper;
5
import org.springframework.beans.factory.annotation.Autowired;
6
import org.springframework.beans.factory.annotation.Value;
7
import org.springframework.core.ParameterizedTypeReference;
8
import org.springframework.http.HttpMethod;
9
import org.springframework.http.ResponseEntity;
10
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
11
import org.springframework.security.access.prepost.PreAuthorize;
12
import org.springframework.stereotype.Service;
13
import org.springframework.web.bind.annotation.PathVariable;
14
import org.springframework.web.bind.annotation.RequestParam;
15
import org.springframework.web.client.RestClientException;
16
import org.springframework.web.client.RestTemplate;
17
import org.springframework.web.util.UriComponentsBuilder;
18

  
19
import java.util.ArrayList;
20
import java.util.List;
21

  
22
@Service("sushiliteService")
23
public class SushiliteServiceImpl implements SushiliteService {
24

  
25

  
26
    @Value("${services.repomanager.usagestats.sushiliteEndpoint}")
27
    private String usagestatsSushiliteEndpoint;
28

  
29
    @Autowired
30
    private EmailUtils emailUtils;
31

  
32
    private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger.getLogger(SushiliteServiceImpl.class);
33

  
34

  
35
    @Override
36
    @PreAuthorize("hasRole('ROLE_USER')")
37
    public ReportResponseWrapper getReportResults(String page,
38
                                                  String pageSize,
39
                                                  String Report,
40
                                                  String Release,
41
                                                  String RequestorID,
42
                                                  String BeginDate,
43
                                                  String EndDate,
44
                                                  String RepositoryIdentifier,
45
                                                  String ItemIdentifier,
46
                                                  String ItemDataType,
47
                                                  String Granularity,
48
                                                  String Pretty) {
49

  
50
            //build the uri params
51
            UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(this.usagestatsSushiliteEndpoint + "GetReport/")
52
                                                                .queryParam("Report", Report)
53
                                                                .queryParam("Release", Release)
54
                                                                .queryParam("RequestorID", RequestorID)
55
                                                                .queryParam("BeginDate", BeginDate)
56
                                                                .queryParam("EndDate", EndDate)
57
                                                                .queryParam("RepositoryIdentifier", RepositoryIdentifier)
58
                                                                .queryParam("ItemIdentifier", ItemIdentifier)
59
                                                                .queryParam("ItemDataType", ItemDataType)
60
                                                                .queryParam("Granularity", Granularity)
61
                                                                .queryParam("Pretty", Pretty);
62

  
63
            //create new template engine
64
            RestTemplate template = new RestTemplate();
65
            template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
66

  
67
            ResponseEntity<ReportResponseWrapper> resp;
68
            try {
69
                //communicate with endpoint
70
                resp = template.exchange(
71
                        builder.build().encode().toUri(),
72
                        HttpMethod.GET,
73
                        null,
74
                        new ParameterizedTypeReference<ReportResponseWrapper>() {
75
                        });
76
            } catch (RestClientException e) {
77
                LOGGER.debug("Exception on getReportResults" , e);
78
                emailUtils.reportException(e);
79
                throw e;
80
            }
81

  
82
            // check remote api's response
83
            System.out.println("sushi responded status " + resp.getStatusCode());
84

  
85
            // get the items corresponding to the requested page
86
            List<ReportItem> requestedItemList = new ArrayList<>();
87
            if (resp.getBody().getReportResponse().getReportWrapper().getReport().getCustomer().getReportItems() != null) {
88
                try {
89
                    int totalItems = resp.getBody().getReportResponse().getReportWrapper().getReport().getCustomer().getReportItems().size();
90
                    int size = Integer.parseInt(pageSize);
91
                    int offset = Integer.parseInt(page)*size;
92

  
93
                    if (offset < totalItems ) {
94
                        int upperIndex = offset+size;
95
                        if (upperIndex > totalItems) {
96
                            upperIndex = totalItems;
97
                        }
98
                        requestedItemList = resp.getBody().getReportResponse().getReportWrapper().getReport().getCustomer().getReportItems().subList(offset,upperIndex);
99
                    }
100

  
101
                } catch (NumberFormatException e) {
102
                    LOGGER.debug("Exception on getReportResults - trying to cast strings to integers", e);
103
                    //emailUtils.reportException(e);
104
                    throw e;
105
                }
106

  
107
            }
108

  
109
            ReportResponseWrapper newReportResponse = resp.getBody();
110
            newReportResponse.getReportResponse().getReportWrapper().getReport().getCustomer().setReportItems(requestedItemList);
111

  
112

  
113
            return newReportResponse;
114
    }
115

  
116
}
modules/uoa-repository-manager-service/branches/cris/src/main/java/eu/dnetlib/repo/manager/service/StatsService.java
1
package eu.dnetlib.repo.manager.service;
2

  
3
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
4
import eu.dnetlib.repo.manager.exception.EndPointException;
5
import org.json.JSONException;
6

  
7
import java.util.Map;
8

  
9

  
10
public interface StatsService {
11

  
12
    Map getStatistics() ;
13
}
modules/uoa-repository-manager-service/branches/cris/src/main/java/eu/dnetlib/repo/manager/service/UserServiceImpl.java
1
package eu.dnetlib.repo.manager.service;
2

  
3
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
4
import org.springframework.beans.factory.annotation.Value;
5
import org.springframework.http.HttpStatus;
6
import org.springframework.http.ResponseEntity;
7
import org.springframework.security.core.GrantedAuthority;
8
import org.springframework.security.core.context.SecurityContextHolder;
9
import org.springframework.stereotype.Service;
10

  
11
import java.util.HashMap;
12
import java.util.List;
13
import java.util.Map;
14
import java.util.stream.Collectors;
15

  
16
@Service("userService")
17
public class UserServiceImpl implements UserService {
18

  
19
    private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger
20
            .getLogger(UserServiceImpl.class);
21

  
22
    @Value("${oidc.issuer}")
23
    private String oidc_issuer;
24

  
25
    @Override
26
    public ResponseEntity<Object> login() {
27
        OIDCAuthenticationToken authentication = (OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
28
        LOGGER.debug("User authentication : " + authentication);
29
        Map<String,Object> body = new HashMap<>();
30
        body.put("sub",authentication.getSub());
31
        if(authentication.getUserInfo().getName() == null || authentication.getUserInfo().getName().equals(""))
32
            body.put("name",authentication.getUserInfo().getGivenName() + " " + authentication.getUserInfo().getFamilyName());
33
        else
34
            body.put("name",authentication.getUserInfo().getName());
35

  
36
        body.put("email",authentication.getUserInfo().getEmail());
37
        List<String> roles = authentication.getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList());
38
        body.put("role",roles);
39

  
40
        return new ResponseEntity<>(body, HttpStatus.OK);
41
    }
42
}
modules/uoa-repository-manager-service/branches/cris/src/main/java/eu/dnetlib/repo/manager/service/RepositoryServiceImpl.java
1
package eu.dnetlib.repo.manager.service;
2

  
3
import com.fasterxml.jackson.core.JsonProcessingException;
4
import com.fasterxml.jackson.databind.ObjectMapper;
5
import com.fasterxml.jackson.databind.SerializationFeature;
6
import eu.dnetlib.api.functionality.ValidatorServiceException;
7
import eu.dnetlib.domain.data.Repository;
8
import eu.dnetlib.domain.data.RepositoryInterface;
9
import eu.dnetlib.domain.enabling.Vocabulary;
10
import eu.dnetlib.domain.functionality.validator.JobForValidation;
11
import eu.dnetlib.repo.manager.domain.RepositorySnippet;
12
import eu.dnetlib.repo.manager.domain.RequestFilter;
13
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
14
import eu.dnetlib.repo.manager.shared.*;
15
import eu.dnetlib.repo.manager.utils.Converter;
16
import gr.uoa.di.driver.enabling.vocabulary.VocabularyLoader;
17
import gr.uoa.di.driver.xml.repository.INTERFACE;
18
import org.apache.commons.codec.digest.DigestUtils;
19
import org.apache.log4j.Logger;
20
import org.json.JSONArray;
21
import org.json.JSONException;
22
import org.json.JSONObject;
23
import org.springframework.beans.factory.annotation.Autowired;
24
import org.springframework.beans.factory.annotation.Value;
25
import org.springframework.core.ParameterizedTypeReference;
26
import org.springframework.http.*;
27
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
28
import org.springframework.security.core.Authentication;
29
import org.springframework.security.core.context.SecurityContextHolder;
30
import org.springframework.stereotype.Service;
31
import org.springframework.web.bind.annotation.PathVariable;
32
import org.springframework.web.bind.annotation.RequestBody;
33
import org.springframework.web.bind.annotation.RequestParam;
34
import org.springframework.web.client.RestClientException;
35
import org.springframework.web.client.RestTemplate;
36
import org.springframework.web.util.UriComponents;
37
import org.springframework.web.util.UriComponentsBuilder;
38

  
39
import javax.annotation.PostConstruct;
40
import java.io.IOException;
41
import java.sql.Timestamp;
42
import java.util.*;
43
import java.util.concurrent.ConcurrentHashMap;
44
import java.util.stream.Collectors;
45

  
46
@Service("repositoryService")
47
public class RepositoryServiceImpl implements RepositoryService {
48

  
49
    @Value("${api.baseAddress}")
50
    private String baseAddress;
51

  
52
    @Value("${services.repo-manager.adminEmail}")
53
    private String adminEmail;
54

  
55
    @Autowired
56
    RestTemplate restTemplate;
57

  
58
    private HttpHeaders httpHeaders;
59

  
60
    private final String[] vocabularyNames = {"dnet:countries", "dnet:datasource_typologies", "dnet:compatibilityLevel"};
61

  
62
    private static final Logger LOGGER = Logger.getLogger(RepositoryServiceImpl.class);
63

  
64
    @Value("${services.repomanager.usageStatisticsDiagramsBaseURL}")
65
    private String usageStatisticsDiagramsBaseURL;
66

  
67
    @Value("${services.repomanager.usageStatisticsNumbersBaseURL}")
68
    private String usageStatisticsNumbersBaseURL;
69

  
70
    @Autowired
71
    private VocabularyLoader vocabularyLoader;
72

  
73
    @Autowired
74
    private PiWikService piWikService;
75

  
76
    @Autowired
77
    private EmailUtils emailUtils;
78

  
79
    @Autowired
80
    ValidatorService validatorService;
81

  
82

  
83
    private Map<String, Vocabulary> vocabularyMap = new ConcurrentHashMap<>();
84

  
85
    private Map<String, String> countriesMap = new HashMap<>();
86
    private Map<String, String> inverseCountriesMap = new HashMap<>();
87

  
88
    private static Map<String,List<String>> dataSourceClass = new HashMap<>();
89

  
90
    private static Map<String,String> invertedDataSourceClass = new HashMap<>();
91

  
92

  
93

  
94
    @PostConstruct
95
    private void init() {
96
        LOGGER.debug("Initialization method of repository api!");
97
        LOGGER.debug("Updated version!");
98

  
99
        dataSourceClass.put("opendoar",Arrays.asList("pubsrepository::institutional","pubsrepository::thematic","pubsrepository::unknown","pubsrepository::mock"));
100
        dataSourceClass.put("re3data", Collections.singletonList("datarepository::unknown"));
101
        dataSourceClass.put("journal", Collections.singletonList("pubsrepository::journal"));
102
        dataSourceClass.put("aggregator",Arrays.asList("aggregator::pubsrepository::institutional","aggregator::pubsrepository::journals","aggregator::datarepository", "aggregator::pubsrepository::unknown"));
103

  
104
        invertedDataSourceClass.put("pubsrepository::institutional","opendoar");
105
        invertedDataSourceClass.put("pubsrepository::thematic","opendoar");
106
        invertedDataSourceClass.put("pubsrepository::unknown","opendoar");
107
        invertedDataSourceClass.put("pubsrepository::mock","opendoar");
108
        invertedDataSourceClass.put("datarepository::unknown","re3data");
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff