Project

General

Profile

« Previous | Next » 

Revision 51140

updated to spring boot 2.0.0

View differences:

modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/dsm/dao/DatasourceDaoImpl.java
72 72
			throws DsmException {
73 73

  
74 74
		final Specification<DatasourceDbEntry> spec = dsSpec(requestSortBy, order, requestFilter);
75
		return dsRepository.findAll(spec, new PageRequest(page, size));
75
		return dsRepository.findAll(spec, PageRequest.of(page, size));
76 76
	}
77 77

  
78 78
	@Override
79 79
	public DatasourceDbEntry getDs(final String dsId) throws DsmException {
80
		return dsRepository.findOne(dsId);
80
		return dsRepository.getOne(dsId);
81 81
	}
82 82

  
83 83
	@Override
......
104 104

  
105 105
	@Override
106 106
	public void deleteApi(final String dsId, final String apiId) throws DsmException {
107
		final ApiDbEntry api = apiRepository.findOne(apiId);
107
		final ApiDbEntry api = apiRepository.getOne(apiId);
108 108
		if (!api.getRemovable()) {
109 109
			throw new DsmException(HttpStatus.SC_UNAUTHORIZED, "api is not removable");
110 110
		}
111 111

  
112
		apiRepository.delete(apiId);
112
		apiRepository.deleteById(apiId);
113 113
		log.info(String.format("deleted api '%s'", apiId));
114 114
	}
115 115

  
......
119 119
	}
120 120

  
121 121
	public boolean existDs(final String dsId) throws DsmException {
122
		return dsRepository.exists(dsId);
122
		return dsRepository.existsById(dsId);
123 123
	}
124 124

  
125 125
	@Override
......
131 131

  
132 132
	@Override
133 133
	public void deleteDs(final String dsId) {
134
		dsRepository.delete(dsId);
134
		dsRepository.deleteById(dsId);
135 135
		log.info(String.format("deleted datasource '%s'", dsId));
136 136
	}
137 137

  
......
158 158

  
159 159
	@Override
