Project

General

Profile

« Previous | Next » 

Revision 50058

View differences:

modules/uoa-repository-manager-service/trunk/src/main/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" xmlns:p="http://www.springframework.org/schema/p"
4
       xmlns:context="http://www.springframework.org/schema/context"
5
       xmlns:task="http://www.springframework.org/schema/task" xmlns:tx="http://www.springframework.org/schema/tx"
6
       xsi:schemaLocation="http://www.springframework.org/schema/beans
7
       http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
8
	http://www.springframework.org/schema/context
9
	http://www.springframework.org/schema/context/spring-context-4.0.xsd
10
	http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
11

  
12
    <import resource="classpath:META-INF/cxf/cxf.xml"/>
13
    <import resource="classpath:META-INF/cxf/cxf-extension-jaxws.xml"/>
14
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
15
    <import resource="classpath*:/cxf.xml"/>
16
    <import resource="classpath*:/eu/dnetlib/repos/ehcacher/springContext-repos-ehcacher.xml"/>
17
    <import resource="classpath*:/eu/dnetlib/soap/cxf/applicationContext-eprbuilders.xml"/>
18
    <import resource="classpath*:/eu/dnetlib/clients/ws/springContext-locatorFactory.xml"/>
19
    <import resource="classpath*:/eu/dnetlib/users/springContext-users-ldap.xml"/>
20
    <import resource="classpath*:/gr/uoa/di/driver/util/springContext-locators.xml"/>
21
    <import resource="classpath*:/gr/uoa/di/driver/app/springContext-lookupFactory.xml"/>
22
    <import resource="classpath*:/gr/uoa/di/driver/app/springContext-lookupClients.xml"/>
23
    <import resource="classpath*:/eu/dnetlib/enabling/hcm/springContext-hcmService.xml"/>
24
    <import resource="classpath*:/gr/uoa/di/driver/app/springContext-commons.xml"/>
25
    <import resource="classpath*:/gr/uoa/di/driver/app/springContext-registrator.xml"/>
26
    <import resource="classpath*:/eu/dnetlib/repos/springContext-repos-dms-cached.xml"/>
27
    <context:property-placeholder location="classpath*:/eu/**/application.properties" />
28
    <tx:annotation-driven transaction-manager="txManager"/>
29

  
30
    <bean class="eu.dnetlib.repo.manager.service.config.CascadingPropertyLoader" id="propertyLoader">
31
        <property name="order" value="2" />
32
        <property name="properties">
33
            <bean class="eu.dnetlib.conf.WebappContextProperyFactory">
34
                <property name="propertyFetcher">
35
                    <bean class="eu.dnetlib.conf.PropertyFetcher" />
36
                </property>
37
            </bean>
38
        </property>
39
        <property name="ignoreUnresolvablePlaceholders" value="true" />
40
        <property name="locations">
41
            <list>
42
                <value>classpath*:/gr/**/springContext-*.properties</value>
43
                <value>classpath*:/eu/**/springContext-*.properties</value>
44

  
45
                <value>classpath*:/eu/dnetlib/repo/manager/service/email-texts.properties</value>
46

  
47
                <value>classpath*:dnet-site-wizard.properties</value>
48
                <value>classpath*:dnet-site-override.properties</value>
49
                <value>classpath*:dnet-wizard.properties</value>
50
                <value>classpath*:dnet-override.properties</value>
51
                <value>classpath*:dnet-validator-wizard.properties</value>
52
                <value>classpath*:dnet-validator-override.properties</value>
53
                <value>classpath*:dnet-site-force-override.properties</value>
54
                <value>classpath*:dnet-force-override.properties</value>
55
            </list>
56
        </property>
57
    </bean>
58

  
59
    <bean id="repomanager.dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
60
        <property name="driverClassName" value="${repomanager.db.driverClassName}" />
61
        <property name="url" value="${repomanager.db.url}" />
62
        <property name="username" value="${repomanager.db.username}" />
63
        <property name="password" value="${repomanager.db.password}" />
64
        <property name="maxIdle" value="10" />
65
        <property name="maxActive" value="100" />
66
        <property name="maxWait" value="10000" />
67
        <property name="validationQuery" value="SELECT 1;" />
68
        <property name="testOnBorrow" value="true" />
69
        <property name="testOnReturn" value="true" />
70
        <property name="testWhileIdle" value="true" />
71
        <property name="timeBetweenEvictionRunsMillis" value="1200000" />
72
        <property name="minEvictableIdleTimeMillis" value="1800000" />
73
        <property name="numTestsPerEvictionRun" value="5" />
74
        <property name="poolPreparedStatements" value="true" />
75
        <property name="defaultAutoCommit" value="true" />
76
    </bean>
77

  
78
    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
79
        <property name="dataSource" ref="repomanager.dataSource"/>
80
    </bean>
