Revision 59119
Added by Antonis Lempesis over 3 years ago
modules/uoa-repository-manager-service/branches/newmodel/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/newmodel/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/newmodel/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/newmodel/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 |
|
|
12 |
<bean class="eu.dnetlib.repo.manager.config.CascadingPropertyLoader" |
|
13 |
id="propertyLoader"> |
|
14 |
<property name="order" value="2"/> |
|
15 |
<property name="properties"> |
|
16 |
<bean class="eu.dnetlib.conf.WebappContextProperyFactory"> |
|
17 |
<property name="propertyFetcher"> |
|
18 |
<bean class="eu.dnetlib.conf.PropertyFetcher"/> |
|
19 |
</property> |
|
20 |
</bean> |
|
21 |
</property> |
|
22 |
<property name="ignoreUnresolvablePlaceholders" value="true"/> |
|
23 |
<property name="locations"> |
|
24 |
<list> |
|
25 |
<value>classpath*:/gr/**/springContext-*.properties</value> |
|
26 |
<value>classpath*:/eu/**/springContext-*.properties</value> |
|
27 |
|
|
28 |
<value>classpath*:/application.properties</value> |
|
29 |
<value>classpath*:email-texts.properties</value> |
|
30 |
|
|
31 |
<!-- <value>classpath*:dnet-site-wizard.properties</value>--> |
|
32 |
<!-- <value>classpath*:dnet-site-override.properties</value>--> |
|
33 |
<!-- <value>classpath*:dnet-wizard.properties</value>--> |
|
34 |
<!-- <value>classpath*:dnet-override.properties</value>--> |
|
35 |
<!-- <value>classpath*:dnet-validator-wizard.properties</value>--> |
|
36 |
<!-- <value>classpath*:dnet-validator-override.properties</value>--> |
|
37 |
<!-- <value>classpath*:dnet-site-force-override.properties</value>--> |
|
38 |
<!-- <value>classpath*:dnet-force-override.properties</value>--> |
|
39 |
</list> |
|
40 |
</property> |
|
41 |
</bean> |
|
42 |
</beans> |
modules/uoa-repository-manager-service/branches/newmodel/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 |
</beans> |
modules/uoa-repository-manager-service/branches/newmodel/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/newmodel/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.*; |
|
7 |
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException; |
|
8 |
import org.json.JSONException; |
|
9 |
import org.springframework.security.core.Authentication; |
|
10 |
|
|
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, IOException; |
|
25 |
|
|
26 |
List<RepositorySnippet> getRepositoriesSnippetOfUser(String userEmail, String page, String size) throws IOException, JSONException; |
|
27 |
|
|
28 |
Repository getRepositoryById(String id) throws JSONException, ResourceNotFoundException; |
|
29 |
|
|
30 |
List<AggregationDetails> getRepositoryAggregations(String id, int from, int size) throws JSONException; |
|
31 |
|
|
32 |
Map<String,List<AggregationDetails>> getRepositoryAggregationsByYear(String id) throws JSONException; |
|
33 |
|
|
34 |
List<Repository> getRepositoriesByName(String name, |
|
35 |
String page, |
|
36 |
String size) throws JSONException; |
|
37 |
|
|
38 |
List<RepositorySnippet> searchRegisteredRepositories(String country, String typology, String englishName, |
|
39 |
String officialName, String requestSortBy, String order, |
|
40 |
int page, int pageSize) throws Exception; |
|
41 |
|
|
42 |
List<RepositoryInterface> getRepositoryInterface(String id) throws JSONException; |
|
43 |
|
|
44 |
Repository addRepository(String datatype, Repository repository) throws Exception; |
|
45 |
|
|
46 |
void deleteRepositoryInterface(String id, String registeredBy); |
|
47 |
|
|
48 |
RepositoryInterface addRepositoryInterface(String datatype, |
|
49 |
String repoId, |
|
50 |
String registeredBy, |
|
51 |
RepositoryInterface iFace) throws Exception; |
|
52 |
|
|
53 |
List<String> getDnetCountries(); |
|
54 |
|
|
55 |
List<String> getTypologies(); |
|
56 |
|
|
57 |
List<Timezone> getTimezones(); |
|
58 |
|
|
59 |
Repository updateRepository(Repository repository, Authentication authentication) throws Exception; |
|
60 |
|
|
61 |
List<String> getUrlsOfUserRepos(String user_email, |
|
62 |
String page, |
|
63 |
String size) throws JSONException; |
|
64 |
|
|
65 |
List<String> getDatasourceVocabularies(String mode); |
|
66 |
|
|
67 |
Map<String, String> getCompatibilityClasses(String mode); |
|
68 |
|
|
69 |
Map<String, String> getDatasourceClasses(String mode); |
|
70 |
|
|
71 |
String getCountryName(String countryCode); |
|
72 |
|
|
73 |
MetricsInfo getMetricsInfoForRepository(String repoId) throws RepositoryServiceException; |
|
74 |
|
|
75 |
Map<String, String> getListLatestUpdate(String mode) throws RepositoryServiceException, JSONException; |
|
76 |
|
|
77 |
RepositoryInterface updateRepositoryInterface(String repositoryId, String registeredBy, RepositoryInterface repositoryInterface) throws Exception; |
|
78 |
|
|
79 |
} |
modules/uoa-repository-manager-service/branches/newmodel/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/newmodel/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.domain.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/newmodel/src/main/java/eu/dnetlib/repo/manager/service/BrokerService.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.service; |
|
2 |
|
|
3 |
import eu.dnetlib.repo.manager.domain.BrokerException; |
|
4 |
import eu.dnetlib.repo.manager.domain.Term; |
|
5 |
import eu.dnetlib.repo.manager.domain.broker.*; |
|
6 |
import org.json.JSONException; |
|
7 |
import org.springframework.http.ResponseEntity; |
|
8 |
|
|
9 |
import java.io.IOException; |
|
10 |
import java.util.List; |
|
11 |
import java.util.Map; |
|
12 |
|
|
13 |
|
|
14 |
public interface BrokerService { |
|
15 |
|
|
16 |
DatasourcesBroker getDatasourcesOfUser(String user, String includeShared, String includeByOthers) throws BrokerException, JSONException; |
|
17 |
|
|
18 |
List<BrowseEntry> getTopicsForDatasource(String datasourceName) throws BrokerException; |
|
19 |
|
|
20 |
EventsPage advancedShowEvents(String page, |
|
21 |
String size, |
|
22 |
AdvQueryObject advQueryObject) throws BrokerException, JSONException ,IOException; |
|
23 |
|
|
24 |
EventsPage showEvents(String datasourceName, |
|
25 |
String topic, |
|
26 |
String page, |
|
27 |
String size) throws BrokerException, JSONException; |
|
28 |
|
|
29 |
Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser(String userEmail) throws BrokerException; |
|
30 |
|
|
31 |
Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUserByRepoId(String userEmail, String repoId) throws BrokerException; |
|
32 |
|
|
33 |
Subscription subscribe(OpenaireSubscription obj) throws BrokerException; |
|
34 |
|
|
35 |
ResponseEntity<Object> unsubscribe(String subscriptionId) throws BrokerException; |
|
36 |
|
|
37 |
Subscription getSubscription(String subscriptionId) throws BrokerException; |
|
38 |
|
|
39 |
Map<String, Term> getDnetTopics() throws BrokerException; |
|
40 |
|
|
41 |
EventsPage getNotificationsBySubscriptionId(String subscriptionId, String page, String size) throws BrokerException; |
|
42 |
|
|
43 |
Map<String, List<Subscription>> getSubscriptionsOfUser(String userEmail) throws BrokerException; |
|
44 |
} |
modules/uoa-repository-manager-service/branches/newmodel/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.RuleSet; |
|
6 |
import eu.dnetlib.domain.functionality.validator.StoredJob; |
|
7 |
import eu.dnetlib.repo.manager.domain.InterfaceInformation; |
|
8 |
import eu.dnetlib.repo.manager.domain.ValidationServiceException; |
|
9 |
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException; |
|
10 |
import org.json.JSONException; |
|
11 |
import org.springframework.http.ResponseEntity; |
|
12 |
|
|
13 |
import java.util.List; |
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
public interface ValidatorService { |
|
18 |
|
|
19 |
|
|
20 |
JobForValidation submitJobForValidation(JobForValidation jobForValidation) throws ValidatorServiceException; |
|
21 |
|
|
22 |
ResponseEntity<Object> reSubmitJobForValidation(String email, String jobId) throws JSONException, ValidatorServiceException; |
|
23 |
|
|
24 |
List<RuleSet> getRuleSets(String mode); |
|
25 |
|
|
26 |
List<String> getSetsOfRepository(String url); |
|
27 |
|
|
28 |
boolean identifyRepo(String url); |
|
29 |
|
|
30 |
RuleSet getRuleSet(String acronym); |
|
31 |
|
|
32 |
List<StoredJob> getStoredJobsNew(String user, |
|
33 |
String jobType, |
|
34 |
String offset, |
|
35 |
String limit, |
|
36 |
String dateFrom, |
|
37 |
String dateTo, |
|
38 |
String validationStatus) throws ValidatorServiceException; |
|
39 |
|
|
40 |
int getStoredJobsTotalNumberNew(String user, String jobType, String validationStatus) throws ValidatorServiceException; |
|
41 |
|
|
42 |
InterfaceInformation getInterfaceInformation(String baseUrl) throws ValidationServiceException; |
|
43 |
|
|
44 |
List<StoredJob> getJobsSummary(String repoId, int limit) throws ValidatorServiceException, ResourceNotFoundException, JSONException; |
|
45 |
} |
modules/uoa-repository-manager-service/branches/newmodel/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/newmodel/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/newmodel/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/newmodel/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/newmodel/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/newmodel/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/newmodel/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/newmodel/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/newmodel/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/newmodel/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.domain.JobsOfUser; |
|
6 |
import org.json.JSONException; |
|
7 |
|
|
8 |
|
|
9 |
public interface MonitorService { |
|
10 |
|
|
11 |
|
|
12 |
JobsOfUser getJobsOfUser(String user, |
|
13 |
String jobType, |
|
14 |
String offset, |
|
15 |
String limit, |
|
16 |
String dateFrom, |
|
17 |
String dateTo, |
|
18 |
String validationStatus, |
|
19 |
String includeJobsTotal) throws JSONException, ValidatorServiceException; |
|
20 |
|
|
21 |
int getJobsOfUserPerValidationStatus(String user, |
|
22 |
String jobType, |
|
23 |
String validationStatus) throws JSONException; |
|
24 |
|
|
25 |
|
|
26 |
StoredJob getJobSummary(String jobId, |
|
27 |
String groupBy) throws JSONException; |
|
28 |
|
|
29 |
} |
modules/uoa-repository-manager-service/branches/newmodel/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 org.springframework.security.core.Authentication; |
|
8 |
|
|
9 |
public interface EmailUtils { |
|
10 |
|
|
11 |
|
|
12 |
void reportException(Exception exception); |
|
13 |
|
|
14 |
void sendAdministratorRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception; |
|
15 |
|
|
16 |
void sendUserRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception; |
|
17 |
|
|
18 |
void sendAdministratorMetricsEnabled(PiwikInfo piwikInfo) throws Exception; |
|
19 |
|
|
20 |
void sendUserMetricsEnabled(PiwikInfo piwikInfo) throws Exception; |
|
21 |
|
|
22 |
/****USER REGISTRATION REQUEST EMAILS****/ |
|
23 |
void sendAdminRegistrationEmail(Repository repository, Authentication authentication) throws Exception; |
|
24 |
|
|
25 |
void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception; |
|
26 |
|
|
27 |
void sendAdminRegisterInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception; |
|
28 |
|
|
29 |
void sendUserRegisterInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception; |
|
30 |
|
|
31 |
/****SUCCESSFUL REGISTRATION RESULTS EMAILS****/ |
|
32 |
void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; |
|
33 |
|
|
34 |
void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; |
|
35 |
|
|
36 |
/****FAILURE REGISTRATION RESULTS EMAILS****/ |
|
37 |
void sendUserRegistrationResultsFailureEmail(String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; |
|
38 |
|
|
39 |
void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; |
|
40 |
|
|
41 |
/****SUCCESSFUL UPDATE RESULTS EMAILS****/ |
|
42 |
void sendUserUpdateResultsSuccessEmail(String issuer, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; |
|
43 |
|
|
44 |
void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; |
|
45 |
|
|
46 |
/****FAILURE UPDATE RESULTS EMAILS****/ |
|
47 |
void sendUserUpdateResultsFailureEmail(String issuer, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; |
|
48 |
|
|
49 |
void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; |
|
50 |
|
|
51 |
/****VALIDATION OF CONTENT PROVIDER EMAILS****/ |
|
52 |
void sendUserValidationResults(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; |
|
53 |
|
|
54 |
void sendAdminValidationResults(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; |
|
55 |
|
|
56 |
/****GENERAL FAILURE OF VALIDATOR****/ |
|
57 |
void sendAdminGeneralFailure(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; |
|
58 |
|
|
59 |
|
|
60 |
void sendAdminUpdateRepositoryInfoEmail(Repository repository, Authentication authentication) throws Exception; |
|
61 |
|
|
62 |
void sendUserUpdateRepositoryInfoEmail(Repository repository, Authentication authentication) throws Exception; |
|
63 |
|
|
64 |
void sendAdminUpdateInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception; |
|
65 |
|
|
66 |
void sendUserUpdateInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception; |
|
67 |
|
|
68 |
void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation) throws Exception; |
|
69 |
|
|
70 |
void sendUponJobCompletion(String repoId, |
|
71 |
String repoInterfaceId, |
|
72 |
int scoreUsage, |
|
73 |
int scoreContent, |
|
74 |
boolean isSuccess, |
|
75 |
boolean isUpdate, |
|
76 |
String issuerEmail, |
|
77 |
String jobId) throws Exception; |
|
78 |
} |
modules/uoa-repository-manager-service/branches/newmodel/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/newmodel/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.client.RestClientException; |
|
14 |
import org.springframework.web.client.RestTemplate; |
|
15 |
import org.springframework.web.util.UriComponentsBuilder; |
|
16 |
|
|
17 |
import java.util.ArrayList; |
|
18 |
import java.util.List; |
|
19 |
|
|
20 |
@Service("sushiliteService") |
|
21 |
public class SushiliteServiceImpl implements SushiliteService { |
|
22 |
|
|
23 |
|
|
24 |
@Value("${services.repomanager.usagestats.sushiliteEndpoint}") |
|
25 |
private String usagestatsSushiliteEndpoint; |
|
26 |
|
|
27 |
@Autowired |
|
28 |
private EmailUtils emailUtils; |
|
29 |
|
|
30 |
private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger.getLogger(SushiliteServiceImpl.class); |
|
31 |
|
|
32 |
|
|
33 |
@Override |
|
34 |
@PreAuthorize("hasRole('ROLE_USER')") |
|
35 |
public ReportResponseWrapper getReportResults(String page, |
|
36 |
String pageSize, |
|
37 |
String Report, |
|
38 |
String Release, |
|
39 |
String RequestorID, |
|
40 |
String BeginDate, |
|
41 |
String EndDate, |
|
42 |
String RepositoryIdentifier, |
|
43 |
String ItemIdentifier, |
|
44 |
String ItemDataType, |
|
45 |
String Granularity, |
|
46 |
String Pretty) { |
|
47 |
|
|
48 |
//build the uri params |
|
49 |
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(this.usagestatsSushiliteEndpoint + "GetReport/") |
|
50 |
.queryParam("Report", Report) |
|
51 |
.queryParam("Release", Release) |
|
52 |
.queryParam("RequestorID", RequestorID) |
|
53 |
.queryParam("BeginDate", BeginDate) |
|
54 |
.queryParam("EndDate", EndDate) |
|
55 |
.queryParam("RepositoryIdentifier", RepositoryIdentifier) |
|
56 |
.queryParam("ItemIdentifier", ItemIdentifier) |
|
57 |
.queryParam("ItemDataType", ItemDataType) |
|
58 |
.queryParam("Granularity", Granularity) |
|
59 |
.queryParam("Pretty", Pretty); |
|
60 |
|
|
61 |
//create new template engine |
|
62 |
RestTemplate template = new RestTemplate(); |
|
63 |
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); |
|
64 |
|
|
65 |
ResponseEntity<ReportResponseWrapper> resp; |
|
66 |
try { |
|
67 |
//communicate with endpoint |
|
68 |
resp = template.exchange( |
|
69 |
builder.build().encode().toUri(), |
|
70 |
HttpMethod.GET, |
|
71 |
null, |
|
72 |
new ParameterizedTypeReference<ReportResponseWrapper>() { |
|
73 |
}); |
|
74 |
} catch (RestClientException e) { |
|
75 |
LOGGER.debug("Exception on getReportResults" , e); |
|
76 |
emailUtils.reportException(e); |
|
77 |
throw e; |
|
78 |
} |
|
79 |
|
|
80 |
// check remote api's response |
|
81 |
System.out.println("sushi responded status " + resp.getStatusCode()); |
|
82 |
|
|
83 |
// get the items corresponding to the requested page |
|
84 |
List<ReportItem> requestedItemList = new ArrayList<>(); |
|
85 |
if (resp.getBody().getReportResponse().getReportWrapper().getReport().getCustomer().getReportItems() != null) { |
|
86 |
try { |
|
87 |
int totalItems = resp.getBody().getReportResponse().getReportWrapper().getReport().getCustomer().getReportItems().size(); |
|
88 |
int size = Integer.parseInt(pageSize); |
|
89 |
int offset = Integer.parseInt(page)*size; |
|
90 |
|
|
91 |
if (offset < totalItems ) { |
|
92 |
int upperIndex = offset+size; |
|
93 |
if (upperIndex > totalItems) { |
|
94 |
upperIndex = totalItems; |
|
95 |
} |
|
96 |
requestedItemList = resp.getBody().getReportResponse().getReportWrapper().getReport().getCustomer().getReportItems().subList(offset,upperIndex); |
|
97 |
} |
|
98 |
|
|
99 |
} catch (NumberFormatException e) { |
|
100 |
LOGGER.debug("Exception on getReportResults - trying to cast strings to integers", e); |
|
101 |
//emailUtils.reportException(e); |
|
102 |
throw e; |
|
103 |
} |
|
104 |
|
|
105 |
} |
|
106 |
|
|
107 |
ReportResponseWrapper newReportResponse = resp.getBody(); |
|
108 |
newReportResponse.getReportResponse().getReportWrapper().getReport().getCustomer().setReportItems(requestedItemList); |
|
109 |
|
|
110 |
|
|
111 |
return newReportResponse; |
|
112 |
} |
|
113 |
|
|
114 |
} |
modules/uoa-repository-manager-service/branches/newmodel/src/main/java/eu/dnetlib/repo/manager/service/StatsService.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.service; |
|
2 |
|
|
3 |
import java.util.Map; |
|
4 |
|
|
5 |
|
|
6 |
public interface StatsService { |
|
7 |
|
|
8 |
Map getStatistics() ; |
|
9 |
} |
modules/uoa-repository-manager-service/branches/newmodel/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/newmodel/src/main/java/eu/dnetlib/repo/manager/service/RepositoryServiceImpl.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.service; |
|
2 |
|
|
3 |
import com.fasterxml.jackson.databind.ObjectMapper; |
|
4 |
import eu.dnetlib.api.functionality.ValidatorServiceException; |
|
5 |
import eu.dnetlib.domain.data.Repository; |
|
6 |
import eu.dnetlib.domain.data.RepositoryInterface; |
|
7 |
import eu.dnetlib.domain.enabling.Vocabulary; |
|
8 |
import eu.dnetlib.domain.functionality.validator.JobForValidation; |
|
9 |
import eu.dnetlib.repo.manager.domain.*; |
|
10 |
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException; |
|
11 |
import eu.dnetlib.repo.manager.utils.Converter; |
|
12 |
import gr.uoa.di.driver.enabling.vocabulary.VocabularyLoader; |
|
13 |
import org.apache.commons.codec.digest.DigestUtils; |
|
14 |
import org.apache.log4j.Logger; |
|
15 |
import org.json.JSONArray; |
|
16 |
import org.json.JSONException; |
|
17 |
import org.json.JSONObject; |
|
18 |
import org.springframework.beans.factory.annotation.Autowired; |
|
19 |
import org.springframework.beans.factory.annotation.Value; |
|
20 |
import org.springframework.core.ParameterizedTypeReference; |
|
21 |
import org.springframework.http.*; |
|
22 |
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; |
|
23 |
import org.springframework.security.core.Authentication; |
|
24 |
import org.springframework.security.core.context.SecurityContextHolder; |
|
25 |
import org.springframework.stereotype.Service; |
|
26 |
import org.springframework.web.client.RestClientException; |
|
27 |
import org.springframework.web.client.RestTemplate; |
|
28 |
import org.springframework.web.util.UriComponents; |
|
29 |
import org.springframework.web.util.UriComponentsBuilder; |
|
30 |
|
|
31 |
import javax.annotation.PostConstruct; |
|
32 |
import java.io.IOException; |
|
33 |
import java.sql.Timestamp; |
|
34 |
import java.util.*; |
|
35 |
import java.util.concurrent.ConcurrentHashMap; |
|
36 |
import java.util.stream.Collectors; |
|
37 |
|
|
38 |
@Service("repositoryService") |
|
39 |
public class RepositoryServiceImpl implements RepositoryService { |
|
40 |
|
|
41 |
@Value("${api.baseAddress}") |
|
42 |
private String baseAddress; |
|
43 |
|
|
44 |
@Value("${services.repo-manager.adminEmail}") |
|
45 |
private String adminEmail; |
|
46 |
|
|
47 |
@Autowired |
|
48 |
RestTemplate restTemplate; |
|
49 |
|
|
50 |
private HttpHeaders httpHeaders; |
|
51 |
|
|
52 |
private final String[] vocabularyNames = {"dnet:countries", "dnet:datasource_typologies", "dnet:compatibilityLevel"}; |
|
53 |
|
|
54 |
private static final Logger LOGGER = Logger.getLogger(RepositoryServiceImpl.class); |
|
55 |
|
|
56 |
@Value("${services.repomanager.usageStatisticsDiagramsBaseURL}") |
|
57 |
private String usageStatisticsDiagramsBaseURL; |
|
58 |
|
|
59 |
@Value("${services.repomanager.usageStatisticsNumbersBaseURL}") |
|
60 |
private String usageStatisticsNumbersBaseURL; |
|
61 |
|
|
62 |
@Autowired |
|
63 |
private VocabularyLoader vocabularyLoader; |
|
64 |
|
|
65 |
@Autowired |
|
66 |
private PiWikService piWikService; |
|
67 |
|
|
68 |
@Autowired |
|
69 |
private EmailUtils emailUtils; |
|
70 |
|
|
71 |
@Autowired |
|
72 |
ValidatorService validatorService; |
|
73 |
|
|
74 |
|
|
75 |
private Map<String, Vocabulary> vocabularyMap = new ConcurrentHashMap<>(); |
|
76 |
|
|
77 |
private Map<String, String> countriesMap = new HashMap<>(); |
|
78 |
private Map<String, String> inverseCountriesMap = new HashMap<>(); |
|
79 |
|
|
80 |
private static Map<String,List<String>> dataSourceClass = new HashMap<>(); |
|
81 |
|
|
82 |
private static Map<String,String> invertedDataSourceClass = new HashMap<>(); |
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
@PostConstruct |
|
87 |
private void init() { |
|
88 |
LOGGER.debug("Initialization method of repository api!"); |
|
89 |
LOGGER.debug("Updated version!"); |
|
90 |
|
|
91 |
dataSourceClass.put("opendoar",Arrays.asList("pubsrepository::institutional","pubsrepository::thematic","pubsrepository::unknown","pubsrepository::mock")); |
|
92 |
dataSourceClass.put("re3data", Collections.singletonList("datarepository::unknown")); |
|
93 |
dataSourceClass.put("journal", Collections.singletonList("pubsrepository::journal")); |
|
94 |
dataSourceClass.put("aggregator",Arrays.asList("aggregator::pubsrepository::institutional","aggregator::pubsrepository::journals","aggregator::datarepository", "aggregator::pubsrepository::unknown")); |
|
95 |
|
|
96 |
invertedDataSourceClass.put("pubsrepository::institutional","opendoar"); |
|
97 |
invertedDataSourceClass.put("pubsrepository::thematic","opendoar"); |
|
98 |
invertedDataSourceClass.put("pubsrepository::unknown","opendoar"); |
|
99 |
invertedDataSourceClass.put("pubsrepository::mock","opendoar"); |
|
100 |
invertedDataSourceClass.put("datarepository::unknown","re3data"); |
|
101 |
invertedDataSourceClass.put("pubsrepository::journal","journal"); |
|
102 |
invertedDataSourceClass.put("aggregator::pubsrepository::institutional","aggregator"); |
|
103 |
invertedDataSourceClass.put("aggregator::pubsrepository::journals","aggregator"); |
|
104 |
invertedDataSourceClass.put("aggregator::datarepository","aggregator"); |
|
105 |
invertedDataSourceClass.put("aggregator::pubsrepository::unknown","aggregator"); |
|
106 |
|
|
107 |
|
|
108 |
httpHeaders = new HttpHeaders(); |
|
109 |
httpHeaders.setContentType(MediaType.APPLICATION_JSON_UTF8); |
|
110 |
|
|
111 |
for (String vocName : vocabularyNames) { |
|
112 |
vocabularyMap.put(vocName, vocabularyLoader.getVocabulary(vocName, Locale.ENGLISH, Locale.ROOT)); |
|
113 |
} |
|
114 |
|
|
115 |
Country[] countries = getCountries(); |
|
116 |
for (Country c : countries) { |
|
117 |
countriesMap.put(c.getName(), c.getCode()); |
|
118 |
inverseCountriesMap.put(c.getCode(), c.getName()); |
|
119 |
} |
|
120 |
|
|
121 |
|
|
122 |
} |
|
123 |
|
|
124 |
@Override |
|
125 |
public Country[] getCountries() { |
|
126 |
UriComponents uriComponents = UriComponentsBuilder |
|
127 |
.fromHttpUrl(baseAddress + "/ds/countries") |
|
128 |
.build().encode(); |
|
129 |
return restTemplate.getForObject(uriComponents.toUri(), Country[].class); |
|
130 |
} |
|
131 |
|
|
132 |
|
|
133 |
@Override |
|
134 |
public List<RepositorySnippet> getRepositoriesByCountry(String country, |
|
135 |
String mode, |
|
136 |
Boolean managed) throws JSONException, IOException { |
|
137 |
|
|
138 |
LOGGER.debug("Getting repositories by country!"); |
|
139 |
int page = 0; |
|
140 |
int size = 100; |
|
141 |
List<RepositorySnippet> resultSet = new ArrayList<>(); |
|
142 |
ObjectMapper mapper = new ObjectMapper(); |
|
143 |
|
|
144 |
String filterKey = "UNKNOWN"; |
|
145 |
if (mode.equalsIgnoreCase("opendoar")) |
|
146 |
filterKey = "openaire____::opendoar"; |
|
147 |
else if (mode.equalsIgnoreCase("re3data")) |
|
148 |
filterKey = "openaire____::re3data"; |
|
149 |
|
|
150 |
|
|
151 |
LOGGER.debug("Country code equals : " + country); |
|
152 |
LOGGER.debug("Filter mode equals : " + filterKey); |
|
153 |
|
|
154 |
UriComponents uriComponents = searchSnipperDatasource(String.valueOf(page),String.valueOf(size)); |
|
155 |
RequestFilter requestFilter = new RequestFilter(); |
|
156 |
requestFilter.setCountry(country); |
|
157 |
requestFilter.setCollectedfrom(filterKey); |
|
158 |
|
|
159 |
try{ |
|
160 |
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class); |
|
161 |
JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo"); |
|
162 |
while (jsonArray.length() > 0 ) { |
|
163 |
resultSet.addAll(mapper.readValue(String.valueOf(jsonArray), |
|
164 |
mapper.getTypeFactory().constructCollectionType(List.class, RepositorySnippet.class))); |
|
165 |
page += 1; |
|
166 |
uriComponents = searchSnipperDatasource(String.valueOf(page),String.valueOf(size)); |
|
167 |
rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class); |
|
168 |
jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo"); |
|
169 |
} |
|
170 |
return resultSet; |
|
171 |
}catch (Exception e){ |
Also available in: Unified diff
creating branch to use new broker model