Revision 49931
Added by Panagiotis Kanakakis over 6 years ago
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/config/SwaggerConfig.java | ||
---|---|---|
1 |
package eu.dnetlib.repo.manager.service.config; |
|
2 |
|
|
3 |
import org.springframework.context.annotation.Bean; |
|
4 |
import org.springframework.context.annotation.Configuration; |
|
5 |
import org.springframework.web.servlet.config.annotation.EnableWebMvc; |
|
6 |
import springfox.documentation.builders.RequestHandlerSelectors; |
|
7 |
import springfox.documentation.service.ApiInfo; |
|
8 |
import springfox.documentation.service.Contact; |
|
9 |
import springfox.documentation.service.VendorExtension; |
|
10 |
import springfox.documentation.spi.DocumentationType; |
|
11 |
import springfox.documentation.spring.web.plugins.Docket; |
|
12 |
import springfox.documentation.swagger2.annotations.EnableSwagger2; |
|
13 |
|
|
14 |
import java.util.ArrayList; |
|
15 |
|
|
16 |
import static springfox.documentation.builders.PathSelectors.regex; |
|
17 |
|
|
18 |
/** |
|
19 |
* Created by panagiotis on 16/11/2017. |
|
20 |
*/ |
|
21 |
@Configuration |
|
22 |
@EnableSwagger2 |
|
23 |
@EnableWebMvc |
|
24 |
public class SwaggerConfig { |
|
25 |
|
|
26 |
@Bean |
|
27 |
public Docket productApi() { |
|
28 |
return new Docket(DocumentationType.SWAGGER_2) |
|
29 |
.apiInfo(getApiInfo()) |
|
30 |
.select() |
|
31 |
.apis(RequestHandlerSelectors.basePackage("eu.dnetlib.repo.manager.service.controllers")) |
|
32 |
.paths(regex("/repository.*")) |
|
33 |
.build(); |
|
34 |
} |
|
35 |
|
|
36 |
private ApiInfo getApiInfo() { |
|
37 |
return new ApiInfo("REST Api Documentation", |
|
38 |
"REST Api Documentation", |
|
39 |
"1.0", |
|
40 |
"urn:tos", |
|
41 |
new Contact("", "", ""), |
|
42 |
"Apache 2.0", "http://www.apache.org/licenses/LICENSE-2.0", |
|
43 |
new ArrayList<VendorExtension>()); |
|
44 |
} |
|
45 |
|
|
46 |
} |
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/controllers/PiWikApiImpl.java | ||
---|---|---|
33 | 33 |
|
34 | 34 |
private final static String GET_PIWIK_SITES = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, validated, validationdate, comment, repositoryname, country from piwik_site order by repositoryname"; |
35 | 35 |
|
36 |
private final static String APPROVE_PIWIK_SITE = "update piwik_site set approved=true, approvaldate=now() where repositoryid = ?;";
|
|
36 |
private final static String APPROVE_PIWIK_SITE = "update piwik_site set validated=true, validationdate=now() where repositoryid = ?;";
|
|
37 | 37 |
|
38 | 38 |
|
39 | 39 |
private RowMapper<PiwikInfo> piwikRowMapper = (rs, i) -> new PiwikInfo(rs.getString("repositoryid"), getOpenaireId(rs.getString("repositoryid")), rs.getString("repositoryname"), rs.getString("country"), |
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/controllers/BrokerApiImpl.java | ||
---|---|---|
21 | 21 |
import org.springframework.web.client.RestClientException; |
22 | 22 |
import org.springframework.web.client.RestTemplate; |
23 | 23 |
import org.springframework.web.util.UriComponentsBuilder; |
24 |
import sun.reflect.generics.reflectiveObjects.LazyReflectiveObjectGenerator; |
|
24 | 25 |
|
25 | 26 |
import java.io.IOException; |
26 | 27 |
import java.util.*; |
... | ... | |
239 | 240 |
new ParameterizedTypeReference<Map<String, List<SimpleSubscriptionDesc>>>() { |
240 | 241 |
}); |
241 | 242 |
} catch (RestClientException e) { |
243 |
LOGGER.debug("Error " , e); |
|
242 | 244 |
throw new BrokerException(e); |
243 | 245 |
} |
244 |
|
|
245 | 246 |
return resp.getBody(); |
246 | 247 |
} |
247 | 248 |
|
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/controllers/RepositoryApi.java | ||
---|---|---|
123 | 123 |
@ResponseBody |
124 | 124 |
String updateTypology(String id, String typology); |
125 | 125 |
|
126 |
@RequestMapping(value = "/updateTypology", method = RequestMethod.POST,
|
|
126 |
@RequestMapping(value = "/updateLogoUrl", method = RequestMethod.POST,
|
|
127 | 127 |
produces = MediaType.APPLICATION_JSON_VALUE) |
128 | 128 |
@ResponseBody |
129 | 129 |
String updateLogoUrl(String id, String logoUrl); |
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/controllers/RepositoryApiImpl.java | ||
---|---|---|
68 | 68 |
@Override |
69 | 69 |
public Aggregations testAggregations() throws JSONException { |
70 | 70 |
|
71 |
int page = 1;
|
|
71 |
int page = 0;
|
|
72 | 72 |
int size = 1000; |
73 | 73 |
|
74 | 74 |
UriComponents uriComponents = UriComponentsBuilder |
... | ... | |
126 | 126 |
int size = 100; |
127 | 127 |
|
128 | 128 |
String countryCode = countriesMap.get(country); |
129 |
countryCode = "GR"; |
|
130 | 129 |
String filterKey = "UNKNOWN"; |
131 | 130 |
if(mode.equalsIgnoreCase("opendoar")) { |
132 | 131 |
filterKey = "openaire____::opendoar"; |
... | ... | |
161 | 160 |
rs = restTemplate.getForObject(uriComponents.toUri(), String.class); |
162 | 161 |
} |
163 | 162 |
for(Repository r : resultSet) |
164 |
r.setCountryName("Greece"); |
|
165 |
// r.setCountryName(getCountryName(r.getCountryCode())); |
|
163 |
r.setCountryName(getCountryName(r.getCountryCode())); |
|
166 | 164 |
return resultSet; |
167 | 165 |
} |
168 | 166 |
|
modules/uoa-repository-manager-service/src/main/resources/application-context.xml | ||
---|---|---|
3 | 3 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" |
4 | 4 |
xmlns:context="http://www.springframework.org/schema/context" |
5 | 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 http://www.springframework.org/schema/beans/spring-beans-4.0.xsd |
|
7 |
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> |
|
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"> |
|
8 | 11 |
|
9 | 12 |
<import resource="classpath:META-INF/cxf/cxf.xml"/> |
10 |
<!-- <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>-->
|
|
13 |
<!--<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>-->
|
|
11 | 14 |
<import resource="classpath:META-INF/cxf/cxf-extension-jaxws.xml"/> |
12 | 15 |
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/> |
13 | 16 |
<import resource="classpath*:/cxf.xml"/> |
... | ... | |
22 | 25 |
<import resource="classpath*:/gr/uoa/di/driver/app/springContext-commons.xml"/> |
23 | 26 |
<import resource="classpath*:/gr/uoa/di/driver/app/springContext-registrator.xml"/> |
24 | 27 |
<import resource="classpath*:/eu/dnetlib/repos/springContext-repos-dms-cached.xml"/> |
25 |
|
|
26 | 28 |
<context:property-placeholder location="classpath*:/eu/**/application.properties" /> |
27 | 29 |
<tx:annotation-driven transaction-manager="txManager"/> |
28 | 30 |
|
... | ... | |
78 | 80 |
<property name="dataSource" ref="repomanager.dataSource"/> |
79 | 81 |
</bean> |
80 | 82 |
|
81 |
|
|
82 | 83 |
</beans> |
modules/uoa-repository-manager-service/src/main/webapp/WEB-INF/applicationContext.xml | ||
---|---|---|
2 | 2 |
<beans xmlns="http://www.springframework.org/schema/beans" |
3 | 3 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
4 | 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 http://www.springframework.org/schema/beans/spring-beans.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"> |
|
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"> |
|
6 | 12 |
|
7 | 13 |
<import resource="classpath*:/application-context.xml"/> |
8 | 14 |
|
... | ... | |
81 | 87 |
<property name="dataSource" ref="repomanager.dataSource"/> |
82 | 88 |
</bean> |
83 | 89 |
|
90 |
<mvc:resources mapping="swagger-ui.html" location="classpath:/META-INF/resources/"/> |
|
91 |
<mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/> |
|
92 |
<bean class="eu.dnetlib.repo.manager.service.config.SwaggerConfig"/> |
|
93 |
|
|
84 | 94 |
</beans> |
modules/uoa-repository-manager-service/pom.xml | ||
---|---|---|
205 | 205 |
<artifactId>json</artifactId> |
206 | 206 |
<version>20080701</version> |
207 | 207 |
</dependency> |
208 |
|
|
209 |
<dependency> |
|
210 |
<groupId>io.springfox</groupId> |
|
211 |
<artifactId>springfox-swagger2</artifactId> |
|
212 |
<version>2.7.0</version> |
|
213 |
</dependency> |
|
214 |
<dependency> |
|
215 |
<groupId>io.springfox</groupId> |
|
216 |
<artifactId>springfox-swagger-ui</artifactId> |
|
217 |
<version>2.7.0</version> |
|
218 |
</dependency> |
|
219 |
|
|
208 | 220 |
</dependencies> |
209 | 221 |
|
210 | 222 |
|
Also available in: Unified diff
1. Update pom.xml with swagger dep.
2. Change pagination numbers.
3. Add swagger config file.
4. Change piwik queries with new database collumns.