81

  
82
</beans>
modules/uoa-repository-manager-service/trunk/src/main/resources/eu/dnetlib/repo/manager/service/email-texts.properties
1
user.registration.mail.subject = OpenAIRE Account Activation
2
user.registration.mail.message = Please follow this link to activate your account
3

  
4
user.forgotPassword.mail.Subject = OpenAIRE Reset Password Request
5
user.forgotPassword.mail.Body1 = To complete your password reset please follow this link
6
user.forgotPassword.mail.Body2 = Security Code
7

  
modules/uoa-repository-manager-service/trunk/src/main/resources/eu/dnetlib/repo/manager/service/application.properties
1
infrastructure.name=integration
2

  
3
# Container properties
4
container.hostname = localhost
5
container.context=repoManager
6
container.port = 8080
7

  
8
# IS
9
ISLookUpService.url = http://node6.t.openaire.research-infrastructures.eu/is/services/isLookUp
10
ISRegistryService.url = http://node6.t.openaire.research-infrastructures.eu/is/services/isRegistry
11
ISSNService.url = http://node6.t.openaire.research-infrastructures.eu/is/services/isSN
12
#ISLookUpService.url = http://localhost:9190/is/services/isLookUp
13
#ISRegistryService.url = http://localhost:9190/is/services/isRegistry
14
#ISSNService.url = http://localhost:9190/is/services/isSN
15
# LDAP
16
services.users.ldap.address = 194.177.192.119
17
services.users.ldap.port = 389
18
services.users.ldap.username = cn=admin,dc=openaire,dc=eu
19
services.users.ldap.password = serenata
20
services.users.ldap.usersDN = ou=users,dc=openaire,dc=eu
21

  
22
#services.repo-manager.repository.testing.mode = true
23

  
24
ValidatorService.url=http://adonis.athenarc.gr:8080/validator-service/services/validatorWebService
25

  
26
# Broker Service
27
services.broker.url = http://broker1-dev-dnet.d4science.org
28
#services.broker.url = http://localhost
29
services.broker.port = 8080
30
#services.broker.port = 9090
31
services.broker.api = api/
32
services.broker.openaire = openaireBroker
33

  
34
#
35
# Configuration file classpath
36
configurationFileClassPath=classpath:application-context.xml
37

  
38
api.baseAddress=https://dev-openaire.d4science.org/openaire
39

  
40
service.repository-rest-api.baseUrl = http://localhost:8080
41

  
42

  
43
# the address where validator is running and is accessible from the controllers of the web
44
services.repo-manager.baseUrl = http://${container.hostname}:${container.port}/${container.context}
45

  
46
# base address for soap web services
47
transport.soap.baseAddress = http://${container.hostname}:${container.port}/${container.context}
48

  
49
transport.soap.force.local.address = false
50

  
51
# the email of the administrator
52
# he will receive all the automatic bug reports and feedback created
53
services.repo-manager.adminEmail = nikonas@di.uoa.gr
54

  
55
# if set to true, getRepositories will return dummy repositories
56
services.repo-manager.repository.testing.mode = false
57

  
58
services.repo-manager.deploy.environment = development
59

  
60
# the mailhost for the mail service
61
services.validator.mail.host = smtp.gmail.com
62
# the port where the mail service is running
63
services.validator.mail.port = 465
64
# the address that appears in the from field in the mails send by the validator
65
services.validator.mail.fromAddress = no-reply@openaire.eu
66
# the reply-to field value in the mails send by the validator
67
services.validator.mail.replyToAddress = no-reply@openaire.eu
68
# the username of the account used to login in the mail server
69
services.validator.mail.username = test.openaire@gmail.com
70
# the password of the account used to login in the mail server
71
services.validator.mail.password = ^($*@$)*!$
72
# if authentication should take place
73
# if set to false username and password is not needed
74
services.validator.mail.authenticate = true
75
# is set to yes then all mails will not be sent to their targets but to the address specified in services.validator.mail.overrideEmail
76
services.validator.mail.override = false
77
# if set to true then no mails are send, they are only logged as a debug message
78
services.validator.mail.logonly = false
79
# the mode used for the mails send by the validator
80
services.validator.mail.mode = ssl
81
# used by eu.dnetlib.utils.MailLibrary to control debuggin messages
82
services.validator.mail.debug = false
83
# if services.validator.mail.override is true then all mails will be send only to this address
84
services.validator.mail.overrideEmail = nikonas@di.uoa.gr
85
# a comma-seperated list of address that will receive all mails about validations and repo registrations
86
services.validator.mail.specialRecipients = nikonas@di.uoa.gr
87

  
88
# a comma-seperated list of addresses that have the ability to register repos without the need for validation and registration
89
services.validator.repoRegistration.override = nikonas@di.uoa.gr
90

  
91

  
92
repomanager.db.driverClassName = org.postgresql.Driver
93
repomanager.db.url = jdbc:postgresql://194.177.192.119:5432/repomanager
94
repomanager.db.username = dnet
95
repomanager.db.password = dnetPwd
96

  
97
services.repomanager.analyticsURL = http://analytics.openaire.eu/addsite.php?
modules/uoa-repository-manager-service/trunk/src/main/resources/eu/dnetlib/repo/manager/service/utils/countries.txt
1
Afghanistan
2
Albania
3
Algeria
4
Andorra
5
Angola
6
Antigua & Deps
7
Argentina
8
Armenia
9
Australia
10
Austria
11
Azerbaijan
12
Bahamas
13
Bahrain
14
Bangladesh
15
Barbados
16
Belarus
17
Belgium
18
Belize
19
Benin
20
Bhutan
21
Bolivia
22
Bosnia Herzegovina
23
Botswana
24
Brazil
25
Brunei
26
Bulgaria
27
Burkina
28
Burundi
29
Cambodia
30
Cameroon
31
Canada
32
Cape Verde
33
Central African Rep
34
Chad
35
Chile
36
China
37
Colombia
38
Comoros
39
Congo
40
Congo {Democratic Rep}
41
Costa Rica
42
Croatia
43
Cuba
44
Cyprus
45
Czech Republic
46
Denmark
47
Djibouti
48
Dominica
49
Dominican Republic
50
East Timor
51
Ecuador
52
Egypt
53
El Salvador
54
Equatorial Guinea
55
Eritrea
56
Estonia
57
Ethiopia
58
Fiji
59
Finland
60
France
61
Gabon
62
Gambia
63
Georgia
64
Germany
65
Ghana
66
Greece
67
Grenada
68
Guatemala
69
Guinea
70
Guinea-Bissau
71
Guyana
72
Haiti
73
Honduras
74
Hungary
75
Iceland
76
India
77
Indonesia
78
Iran
79
Iraq
80
Ireland {Republic}
81
Israel
82
Italy
83
Ivory Coast
84
Jamaica
85
Japan
86
Jordan
87
Kazakhstan
88
Kenya
89
Kiribati
90
Korea North
91
Korea South
92
Kosovo
93
Kuwait
94
Kyrgyzstan
95
Laos
96
Latvia
97
Lebanon
98
Lesotho
99
Liberia
100
Libya
101
Liechtenstein
102
Lithuania
103
Luxembourg
104
Macedonia
105
Madagascar
106
Malawi
107
Malaysia
108
Maldives
109
Mali
110
Malta
111
Marshall Islands
112
Mauritania
113
Mauritius
114
Mexico
115
Micronesia
116
Moldova
117
Monaco
118
Mongolia
119
Montenegro
120
Morocco
121
Mozambique
122
Myanmar, {Burma}
123
Namibia
124
Nauru
125
Nepal
126
Netherlands
127
New Zealand
128
Nicaragua
129
Niger
130
Nigeria
131
Norway
132
Oman
133
Pakistan
134
Palau
135
Panama
136
Papua New Guinea
137
Paraguay
138
Peru
139
Philippines
140
Poland
141
Portugal
142
Qatar
143
Romania
144
Russian Federation
145
Rwanda
146
St Kitts & Nevis
147
St Lucia
148
Saint Vincent & the Grenadines
149
Samoa
150
San Marino
151
Sao Tome & Principe
152
Saudi Arabia
153
Senegal
154
Serbia
155
Seychelles
156
Sierra Leone
157
Singapore
158
Slovakia
159
Slovenia
160
Solomon Islands
161
Somalia
162
South Africa
163
Spain
164
Sri Lanka
165
Sudan
166
Suriname
167
Swaziland
168
Sweden
169
Switzerland
170
Syria
171
Taiwan
172
Tajikistan
173
Tanzania
174
Thailand
175
Togo
176
Tonga
177
Trinidad & Tobago
178
Tunisia
179
Turkey
180
Turkmenistan
181
Tuvalu
182
Uganda
183
Ukraine
184
United Arab Emirates
185
United Kingdom
186
United States
187
Uruguay
188
Uzbekistan
189
Vanuatu
190
Vatican City
191
Venezuela
192
Vietnam
193
Yemen
194
Zambia
195
Zimbabwe
modules/uoa-repository-manager-service/trunk/src/main/resources/eu/dnetlib/repo/manager/service/utils/timezones.txt
1
-2.0	[GMT - 2] Fernando de Noronha Time,	South Georg...
2
-1.0	[GMT - 1] Azores Standard Time, Cape Verde Time...
3
0.0	[GMT] Western European Time, Greenwich Mean Time
4
1.0	[GMT + 1] Central European Time, West African Time
5
2.0	[GMT + 2] Eastern European Time, Central Africa...
6
3.0	[GMT + 3] Moscow Standard Time, Eastern African...
7
3.5	[GMT + 3:30] Iran Standard Time
8
4.0	[GMT + 4] Gulf Standard Time, Samara Standard Time
9
4.5	[GMT + 4:30] Afghanistan Time
10
5.0	[GMT + 5] Pakistan Standard Time, Yekaterinburg...
11
8.0	[GMT + 8] Beijing, Hong Kong, Irkutsk, Kuala Lumpur, Manila, Perth
modules/uoa-repository-manager-service/trunk/src/main/resources/eu/dnetlib/repo/manager/service/utils/typologies.txt
1
CONTENTdm
2
Digibib
3
Digital Commons
4
DigiTool
5
DIVA
6
Diva-Portal
7
dLibra
8
Doks
9
Drupal
10
DSpace
11
Earmas
12
EPrints
13
ETD
14
ETD-db
15
Fedora
16
Fez
17
Greenstone
18
HAL
19
invenio
20
MyCoRe
21
Open Repository
22
OPUS
23
Pica-Verbundkatalog
24
Proprietary Software
25
PUMA
26
PURE
27
SciELO
28
SFIX
29
VITAL
30
VTOAI
31
WEKO
32
XooNIps
33
------------------------
34
OJS
35
HyperJournal
36
ePubTk
37
GAPworks
38
DPubS
39
E-Journal
40
------------------------
41
[Other]
42

  
modules/uoa-repository-manager-service/trunk/src/main/webapp/WEB-INF/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:context="http://www.springframework.org/schema/context" 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
       http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
