Project

General

Profile

« Previous | Next » 

Revision 51586

1. Add dependency for mails
2. Move preauthorize dependency to applicationContext

View differences:

modules/uoa-repository-manager-service/branches/dev-api/src/main/java/eu/dnetlib/repo/manager/service/controllers/RepositoryApi.java
7 7
import io.swagger.annotations.Api;
8 8
import org.json.JSONException;
9 9
import org.springframework.http.MediaType;
10
import org.springframework.security.access.prepost.PreAuthorize;
10 11
import org.springframework.web.bind.annotation.*;
11 12

  
12 13
import java.util.List;
......
17 18
@RequestMapping(value = "/repository")
18 19
@Api(description = "Repository API",  tags = {"repository"})
19 20
public interface RepositoryApi {
20
    
21
    @RequestMapping(value = "/testAggregations", method = RequestMethod.GET,
22
            produces = MediaType.APPLICATION_JSON_VALUE)
23
    @ResponseBody
24
    List<String> testAggregations() throws JSONException;
25 21

  
26 22
    @RequestMapping(value = "/getCountries", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
27 23
    @ResponseBody
modules/uoa-repository-manager-service/branches/dev-api/src/main/java/eu/dnetlib/repo/manager/service/controllers/UserApiImpl.java
35 35
        else
36 36
            body.put("name",authentication.getUserInfo().getName());
37 37

  
38
        for (GrantedAuthority authority : authentication.getAuthorities())
39
            LOGGER.debug("Role: " + authority.getAuthority());
40

  
41 38
        body.put("email",authentication.getUserInfo().getEmail());
42 39
        List<String> roles = authentication.getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList());
43 40
        body.put("role",roles);
modules/uoa-repository-manager-service/branches/dev-api/src/main/java/eu/dnetlib/repo/manager/service/controllers/RepositoryApiImpl.java
126 126
    }
127 127

  
128 128
    @Override
129
    public List<String> testAggregations() throws JSONException {
130

  
131
        int page = 0;
132
        int size = 1000;
133

  
134
        UriComponents uriComponents = UriComponentsBuilder
135
                .fromHttpUrl(baseAddress + "/ds/list/")
136
                .path("/{page}/{size}/")
137
                .build().expand(page, size).encode();
138

  
139
        String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
140
        List<String> ids = new ArrayList<>();
141
        while (!rs.equals("[]")) {
142

  
143
            ids.addAll(getIdsWithNonEmptyAggregations(rs));
144

  
145
            LOGGER.debug("Checked " + (page + 1) * size + " records!");
146

  
147
            page += 1;
148
            uriComponents = UriComponentsBuilder
149
                    .fromHttpUrl(baseAddress + "/ds/list/")
150
                    .path("/{page}/{size}/")
151
                    .build().expand(page, size).encode();
152
            rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
153
        }
154

  
155
        return ids;
156
    }
157

  
158
    private List<String> getIdsWithNonEmptyAggregations(String rs) throws JSONException {
159

  
160
        JSONArray ids = new JSONArray(rs);
161
        List<String> agg_ids = new ArrayList<>();
162
        for (int i = 0; i < ids.length(); i++) {
163
            String id = ids.getString(i);
164
            Aggregations aggregations = getRepositoryAggregations(id);
165
            if (aggregations.getAggregationHistory() != null)
166
                agg_ids.add(id);
167
        }
168
        return agg_ids;
169
    }
170

  
171
    @Override
172 129
    public Country[] getCountries() {
173 130
        UriComponents uriComponents = UriComponentsBuilder
174 131
                .fromHttpUrl(baseAddress + "/ds/countries")
......
348 305
                .build()
349 306
                .encode();
350 307
        String json_repository = Converter.repositoryObjectToJson(repository);
308

  
309
        LOGGER.debug(json_repository);
310

  
351 311
        HttpEntity<String> httpEntity = new HttpEntity <String> (json_repository,httpHeaders);
352 312
        restTemplate.postForObject(uriComponents.toUri(),httpEntity,String.class);
353 313
        return repository;
modules/uoa-repository-manager-service/branches/dev-api/src/main/webapp/WEB-INF/spring-servlet.xml
1 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:mvc="http://www.springframework.org/schema/mvc"
6
             xmlns:context="http://www.springframework.org/schema/context"
7
             xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
2
<beans xmlns="http://www.springframework.org/schema/beans"
3
       xmlns:mvc="http://www.springframework.org/schema/mvc"
4
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
       xmlns:context="http://www.springframework.org/schema/context"
6
       xmlns:security="http://www.springframework.org/schema/security"
7
       xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
8
		http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
9
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
10
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"
11
      >
8 12

  
9
		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">
13
    <security:global-method-security pre-post-annotations="enabled" proxy-target-class="true"
14
                                     authentication-manager-ref="authenticationManager">
15
    </security:global-method-security>
10 16

  
17
    <bean id="webexpressionHandler"
18
          class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler"/>
19

  
11 20
    <context:annotation-config/>
12 21
    <context:property-placeholder location="classpath*:/eu/**/application.properties" />
13 22
    <context:component-scan base-package="eu.dnetlib.repo.manager.service.controllers"/>
14 23
    <mvc:annotation-driven />
15 24

  
16
</beans:beans>
25
</beans>
modules/uoa-repository-manager-service/branches/dev-api/src/main/webapp/WEB-INF/applicationContext.xml
4 4
       xmlns:tx="http://www.springframework.org/schema/tx"
5 5
       xmlns:mvc="http://www.springframework.org/schema/mvc"
6 6
       xsi:schemaLocation="http://www.springframework.org/schema/beans
7

  
7 8
       http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
8 9
	http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
9 10
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
......
19 20
    <import resource="classpath*:/gr/uoa/di/driver/app/springContext-commons.xml"/>
20 21

  
21 22

  
23

  
22 24
    <bean id="maillib" class="eu.dnetlib.utils.MailLibrary" init-method="init">
23 25
        <property name="mailhost" value="${services.validator.mail.host}"/>
24 26
        <property name="smtpPort" value="${services.validator.mail.port}"/>
modules/uoa-repository-manager-service/branches/dev-api/src/main/webapp/WEB-INF/aai-security.xml
7 7
		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd"
8 8
       default-autowire="byType">
9 9

  
10

  
10 11
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
11 12
        <property name="maxUploadSize" value="268435456"/>
12 13
    </bean>
13 14

  
14
    <bean id="webexpressionHandler"
15
          class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler"/>
15
    <!--<bean id="webexpressionHandler"
16
          class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler"/>-->
16 17

  
17
    <security:global-method-security pre-post-annotations="enabled" proxy-target-class="true" authentication-manager-ref="authenticationManager"/>
18
   <!-- <security:global-method-security pre-post-annotations="enabled" proxy-target-class="true" authentication-manager-ref="authenticationManager"/>-->
18 19

  
19 20
    <security:http auto-config="false" use-expressions="true"
20 21
                   disable-url-rewriting="true" entry-point-ref="authenticationEntryPoint"
modules/uoa-repository-manager-service/branches/dev-api/pom.xml
155 155
        </dependency>
156 156

  
157 157
        <dependency>
158
            <groupId>com.sun.mail</groupId>
159
            <artifactId>javax.mail</artifactId>
160
            <version>1.6.0</version>
161
        </dependency>
162

  
163
        <dependency>
158 164
            <groupId>io.springfox</groupId>
159 165
            <artifactId>springfox-swagger2</artifactId>
160 166
            <version>2.7.0</version>

Also available in: Unified diff