160 160
	public List<String> findApiBaseURLs(final RequestFilter requestFilter, final int page, final int size) throws DsmException {
161
		final PageRequest pageable = new PageRequest(page, size);
161
		final PageRequest pageable = PageRequest.of(page, size);
162 162
		final Specification<DatasourceApiDbEntry> spec = apiSpec(requestFilter);
163 163
		final Set<String> set = dsApiRepository.findAll(spec, pageable).getContent().stream()
164 164
				.map(DatasourceApiDbEntry::getBaseurl)
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetails.java
3 3
import java.sql.Date;
4 4
import java.util.Set;
5 5
import javax.persistence.Transient;
6
import javax.validation.constraints.Email;
7
import javax.validation.constraints.NotBlank;
6 8

  
7 9
import com.fasterxml.jackson.annotation.JsonAutoDetect;
8 10
import io.swagger.annotations.ApiModel;
9 11
import io.swagger.annotations.ApiModelProperty;
10
import org.hibernate.validator.constraints.Email;
11 12
import org.hibernate.validator.constraints.Length;
12
import org.hibernate.validator.constraints.NotBlank;
13 13

  
14 14
/**
15 15
 * Created by claudio on 12/09/16.
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/dsm/domain/DatasourceDetailsUpdate.java
1 1
package eu.dnetlib.openaire.dsm.domain;
2 2

  
3 3
import java.util.Set;
4
import javax.validation.constraints.Email;
5
import javax.validation.constraints.NotBlank;
4 6

  
5 7
import com.fasterxml.jackson.annotation.JsonAutoDetect;
6 8
import io.swagger.annotations.ApiModel;
7 9
import io.swagger.annotations.ApiModelProperty;
8
import org.hibernate.validator.constraints.Email;
9 10
import org.hibernate.validator.constraints.Length;
10
import org.hibernate.validator.constraints.NotBlank;
11 11

  
12 12
/**
13 13
 * Created by claudio on 12/09/16.
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/dsm/domain/OrganizationDetails.java
1 1
package eu.dnetlib.openaire.dsm.domain;
2 2

  
3
import javax.validation.constraints.NotBlank;
4

  
3 5
import com.fasterxml.jackson.annotation.JsonAutoDetect;
4 6
import io.swagger.annotations.ApiModel;
5 7
import io.swagger.annotations.ApiModelProperty;
6 8
import org.hibernate.validator.constraints.Length;
7
import org.hibernate.validator.constraints.NotBlank;
8 9

  
9 10
@JsonAutoDetect
10 11
@ApiModel(value = "Organization info model", description = "provides information about the organization")
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/funders/FunderDao.java
25 25
	}
26 26

  
27 27
	public List<FunderDetails> listFunderDetails(final int page, final int size) throws FundersApiException {
28
		return funderRepository.findAll(new PageRequest(page, size))
28
		return funderRepository.findAll(PageRequest.of(page, size))
29 29
				.getContent()
30 30
				.stream()
31 31
				.map(ConversionUtils::asFunderDetails)
......
33 33
	}
34 34

  
35 35
	public List<String> listFunderIds(final int page, final int size) throws FundersApiException {
36
		return funderRepository.findAll(new PageRequest(page, size))
36
		return funderRepository.findAll(PageRequest.of(page, size))
37 37
				.getContent()
38 38
				.stream()
39 39
				.map(f -> f.getId())
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/common/RFC3339DateFormat.java
1 1
package eu.dnetlib.openaire.common;
2 2

  
3 3
import java.text.FieldPosition;
4
import java.util.Date;
4
import java.util.*;
5 5

  
6
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
7
import com.fasterxml.jackson.databind.util.ISO8601Utils;
6
import com.fasterxml.jackson.databind.util.StdDateFormat;
8 7

  
9
public class RFC3339DateFormat extends ISO8601DateFormat {
8
public class RFC3339DateFormat extends StdDateFormat {
10 9

  
11
  // Same as ISO8601DateFormat but serializing milliseconds.
12
  @Override
13
  public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
14
    String value = ISO8601Utils.format(date, true);
15
    toAppendTo.append(value);
16
    return toAppendTo;
17
  }
10
	private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
18 11

  
12
	// Same as ISO8601DateFormat but serializing milliseconds.
13
	@Override
14
	public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
15
		String value = format(date, true, TIMEZONE_Z, Locale.US);
16
		toAppendTo.append(value);
17
		return toAppendTo;
18
	}
19

  
20
	/**
21
	 * Format date into yyyy-MM-ddThh:mm:ss[.sss][Z|[+-]hh:mm]
22
	 *
23
	 * @param date   the date to format
24
	 * @param millis true to include millis precision otherwise false
25
	 * @param tz     timezone to use for the formatting (UTC will produce 'Z')
26
	 * @return the date formatted as yyyy-MM-ddThh:mm:ss[.sss][Z|[+-]hh:mm]
27
	 */
28
	private static String format(Date date, boolean millis, TimeZone tz, Locale loc) {
29
		Calendar calendar = new GregorianCalendar(tz, loc);
30
		calendar.setTime(date);
31

  
32
		// estimate capacity of buffer as close as we can (yeah, that's pedantic ;)
33
		StringBuilder sb = new StringBuilder(30);
34
		sb.append(String.format(
35
				"%04d-%02d-%02dT%02d:%02d:%02d",
36
				calendar.get(Calendar.YEAR),
37
				calendar.get(Calendar.MONTH) + 1,
38
				calendar.get(Calendar.DAY_OF_MONTH),
39
				calendar.get(Calendar.HOUR_OF_DAY),
40
				calendar.get(Calendar.MINUTE),
41
				calendar.get(Calendar.SECOND)
42
		));
43
		if (millis) {
44
			sb.append(String.format(".%03d", calendar.get(Calendar.MILLISECOND)));
45
		}
46

  
47
		int offset = tz.getOffset(calendar.getTimeInMillis());
48
		if (offset != 0) {
49
			int hours = Math.abs((offset / (60 * 1000)) / 60);
50
			int minutes = Math.abs((offset / (60 * 1000)) % 60);
51
			sb.append(String.format("%c%02d:%02d",
52
					(offset < 0 ? '-' : '+'),
53
					hours, minutes));
54
		} else {
55
			sb.append('Z');
56
		}
57
		return sb.toString();
58
	}
59

  
19 60
}
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/common/GenericArrayUserType.java
4 4
import java.sql.*;
5 5

  
6 6
import org.hibernate.HibernateException;
7
import org.hibernate.engine.spi.SessionImplementor;
7
import org.hibernate.engine.spi.SharedSessionContractImplementor;
8 8
import org.hibernate.usertype.UserType;
9 9

  
10 10
/**
......
47 47
	}
48 48

  
49 49
	@Override
50
	public boolean isMutable() {
51
		return true;
52
	}
53

  
54
	@Override
55
	public Object nullSafeGet(ResultSet resultSet, String[] names, SessionImplementor session, Object owner)
50
	public Object nullSafeGet(final ResultSet resultSet,
51
			final String[] names,
52
			final SharedSessionContractImplementor sharedSessionContractImplementor,
53
			final Object o)
56 54
			throws HibernateException, SQLException {
57 55
		if (resultSet.wasNull()) {
58 56
			return null;
......
68 66
	}
69 67

  
70 68
	@Override
71
	public void nullSafeSet(PreparedStatement statement, Object value, int index, SessionImplementor session)
69
	public void nullSafeSet(final PreparedStatement statement,
70
			final Object value,
71
			final int index,
72
			final SharedSessionContractImplementor session)
72 73
			throws HibernateException, SQLException {
73 74
		Connection connection = statement.getConnection();
74 75
		if (value == null) {
......
82 83
	}
83 84

  
84 85
	@Override
86
	public boolean isMutable() {
87
		return true;
88
	}
89

  
90
	@Override
85 91
	public Object replace(Object original, Object target, Object owner) throws HibernateException {
86 92
		return original;
87 93
	}
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/metrics/WebMvcConfig.java
6 6
import org.springframework.context.annotation.Configuration;
7 7
import org.springframework.web.servlet.HandlerInterceptor;
8 8
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
9
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
9
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
10 10

  
11 11
@Configuration
12
public class WebMvcConfig extends WebMvcConfigurerAdapter {
12
public class WebMvcConfig implements WebMvcConfigurer {
13 13

  
14 14
	@Autowired
15 15
	private List<MetricInterceptor> interceptors;
......
23 23
					registry.addInterceptor(handlerInterceptor);
24 24
				});
25 25
	}
26

  
26 27
}
modules/dnet-openaire-exporter/trunk/src/main/resources/application.properties
1 1
# COMMON
2
server.contextPath                          =   /openaire
2
server.servlet.context-path                 =   /openaire
3 3
server.port                                 =   8080
4 4

  
5 5
spring.datasource.driverClassName           =   org.postgresql.Driver
6 6
spring.jpa.database-platform                =   org.hibernate.dialect.PostgreSQL9Dialect
7
spring.jpa.show-sql                         =   true
7
spring.jpa.show-sql                         =   false
8 8
spring.jpa.properties.hibernate.format_sql  =   true
9 9
spring.jpa.hibernate.ddl-auto               =   validate
10
#spring.mvc.dispatch-options-request         =   true
10 11

  
11 12
# SWAGGER
12 13
spring.jackson.date-format                              =   eu.dnetlib.openaire.common.RFC3339DateFormat
modules/dnet-openaire-exporter/trunk/pom.xml
3 3
	<modelVersion>4.0.0</modelVersion>
4 4
	<groupId>eu.dnetlib</groupId>
5 5
	<artifactId>dnet-openaire-exporter</artifactId>
6
	<version>1.0.9-SNAPSHOT</version>
6
	<version>1.1.0-SNAPSHOT</version>
7 7
	<scm>
8 8
	  <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-openaire-exporter/trunk</developerConnection>
9 9
    </scm>
......
24 24
	<parent>
25 25
		<groupId>org.springframework.boot</groupId>
26 26
		<artifactId>spring-boot-starter-parent</artifactId>
27
		<version>1.5.2.RELEASE</version>
27
		<version>2.0.0.RELEASE</version>
28 28
	</parent>
29 29

  
30 30
	<repositories>
......
175 175
			<dependency>
176 176
				<groupId>com.fasterxml.jackson.datatype</groupId>
177 177
				<artifactId>jackson-datatype-joda</artifactId>
178
				<version>2.6.6</version>
178
				<version>2.9.4</version>
179 179
			</dependency>
180 180
			<dependency>
181 181
				<groupId>joda-time</groupId>
......
405 405
					<executable>true</executable>
406 406
				</configuration>
407 407
			</plugin>
408
<!--
409
			<plugin>
410
				<groupId>com.spotify</groupId>
411
				<artifactId>dockerfile-maven-plugin</artifactId>
412
				<version>${dockerfile-maven-version}</version>
413
				<executions>
414
					<execution>
415
						<id>default</id>
416
						<goals>
417
							<goal>build</goal>
418
							<goal>push</goal>
419
						</goals>
420
					</execution>
421
				</executions>
422
				<configuration>
423
					<repository>spotify/foobar</repository>
424
					<tag>${project.version}</tag>
425
					<buildArgs>
426
						<JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
427
					</buildArgs>
428
				</configuration>
429
			</plugin>
430
-->
431 408
		</plugins>
432 409
	</build>
433 410

  

Also available in: Unified diff