8
	http://www.springframework.org/schema/context
9
	http://www.springframework.org/schema/context/spring-context-4.0.xsd
10
	http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
11
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
12

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

  
15
    <!-- <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>-->
16

  
17
      <import resource="classpath:META-INF/cxf/cxf.xml"/>
18

  
19
     <import resource="classpath:META-INF/cxf/cxf-extension-jaxws.xml"/>
20
     <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
21
     <import resource="classpath*:/cxf.xml"/>
22
     <import resource="classpath*:/eu/dnetlib/repos/ehcacher/springContext-repos-ehcacher.xml"/>
23
     <import resource="classpath*:/eu/dnetlib/soap/cxf/applicationContext-eprbuilders.xml"/>
24
     <import resource="classpath*:/eu/dnetlib/clients/ws/springContext-locatorFactory.xml"/>
25
     <import resource="classpath*:/eu/dnetlib/users/springContext-users-ldap.xml"/>
26
     <import resource="classpath*:/gr/uoa/di/driver/util/springContext-locators.xml"/>
27
     <import resource="classpath*:/gr/uoa/di/driver/app/springContext-lookupFactory.xml"/>
28
     <import resource="classpath*:/gr/uoa/di/driver/app/springContext-lookupClients.xml"/>
29
     <import resource="classpath*:/eu/dnetlib/enabling/hcm/springContext-hcmService.xml"/>
30
     <import resource="classpath*:/gr/uoa/di/driver/app/springContext-commons.xml"/>
31
     <import resource="classpath*:/gr/uoa/di/driver/app/springContext-registrator.xml"/>
32

  
33
     <import resource="classpath*:/eu/dnetlib/repos/springContext-repos-dms-cached.xml"/>
34

  
35
    <context:property-placeholder location="classpath*:/eu/**/application.properties" />
36

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

  
52
                <value>classpath*:/eu/dnetlib/repo/manager/service/email-texts.properties</value>
53

  
54
                <value>classpath*:dnet-site-wizard.properties</value>
55
                <value>classpath*:dnet-site-override.properties</value>
56
                <value>classpath*:dnet-wizard.properties</value>
57
                <value>classpath*:dnet-override.properties</value>
58
                <value>classpath*:dnet-validator-wizard.properties</value>
59
                <value>classpath*:dnet-validator-override.properties</value>
60
                <value>classpath*:dnet-site-force-override.properties</value>
61
                <value>classpath*:dnet-force-override.properties</value>
62
            </list>
63
        </property>
64
    </bean>
65

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

  
85
    <tx:annotation-driven transaction-manager="txManager"/>
86

  
87
    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
88
        <property name="dataSource" ref="repomanager.dataSource"/>
89
    </bean>
90

  
91
    <mvc:resources mapping="swagger-ui.html" location="classpath:/META-INF/resources/"/>
92
    <mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>
93
    <bean class="eu.dnetlib.repo.manager.service.config.SwaggerConfig"/>
94
</beans>
modules/uoa-repository-manager-service/trunk/src/main/webapp/WEB-INF/log4j.properties
1
log4j.rootLogger = WARN, R
2

  
3
log4j.logger.eu.dnetlib = DEBUG
4
log4j.logger.eu.dnetlib.clients.data.datasourcemanager.ws.Converter = FATAL
5
log4j.logger.org.springframework = DEBUG, S
6
log4j.additivity.org.springframework = false
7

  
8
log4j.logger.com.opensymphony.xwork2.ognl.OgnlValueStack = FATAL
9
log4j.logger.com.opensymphony.xwork2.ObjectFactory = FATAL
10

  
11
log4j.logger.eu.dnetlib.repo.manager=DEBUG
12

  
13
log4j.appender.R=org.apache.log4j.RollingFileAppender
14
#log4j.appender.R.File=/var/log/dnet/repo-manager/repo-manager-gui.log
15
log4j.appender.R.File=/tmp/repo-manager-service.log
16
log4j.appender.R.MaxFileSize=10MB
17
log4j.appender.R.MaxBackupIndex=10
18
log4j.appender.R.layout=org.apache.log4j.PatternLayout
19
log4j.appender.R.layout.ConversionPattern= %d %p %t [%c] - %m%n
20

  
21
log4j.appender.S=org.apache.log4j.RollingFileAppender
22
#log4j.appender.S.File=/var/log/dnet/repo-manager/repo-manager-gui-spring.log
23
log4j.appender.S.File=/tmp/repo-manager-service-spring.log
24
log4j.appender.S.MaxFileSize=10MB
25
log4j.appender.S.MaxBackupIndex=10
26
log4j.appender.S.layout=org.apache.log4j.PatternLayout
27
log4j.appender.S.layout.ConversionPattern= %d %p %t [%c] - %m%n
28

  
29

  
30
#org.apache.cxf.Logger=org.apache.cxf.common.logging.Log4jLogger
31
#
32
#log4j.rootLogger=INFO, CONSOLE
33
#log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
34
#log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
35
#log4j.appender.CONSOLE.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
36
#
37
#log4j.logger.eu.dnetlib.repo.manager=DEBUG
modules/uoa-repository-manager-service/trunk/src/main/webapp/WEB-INF/web.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
3
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd
5
http://xmlns.jcp.org/xml/ns/javaee "
6
         version="3.1">
7

  
8
    <context-param>
9
        <param-name>log4jConfigLocation</param-name>
10
        <param-value>/WEB-INF/log4j.properties</param-value>
11
    </context-param>
12
    <context-param>
13
        <param-name>log4jRefreshInterval</param-name>
14
        <param-value>1000</param-value>
15
    </context-param>
16
    <context-param>
17
        <param-name>log4jExposeWebAppRoot</param-name>
18
        <param-value>false</param-value>
19
    </context-param>
20
    <listener>
21
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
22
    </listener>
23

  
24

  
25
    <listener>
26
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
27
    </listener>
28

  
29
    <context-param>
30
        <param-name>contextConfigLocation</param-name>
31
        <param-value>/WEB-INF/applicationContext.xml
32
        </param-value>
33
    </context-param>
34

  
35

  
36
    <servlet>
37
        <servlet-name>spring</servlet-name>
38
        <servlet-class>
39
            org.springframework.web.servlet.DispatcherServlet
40
        </servlet-class>
41
        <load-on-startup>1</load-on-startup>
42
    </servlet>
43

  
44
    <servlet-mapping>
45
        <servlet-name>spring</servlet-name>
46
        <url-pattern>/</url-pattern>
47
    </servlet-mapping>
48

  
49
</web-app>
modules/uoa-repository-manager-service/trunk/src/main/webapp/WEB-INF/spring-servlet.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
3
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
             xmlns:beans="http://www.springframework.org/schema/beans"
5
             xmlns:task="http://www.springframework.org/schema/task"
6
             xmlns:mvc="http://www.springframework.org/schema/mvc"
7
             xmlns:context="http://www.springframework.org/schema/context"
8
             xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
9
		http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
10
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
11

  
12
    <context:property-placeholder location="classpath*:/eu/**/application.properties" />
13
    <context:annotation-config/>
14
    <context:component-scan base-package="eu.dnetlib.repo.manager.service.controllers"/>
15
    <mvc:annotation-driven/>
16
</beans:beans>
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/service/controllers/MonitorApiImpl.java
1
package eu.dnetlib.repo.manager.service.controllers;
2

  
3
import eu.dnetlib.api.functionality.ValidatorService;
4
import eu.dnetlib.api.functionality.ValidatorServiceException;
5
import eu.dnetlib.domain.functionality.validator.StoredJob;
6
import eu.dnetlib.repo.manager.shared.JobsOfUser;
7
import eu.dnetlib.repo.manager.shared.Constants;
8
import gr.uoa.di.driver.util.ServiceLocator;
9
import org.apache.log4j.Logger;
10
import org.json.JSONException;
11
import org.springframework.stereotype.Component;
12
import javax.annotation.Resource;
13

  
14
@Component
15
public class MonitorApiImpl implements MonitorApi {
16

  
17
    @Resource(name = "validatorServiceLocator")
18
    private ServiceLocator<ValidatorService> validatorServiceLocator;
19

  
20
    private ValidatorService getValidationService() {
21
        return this.validatorServiceLocator.getService();
22
    }
23

  
24
    public ServiceLocator<ValidatorService> getValidatorServiceLocator() {
25
        return validatorServiceLocator;
26
    }
27

  
28
    public void setValidatorServiceLocator(ServiceLocator<ValidatorService> validatorServiceLocator) {
29
        this.validatorServiceLocator = validatorServiceLocator;
30
    }
31

  
32

  
33
    private static final Logger LOGGER = Logger
34
            .getLogger(MonitorApiImpl.class);
35

  
36
    @Override
37
    public JobsOfUser getJobsOfUser(String user,
38
                                         String jobType,
39
                                         String offset,
40
                                         String limit,
41
                                         String dateFrom,
42
                                         String dateTo,
43
                                         String validationStatus,
44
                                         String includeJobsTotal) throws JSONException, ValidatorServiceException {
45

  
46
        LOGGER.debug("Getting jobs of user : " + user);
47
        JobsOfUser retJobs = new JobsOfUser();
48
        retJobs.setJobs(getValidationService().getStoredJobsNew(user, jobType, Integer.parseInt(offset),
49
                Integer.parseInt(limit), dateFrom, dateTo, validationStatus));
50
        if (Boolean.parseBoolean(includeJobsTotal)) {
51
            retJobs.setTotalJobs(this.getJobsTotalNumberOfUser(user, jobType, null));
52
            retJobs.setTotalJobsSuccessful(this.getJobsTotalNumberOfUser(user, jobType, Constants.VALIDATION_JOB_STATUS_SUCCESSFUL));
53
            retJobs.setTotalJobsFailed(this.getJobsTotalNumberOfUser(user, jobType, Constants.VALIDATION_JOB_STATUS_FAILED));
54
            retJobs.setTotalJobsOngoing(this.getJobsTotalNumberOfUser(user, jobType,Constants.VALIDATION_JOB_STATUS_ONGOING));
55
        }
56
        return retJobs;
57

  
58
    }
59

  
60
    private int getJobsTotalNumberOfUser(String user, String jobType, String validationStatus) throws ValidatorServiceException {
61
        return  getValidationService().getStoredJobsTotalNumberNew(user, jobType, validationStatus);
62
    }
63

  
64
    @Override
65
    public int getJobsOfUserPerValidationStatus(String user,
66
                                                String jobType,
67
                                                String validationStatus) throws JSONException {
68
        LOGGER.debug("Getting job with validation status : " + validationStatus);
69
        try {
70
            return getValidationService().getStoredJobsTotalNumberNew(user, jobType, validationStatus);
71
        } catch (ValidatorServiceException e) {
72
            e.printStackTrace();
73
        }
74
        return 0;
75
    }
76

  
77
    @Override
78
    public StoredJob getJobSummary(String jobId,
79
                                   String groupBy) throws JSONException {
80
        LOGGER.debug("Getting job summary with id : " + jobId);
81
        try {
82
            return getValidationService().getStoredJob(Integer.parseInt(jobId), groupBy);
83
        } catch (ValidatorServiceException e) {
84
            e.printStackTrace();
85
        }
86
        return null;
87
    }
88

  
89
}
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/service/controllers/RepositoryApi.java
1
package eu.dnetlib.repo.manager.service.controllers;
2

  
3
import eu.dnetlib.domain.data.Repository;
4
import eu.dnetlib.domain.data.RepositoryInterface;
5
import eu.dnetlib.repo.manager.shared.Aggregations;
6
import eu.dnetlib.repo.manager.shared.Country;
7
import eu.dnetlib.repo.manager.shared.Timezone;
8
import io.swagger.annotations.Api;
9
import org.json.JSONException;
10
import org.springframework.http.MediaType;
11
import org.springframework.web.bind.annotation.RequestMapping;
12
import org.springframework.web.bind.annotation.RequestMethod;
13
import org.springframework.web.bind.annotation.ResponseBody;
14
import org.springframework.web.bind.annotation.RestController;
15

  
16
import java.util.List;
17
import java.util.Map;
18

  
19

  
20
@RestController
21
@RequestMapping(value = "/repository")
22
@Api(description = "Repository API",  tags = {"repository"})
23
public interface RepositoryApi {
24
    
25
    @RequestMapping(value = "/testAggregations", method = RequestMethod.GET,
26
            produces = MediaType.APPLICATION_JSON_VALUE)
27
    @ResponseBody
28
    List<String> testAggregations() throws JSONException;
29

  
30
    @RequestMapping(value = "/getCountries", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
31
    @ResponseBody
32
    Country[] getCountries() ;
33

  
34
    @RequestMapping(value = "/getRepositoriesByCountry/{country}/{mode}", method = RequestMethod.GET,
35
            produces = MediaType.APPLICATION_JSON_VALUE)
36
    @ResponseBody
37
    List<Repository> getRepositoriesByCountry(String country,String mode) throws JSONException;
38

  
39
    @RequestMapping(value = "/getRepositoriesOfUser/{userEmail}/{page}/{size}",method = RequestMethod.GET,
40
            produces = MediaType.APPLICATION_JSON_VALUE)
41
    @ResponseBody
42
    List<Repository> getRepositoriesOfUser(String userEmail,
43
                                           String page,
44
                                           String size) throws JSONException;
45

  
46
    @RequestMapping(value = "/getRepositoryById/{id}", method = RequestMethod.GET,
47
            produces = MediaType.APPLICATION_JSON_VALUE)
48
    @ResponseBody
49
    Repository getRepositoryById(String id) throws JSONException;
50

  
51

  
52
    @RequestMapping(value = "/getRepositoryAggregations/{id}", method = RequestMethod.GET,
53
            produces = MediaType.APPLICATION_JSON_VALUE)
54
    @ResponseBody
55
    Aggregations getRepositoryAggregations(String id) throws JSONException;
56

  
57

  
58
    @RequestMapping(value = "/getRepositoriesByName/{name}/{page}/{size}/", method = RequestMethod.GET,
59
            produces = MediaType.APPLICATION_JSON_VALUE)
60
    @ResponseBody
61
    List<Repository> getRepositoriesByName(String name,
62
                                           String page,
63
                                           String size) throws JSONException;
64

  
65
    @RequestMapping(value = "/getRepositoryInterface/{id}", method = RequestMethod.GET,
66
            produces = MediaType.APPLICATION_JSON_VALUE)
67
    @ResponseBody
68
    List<RepositoryInterface> getRepositoryInterface(String id) throws JSONException;
69

  
70
    @RequestMapping(value = "/addRepository", method = RequestMethod.POST,
71
            consumes = MediaType.APPLICATION_JSON_VALUE)
72
    @ResponseBody
73
    void addRepository( String params) throws Exception;
74

  
75
    @RequestMapping(value = "/deleteInterface", method = RequestMethod.DELETE)
76
    @ResponseBody
77
    void deleteRepositoryInterface(String id);
78

  
79
    @RequestMapping(value = "/addInterface", method = RequestMethod.POST,
80
            consumes = MediaType.APPLICATION_JSON_VALUE)
81
    @ResponseBody
82
    RepositoryInterface addRepositoryInterface(String params) throws JSONException;
83

  
84
    @RequestMapping(value = "/getDnetCountries", method = RequestMethod.GET,
85
            produces = MediaType.APPLICATION_JSON_VALUE)
86
    @ResponseBody
87
    List<String> getDnetCountries();
88

  
89
    @RequestMapping(value = "/getTypologies", method = RequestMethod.GET,
90
            produces = MediaType.APPLICATION_JSON_VALUE)
91
    @ResponseBody
92
    List<String> getTypologies();
93

  
94
    @RequestMapping(value = "/getTimezones", method = RequestMethod.GET,
95
            produces = MediaType.APPLICATION_JSON_VALUE)
96
    @ResponseBody
97
    List<Timezone> getTimezones();
98

  
99
    @RequestMapping(value = "/updateManagedStatus", method = RequestMethod.POST,
100
            produces = MediaType.APPLICATION_JSON_VALUE)
101
    @ResponseBody
102
    String updateManagedStatus(String id, String managed);
103

  
104
    @RequestMapping(value = "/updateEnglishName", method = RequestMethod.POST,
105
            produces = MediaType.APPLICATION_JSON_VALUE)
106
    @ResponseBody
107
    String updateEnglishName(String id, String englishName);
108

  
109
    @RequestMapping(value = "/updateLatitude", method = RequestMethod.POST,
110
            produces = MediaType.APPLICATION_JSON_VALUE)
111
    @ResponseBody
112
    String updateLatitude(String id, String latitude);
113

  
114
    @RequestMapping(value = "/updateLongitude", method = RequestMethod.POST,
115
            produces = MediaType.APPLICATION_JSON_VALUE)
116
    @ResponseBody
117
    String updateLongitude(String id, String longitude);
118

  
119
    @RequestMapping(value = "/updateOfficialName", method = RequestMethod.POST,
120
            produces = MediaType.APPLICATION_JSON_VALUE)
121
    @ResponseBody
122
    String updateOfficialName(String id, String officialName);
123

  
124
    @RequestMapping(value = "/updateTimezone", method = RequestMethod.POST,
125
            produces = MediaType.APPLICATION_JSON_VALUE)
126
    @ResponseBody
127
    String updateTimezone(String id, String timezone);
128

  
129
    @RequestMapping(value = "/updateTypology", method = RequestMethod.POST,
130
            produces = MediaType.APPLICATION_JSON_VALUE)
131
    @ResponseBody
132
    String updateTypology(String id, String typology);
133

  
134
    @RequestMapping(value = "/updateLogoUrl", method = RequestMethod.POST,
135
            produces = MediaType.APPLICATION_JSON_VALUE)
136
    @ResponseBody
137
    String updateLogoUrl(String id, String logoUrl);
138

  
139
    @RequestMapping(value = "/updatePlatform", method = RequestMethod.POST,
140
            produces = MediaType.APPLICATION_JSON_VALUE)
141
    @ResponseBody
142
    String updatePlatform(String id, String platform);
143

  
144

  
145
    @RequestMapping(value = "/getUrlsOfUserRepos/{user_email}/{page}/{size}/",method = RequestMethod.GET,
146
            produces = MediaType.APPLICATION_JSON_VALUE)
147
    @ResponseBody
148
    List<String> getUrlsOfUserRepos(String user_email,
149
                                    String page,
150
                                    String size) throws JSONException;
151

  
152
    @RequestMapping(value = "/getDatasourceVocabularies/{mode}",method = RequestMethod.GET,
153
            produces = MediaType.APPLICATION_JSON_VALUE)
154
    @ResponseBody
155
    List<String> getDatasourceVocabularies(String mode);
156

  
157
    @RequestMapping(value = "/getCompatibilityClasses/{mode}",method = RequestMethod.GET,
158
            produces = MediaType.APPLICATION_JSON_VALUE)
159
    @ResponseBody
160
    Map<String, String> getCompatibilityClasses(String mode);
161

  
162
    @RequestMapping(value = "/getDatasourceClasses/{mode}",method = RequestMethod.GET,
163
            produces = MediaType.APPLICATION_JSON_VALUE)
164
    @ResponseBody
165
    Map<String, String> getDatasourceClasses(String mode);
166

  
167

  
168
    String getCountryName(String countryCode);
169
}
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/service/controllers/RepositoryApiImpl.java
1
package eu.dnetlib.repo.manager.service.controllers;
2

  
3
import com.fasterxml.jackson.databind.DeserializationFeature;
4
import com.fasterxml.jackson.databind.ObjectMapper;
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.repo.manager.service.utils.Converter;
9
import eu.dnetlib.repo.manager.shared.Aggregations;
10
import eu.dnetlib.repo.manager.shared.Constants;
11
import eu.dnetlib.repo.manager.shared.Country;
12
import eu.dnetlib.repo.manager.shared.Timezone;
13
import gr.uoa.di.driver.enabling.vocabulary.VocabularyLoader;
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.http.HttpEntity;
21
import org.springframework.http.HttpHeaders;
22
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
23
import org.springframework.stereotype.Component;
24
import org.springframework.web.bind.annotation.PathVariable;
25
import org.springframework.web.bind.annotation.RequestBody;
26
import org.springframework.web.bind.annotation.RequestParam;
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.text.Normalizer;
35
import java.util.*;
36
import java.util.concurrent.ConcurrentHashMap;
37

  
38
@Component
39
public class RepositoryApiImpl implements RepositoryApi {
40

  
41
    @Value("${api.baseAddress}")
42
    private String baseAddress;
43

  
44
    private RestTemplate restTemplate = null;
45

  
46
    private HttpHeaders httpHeaders;
47

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

  
50
    private static final Logger LOGGER = Logger.getLogger(RepositoryApiImpl.class);
51

  
52
    @Autowired
53
    private VocabularyLoader vocabularyLoader;
54

  
55
    private Map<String, Vocabulary> vocabularyMap = new ConcurrentHashMap<String, Vocabulary>();
56

  
57
    private Map<String, String> countriesMap = new HashMap<>();
58
    private Map<String, String> inverseCountriesMap = new HashMap<>();
59

  
60

  
61
    @PostConstruct
62
    private void init() {
63
        LOGGER.debug("Initialization method of repository api!");
64

  
65
        restTemplate = new RestTemplate();
66
        restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
67

  
68
        httpHeaders = new HttpHeaders();
69
        httpHeaders.set("Content-Type", "application/json");
70

  
71
        for (String vocName : vocabularyNames) {
72
            vocabularyMap.put(vocName, vocabularyLoader.getVocabulary(vocName, Locale.ENGLISH, Locale.ROOT));
73
        }
74

  
75
        Country[] countries = getCountries();
76
        for (Country c : countries) {
77
            countriesMap.put(c.getName(), c.getCode());
78
            inverseCountriesMap.put(c.getCode(), c.getName());
79
        }
80

  
81

  
82
    }
83

  
84
    @Override
85
    public List<String> testAggregations() throws JSONException {
86

  
87
        int page = 0;
88
        int size = 1000;
89

  
90
        UriComponents uriComponents = UriComponentsBuilder
91
                .fromHttpUrl(baseAddress + "/ds/list/")
92
                .path("/{page}/{size}/")
93
                .build().expand(page, size).encode();
94

  
95
        String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
96
        List<String> ids = new ArrayList<>();
97
        while (!rs.equals("[]")) {
98

  
99
            ids.addAll(getIdsWithNonEmptyAggregations(rs));
100

  
101
            LOGGER.debug("Checked " + (page + 1) * size + " records!");
102

  
103
            page += 1;
104
            uriComponents = UriComponentsBuilder
105
                    .fromHttpUrl(baseAddress + "/ds/list/")
106
                    .path("/{page}/{size}/")
107
                    .build().expand(page, size).encode();
108
            rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
109
        }
110

  
111
        return ids;
112
    }
113

  
114
    private List<String> getIdsWithNonEmptyAggregations(String rs) throws JSONException {
115

  
116
        JSONArray ids = new JSONArray(rs);
117
        List<String> agg_ids = new ArrayList<>();
118
        for (int i = 0; i < ids.length(); i++) {
119
            String id = ids.getString(i);
120
            Aggregations aggregations = getRepositoryAggregations(id);
121
            if (aggregations.getAggregationHistory() != null)
122
                agg_ids.add(id);
123
        }
124
        return agg_ids;
125
    }
126

  
127
    @Override
128
    public Country[] getCountries() {
129
        UriComponents uriComponents = UriComponentsBuilder
130
                .fromHttpUrl(baseAddress + "/ds/countries")
131
                .build().encode();
132
        return restTemplate.getForObject(uriComponents.toUri(), Country[].class);
133
    }
134

  
135

  
136
    @Override
137
    public List<Repository> getRepositoriesByCountry(@PathVariable("country") String country,
138
                                                     @PathVariable("mode") String mode) throws JSONException {
139

  
140
        LOGGER.debug("Getting repositories by country!");
141
        int page = 0;
142
        int size = 100;
143

  
144
        String countryCode = countriesMap.get(country);
145
        String filterKey = "UNKNOWN";
146
        if (mode.equalsIgnoreCase("opendoar")) {
147
            filterKey = "openaire____::opendoar";
148
        } else if (mode.equalsIgnoreCase("re3data")) {
149
            filterKey = "openaire____::re3data";
150
        } else if (mode.equalsIgnoreCase("jour_aggr")) {
151
            filterKey = "infrastruct_::openaire";
152
        }
153

  
154
        LOGGER.debug("Country code equals : " + countryCode);
155
        LOGGER.debug("Filter mode equals : " + filterKey);
156
        UriComponents uriComponents = UriComponentsBuilder
157
                .fromHttpUrl(baseAddress + "/ds/search/country/")
158
                .path("/{page}/{size}/")
159
                .queryParam("country", countryCode)
160
                .build().expand(page, size).encode();
161

  
162
        String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
163
        List<Repository> resultSet = new ArrayList<>();
164
        while (!rs.equals("[]")) {
165
            List<Repository> rep = Converter.jsonToRepositoryList(new JSONArray(rs));
166

  
167
            Collection<Repository> repos = this.getRepositoriesByMode(filterKey, rep);
168
            resultSet.addAll(repos);
169

  
170
            page += 1;
171
            uriComponents = UriComponentsBuilder
172
                    .fromHttpUrl(baseAddress + "/ds/search/country/")
173
                    .path("/{page}/{size}/")
174
                    .queryParam("country", countryCode)
175
                    .build().expand(page, size).encode();
176
            rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
177
        }
178
        for (Repository r : resultSet)
179
            r.setCountryName(getCountryName(r.getCountryCode()));
180
        return resultSet;
181
    }
182

  
183

  
184
    private Collection<Repository> getRepositoriesByMode(String mode, List<Repository> rs) {
185

  
186
        List<Repository> reps = new ArrayList<>();
187
        for (Repository r : rs) {
188
            if (r.getCollectedFrom().equals(mode))
189
                reps.add(r);
190
        }
191
        return reps;
192
    }
193

  
194
    @Override
195
    public List<Repository> getRepositoriesOfUser(@PathVariable("userEmail") String userEmail,
196
                                                  @PathVariable("page") String page,
197
                                                  @PathVariable("size") String size) throws JSONException {
198

  
199
        LOGGER.debug("Retreiving repositories of user : " + userEmail );
200
        UriComponents uriComponents = UriComponentsBuilder
201
                .fromHttpUrl(baseAddress + "/ds/search/registeredby/")
202
                .path("/{page}/{size}/")
203
                .queryParam("registeredBy", userEmail)
204
                .build().expand(page, size).encode();
205

  
206
        String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
207
        List<Repository> repos = Converter.jsonToRepositoryList(new JSONArray(rs));
208
        for (Repository r : repos){
209
            r.setInterfaces(this.getRepositoryInterface(r.getId()));
210
            r.setCountryName(getCountryName(r.getCountryCode()));
211
        }
212

  
213
        return repos;
214
    }
215

  
216
    @Override
217
    public Repository getRepositoryById(@PathVariable("id") String id) throws JSONException {
218

  
219
        UriComponents uriComponents = UriComponentsBuilder
220
                .fromHttpUrl(baseAddress + "/ds/get/")
221
                .path("/{id}/")
222
                .build().expand(id).encode();
223

  
224
        String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
225
        Repository repo = Converter.jsonToRepositoryObject(new JSONObject(rs));
226
        if (repo != null) {
227
            repo.setCountryName(getCountryName(repo.getCountryCode()));
228
            repo.setInterfaces(this.getRepositoryInterface(repo.getId()));
229
        }
230
        return repo;
231
    }
232

  
233

  
234
    @Override
235
    public Aggregations getRepositoryAggregations(@PathVariable("id") String id) throws JSONException {
236

  
237
        UriComponents uriComponents = UriComponentsBuilder
238
                .fromHttpUrl(baseAddress + "/ds/get/")
239
                .path("/{id}/")
240
                .build().expand(id).encode();
241

  
242
        String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
243
        JSONObject repository = new JSONObject(rs);
244

  
245
        Aggregations aggregations = new Aggregations();
246

  
247
        try {
248
            aggregations.setAggregationHistory(Converter.getAggregationHistoryFromJson(repository));
249
            aggregations.setLastCollection(Converter.getLastCollectionFromJson(repository));
250
            aggregations.setLastTransformation(Converter.getLastTransformationFromJson(repository));
251
            return aggregations;
252
        } catch (JSONException e) {
253
            LOGGER.debug("JSON aggregation exception ", e);
254
            throw e;
255
        }
256

  
257
    }
258

  
259
    @Override
260
    public List<Repository> getRepositoriesByName(@PathVariable("name") String name,
261
                                                  @PathVariable("page") String page,
262
                                                  @PathVariable("size") String size) throws JSONException {
263
        UriComponents uriComponents = UriComponentsBuilder
264
                .fromHttpUrl(baseAddress + "/ds/search/name/")
265
                .path("/{page}/{size}")
266
                .queryParam("name", name)
267
                .build().expand(page, size).encode();
268

  
269
        String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
270
        List<Repository> repos = Converter.jsonToRepositoryList(new JSONArray(rs));
271
        for (Repository r : repos){
272
           // r.setInterfaces(this.getRepositoryInterface(r.getId()));
273
            r.setCountryName(getCountryName(r.getCountryCode()));
274
        }
275
        return repos;
276
    }
277

  
278
    @Override
279
    public List<RepositoryInterface> getRepositoryInterface(@PathVariable("id") String id) throws JSONException {
280

  
281
        UriComponents uriComponents = UriComponentsBuilder
282
                .fromHttpUrl(baseAddress + "/ds/api/")
283
                .path("/{id}/")
284
                .build().expand(id).encode();
285

  
286
        String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
287
        return Converter.jsonToRepositoryInterfaceList(new JSONArray(rs));
288
    }
289

  
290
    @Override
291
    public void addRepository(@RequestBody String params) throws Exception {
292

  
293
        JSONObject json_params = new JSONObject(params);
294
        String datatype = json_params.getString("datatype");
295
        String json_repository = json_params.getString("repository");
296
        Repository repository = null;
297
        ObjectMapper mapper = new ObjectMapper();
298
        mapper.disable(DeserializationFeature.FAIL_ON_UNK‌​NOWN_PROPERTIES);
299
        try {
300
            LOGGER.debug("repository -> " + json_repository);
301
            repository = mapper.readValue(json_repository, Repository.class);
302
        } catch (Exception e) {
303
            LOGGER.debug("Error parsing repository ", e);
304
            throw  e;
305
        }
306

  
307
        repository = this.setRepositoryFeatures(datatype,repository);
308

  
309
        LOGGER.debug("storing " + datatype + " repository with id: " + repository.getId());
310
        if (!datatype.equalsIgnoreCase("opendoar") && !datatype.equalsIgnoreCase("re3data")) {
311
            if (datatype.equalsIgnoreCase("journal") || datatype.equalsIgnoreCase("aggregator")) {
312
                LOGGER.debug("looking if " + datatype + " " + repository.getOfficialName() + " is already in datasources");
313
                if (getRepositoryById(repository.getId()) != null) {
314
                    String retMessage = datatype + " '" + repository.getOfficialName() + "' is already in datasources.";
315
                    repository.getInterfaces().clear();
316
                    LOGGER.debug(retMessage);
317
                } else {
318
                    LOGGER.debug(datatype + " " + repository.getOfficialName() + " is not in datasources. Inserting..");
319
                    this.storeRepository(repository);
320
                }
321
            }
322
        } else {
323
            this.updateRegisteredByValue(repository.getId(),repository.getRegisteredBy());
324
        }
325

  
326
        LOGGER.debug("Inserting Interfaces");
327
        Iterator var11 = repository.getInterfaces().iterator();
328

  
329
        while (var11.hasNext()) {
330
            RepositoryInterface iFace = (RepositoryInterface) var11.next();
331
            if (!iFace.getBaseUrl().isEmpty() && !iFace.getDesiredCompatibilityLevel().isEmpty()) {
332
                if (iFace.getId() != null && !iFace.getId().isEmpty()) {
333
                    LOGGER.debug("updating iface..");
334
                    this.updateInterface(datatype,iFace);
335
                    LOGGER.debug("updated successfully");
336
                } else {
337
                    LOGGER.debug("adding new iface..");
338
                    this.registerRepositoryInterface(repository.getId(),iFace,datatype);
339
                }
340
            }
341
        }
342
    }
343

  
344
    private void updateRegisteredByValue(String id, String registeredBy) {
345

  
346
        LOGGER.debug("Updating registered by value with  : " + registeredBy );
347
        UriComponents uriComponents = UriComponentsBuilder
348
                .fromHttpUrl(baseAddress + "/ds/registeredby/")
349
                .queryParam("dsId",id)
350
                .queryParam("registeredBy", registeredBy)
351
                .build()
352
                .encode();
353

  
354
        restTemplate.postForObject(uriComponents.toUri(), null,String.class);
355
    }
356

  
357
    private Repository setRepositoryFeatures(String datatype, Repository repository) {
358

  
359
        //TODO update map
360
        repository.setCountryCode(countriesMap.get(repository.getCountryName()));
361

  
362
        repository.setActivationId(UUID.randomUUID().toString());
363
        // repo.setRegisteredBy((String) session.get(LocalVocabularies.loggedInField));
364

  
365
        if (datatype.equals("opendoar") || datatype.equals("re3data")) {
366
            repository.setProvenanceActionClass("sysimport:crosswalk:entityregistry");
367
        } else if (datatype.equals("journal")) {
368
            repository.setProvenanceActionClass("user:insert");
369
            repository.setCollectedFrom("infrastruct_::openaire");
370
            if (repository.getIssn() != null && repository.getIssn().length() == 0)
371
                repository.setIssn(com.unboundid.util.Base64.encode(repository.getOfficialName()).substring(0, 8));
372
            repository.setId("openaire____::issn" + repository.getIssn());
373
            repository.setNamespacePrefix("issn" + repository.getIssn());
374
        } else if (datatype.equals("aggregator")) {
375
            repository.setProvenanceActionClass("user:insert");
376
            repository.setCollectedFrom("infrastruct_::openaire");
377
            repository.setId("openaire____::" + com.unboundid.util.Base64.encode(repository.getOfficialName()));
378
            repository.setNamespacePrefix(Normalizer.normalize(repository.getOfficialName().toLowerCase().replace(" ", "_"), Normalizer.Form.NFD).replaceAll("[^a-zA-Z0-9]", ""));
379
            if (repository.getNamespacePrefix().length() > 12) {
380
                repository.setNamespacePrefix(repository.getNamespacePrefix().substring(0, 12));
381
            } else {
382
                while (repository.getNamespacePrefix().length() < 12)
383
                    repository.setNamespacePrefix(repository.getNamespacePrefix().concat("_"));
384
            }
385
        }
386
        return repository;
387
    }
388

  
389
    private void updateInterface(String datatype,RepositoryInterface iFace) {
390
        //TODO call update base url
391
        //((DatasourceManagerService) this.dmService.getService()).updateBaseUrl(repo.getId(), iFace.getId(), iFace.getBaseUrl());
392
        if (!iFace.getAccessSet().isEmpty()) {
393
            LOGGER.debug("set not empty: " + iFace.getAccessSet());
394
            //TODO call update method for access params
395
            // ((DatasourceManagerService) this.dmService.getService()).updateAccessParam(repo.getId(), iFace.getId(), "set", iFace.getAccessSet(), false);
396
        } else {
397
            //TODO call deleteAccessParamOrExtraField
398
            //((DatasourceManagerService) this.dmService.getService()).deleteAccessParamOrExtraField(repo.getId(), iFace.getId(), "set");
399
        }
400
        //TODO update content description
401
        //((DatasourceManagerService) this.dmService.getService()).updateContentDescription(repo.getId(), iFace.getId(), "metadata");
402
        if (datatype.equals("re3data")) {
403
            //TODO call update access params
404
            //  ((DatasourceManagerService) this.dmService.getService()).updateAccessParam(repo.getId(), iFace.getId(), "format", "oai_datacite", false);
405
            iFace.setAccessFormat("oai_datacite");
406
        } else {
407
            //TODO call update access params
408
            //((DatasourceManagerService) this.dmService.getService()).updateAccessParam(repo.getId(), iFace.getId(), "format", "oai_dc", false);
409
            iFace.setAccessFormat("oai_dc");
410
        }
411

  
412
    }
413

  
414
    private RepositoryInterface createRepositoryInterface(Repository repo, RepositoryInterface iFace, String datatype) {
415

  
416
        iFace.setContentDescription("metadata");
417
        iFace.setCompliance("UNKNOWN");
418
        if (datatype.equals("re3data")) {
419
            iFace.setAccessFormat("oai_datacite");
420
        } else {
421
            iFace.setAccessFormat("oai_dc");
422
        }
423

  
424
        if (repo.getDatasourceClass() != null && !repo.getDatasourceClass().isEmpty()) {
425
            iFace.setTypology(repo.getDatasourceClass());
426
        } else if (datatype.equalsIgnoreCase("journal")) {
427
            iFace.setTypology("pubsrepository::journal");
428
        } else if (datatype.equalsIgnoreCase("aggregator")) {
429
            iFace.setTypology("aggregator::pubsrepository::unknown");
430
        } else if (datatype.equalsIgnoreCase("opendoar")) {
431
            iFace.setTypology("pubsrepository::unknown");
432
        } else if (datatype.equalsIgnoreCase("re3data")) {
433
            iFace.setTypology("datarepository::unknown");
434
        }
435

  
436
        iFace.setRemovable(true);
437
        iFace.setAccessProtocol("oai");
438
        iFace.setMetadataIdentifierPath("//*[local-name()='header']/*[local-name()='identifier']");
439
       // iFace.setId("api_________::" + repo.getId() + "::" + UUID.randomUUID().toString().substring(0, 8));
440
        if (iFace.getAccessSet().isEmpty()) {
441
            LOGGER.debug("set is empty: " + iFace.getAccessSet());
442
            iFace.removeAccessSet();
443
        }
444
        return iFace;
445
    }
446

  
447
    private void storeRepository(Repository repository) throws JSONException {
448

  
449
        Date utilDate = new Date();
450
        Timestamp date = new Timestamp(utilDate.getTime());
451
        repository.setDateOfCollection(date);
452
        repository.setAggregator("OPENAIRE");
453

  
454
        UriComponents uriComponents = UriComponentsBuilder
455
                .fromHttpUrl(baseAddress + "/ds/add/")
456
                .build()
457
                .encode();
458
        String json_repository = Converter.repositoryObjectToJson(repository);
459
        HttpEntity<String> httpEntity = new HttpEntity <String> (json_repository,httpHeaders);
460
        restTemplate.postForObject(uriComponents.toUri(),httpEntity,String.class);
461
    }
462

  
463
    @Override
464
    public void deleteRepositoryInterface(@PathVariable("id") String id){
465
        UriComponents uriComponents = UriComponentsBuilder
466
                .fromHttpUrl(baseAddress + "/ds/api/")
467
                .path("/{id}/")
468
                .build().expand(id).encode();
469
        restTemplate.delete(uriComponents.toUri());
470
    }
471

  
472
    @Override
473
    public RepositoryInterface addRepositoryInterface(@RequestBody String params) throws JSONException {
474

  
475
        JSONObject json_params = new JSONObject(params);
476

  
477
        LOGGER.debug(params);
478
        //TODO iFace parameter from gui. Object to json
479
        String datatype = json_params.getString("datatype");
480
        String repoId = json_params.getString("repoId");
481
        String json_iFace = json_params.getString("iFace");
482
        RepositoryInterface iFace = null;
483

  
484
        ObjectMapper mapper = new ObjectMapper();
485
        try {
486
            iFace = mapper.readValue(json_iFace, RepositoryInterface.class);
487
        } catch (Exception e1) {
488
            LOGGER.debug("Error parsing repository interface ", e1);
489
        }
490

  
491
        return registerRepositoryInterface(repoId,iFace,datatype);
492
    }
493

  
494
    private RepositoryInterface registerRepositoryInterface(String repoId, RepositoryInterface iFace, String datatype) {
495
        Repository e = null;
496
        try {
497
            e = this.getRepositoryById(repoId);
498
            iFace = createRepositoryInterface(e,iFace,datatype);
499
            ObjectMapper mapper = new ObjectMapper();
500

  
501
            String json_interface = Converter.repositoryInterfaceObjectToJson(e,iFace);
502
            LOGGER.debug("iFace equals -> "  + json_interface);
503
            UriComponents uriComponents = UriComponentsBuilder
504
                    .fromHttpUrl(baseAddress + "/ds/api/add/")
505
                    .build()
506
                    .encode();
507

  
508

  
509
            HttpEntity<String> httpEntity = new HttpEntity <String> (json_interface,httpHeaders);
510
            restTemplate.postForObject(uriComponents.toUri(),httpEntity,String.class);
511
            return iFace;
512

  
513
        } catch (JSONException e1) {
514
            LOGGER.debug("Error parsing json ",e1);
515
        }
516
        return null;
517
    }
518

  
519
    @Override
520
    public List<String> getDnetCountries() {
521
        LOGGER.debug("Getting dnet-countries!");
522
        return Converter.readFile("countries.txt");
523
    }
524

  
525
    @Override
526
    public List<String> getTypologies() {
527
        return Converter.readFile("typologies.txt");
528
    }
529

  
530
    @Override
531
    public List<Timezone> getTimezones() {
532
        List<String> timezones =  Converter.readFile("timezones.txt");
533
        return Converter.toTimezones(timezones);
534
    }
535

  
536
    @Override
537
    public String updateManagedStatus(@RequestParam(value = "id")   String id,
538
                                      @RequestParam(value = "managed")  String managed) {
539

  
540
        UriComponents uriComponents = UriComponentsBuilder
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff