Skip to content

Commit

Permalink
Merge pull request #620 from overture-stack/rc/5.0.0
Browse files Browse the repository at this point in the history
Release 5.0.0
upgrade spring boot
upgrade spring cloud version
fix profiles
fix vault
update to new spring data page-able interface
  • Loading branch information
blabadi authored Jan 5, 2022
2 parents c5bbe9b + 8831029 commit bc906d5
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 40 deletions.
15 changes: 8 additions & 7 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ spec:
image: docker:18.06-dind
securityContext:
privileged: true
runAsUser: 0
volumeMounts:
- name: docker-graph-storage
mountPath: /var/lib/docker
Expand All @@ -35,14 +36,14 @@ spec:
- name: docker
image: docker:18-git
tty: true
volumeMounts:
- mountPath: /var/run/docker.sock
name: docker-sock
env:
- name: DOCKER_HOST
value: tcp://localhost:2375
- name: HOME
value: /home/jenkins/agent
securityContext:
runAsUser: 1000
volumes:
- name: docker-sock
hostPath:
path: /var/run/docker.sock
type: File
- name: docker-graph-storage
emptyDir: {}
"""
Expand Down
31 changes: 31 additions & 0 deletions docker-compose-all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: '3.7'
services:
api:
build:
context: ./
dockerfile: Dockerfile
restart: always
environment:
SERVER_PORT: 8080
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/ego?stringtype=unspecified
SPRING_DATASOURCE_USERNAME: postgres
SPRING_DATASOURCE_PASSWORD: password
SPRING_FLYWAY_ENABLED: "true"
SPRING_FLYWAY_LOCATIONS: "classpath:flyway/sql,classpath:db/migration"
SPRING_PROFILES: demo, auth
expose:
- "8080"
ports:
- "$API_HOST_PORT:8080"
depends_on:
- postgres
postgres:
image: postgres:12.6
restart: always
environment:
- POSTGRES_DB=ego
- POSTGRES_PASSWORD=password
expose:
- "5432"
ports:
- "8432:5432"
27 changes: 8 additions & 19 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
version: '3.7'
services:
api:
build:
context: ./
dockerfile: Dockerfile
restart: always
ego-ui:
image: overture/ego-ui:edge
network_mode: host
environment:
SERVER_PORT: 8080
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/ego?stringtype=unspecified
SPRING_DATASOURCE_USERNAME: postgres
SPRING_DATASOURCE_PASSWORD: password
SPRING_FLYWAY_ENABLED: "true"
SPRING_FLYWAY_LOCATIONS: "classpath:flyway/sql,classpath:db/migration"
SPRING_PROFILES: demo, auth
expose:
- "8080"
ports:
- "$API_HOST_PORT:8080"
depends_on:
- postgres
REACT_APP_API: http://localhost:8081
REACT_APP_EGO_CLIENT_ID: ego-ui

postgres:
image: postgres:12.6
restart: always
Expand All @@ -28,4 +16,5 @@ services:
expose:
- "5432"
ports:
- "8432:5432"
- "5432:5432"

18 changes: 14 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

<groupId>bio.overture</groupId>
<artifactId>ego</artifactId>
<version>4.5.2</version>
<version>5.0.0</version>

<name>ego</name>
<description>OAuth 2.0 Authorization service that supports multiple OpenID Connect Providers</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
<version>2.5.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand Down Expand Up @@ -87,6 +87,7 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
Expand All @@ -106,7 +107,10 @@
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-core</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<!-- JDBC -->
<dependency>
<groupId>com.h2database</groupId>
Expand Down Expand Up @@ -292,6 +296,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
Expand Down Expand Up @@ -416,7 +426,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Greenwich.SR2</version>
<version>2020.0.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public Sort getSort() {
// TODO: this is a hack for now to provide default sort on id field
// ideally we should not be making assumption about field name as "id" - it will break if
// field doesn't exist
return new Sort(direction, StringUtils.isEmpty(sort) ? "id" : sort);
return Sort.by(direction, StringUtils.isEmpty(sort) ? "id" : sort);
}

@Override
Expand All @@ -114,6 +114,11 @@ public Pageable first() {
return null;
}

@Override
public Pageable withPage(int pageNumber) {
throw new RuntimeException("Not implemented");
}

@Override
public boolean hasPrevious() {
return false;
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/bio/overture/ego/grpc/ProtoUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ public Pageable first() {
return null;
}

@Override
public Pageable withPage(int pageNumber) {
throw new RuntimeException("Not implemented");
}

@Override
public boolean hasPrevious() {
return false;
Expand All @@ -97,7 +102,7 @@ public boolean hasPrevious() {
public static Sort parseSort(String sort) {
if (sort.isEmpty()) {
// Sort results by creation time, ensure static order for the page_token to refer to
return new Sort(Sort.Direction.ASC, JavaFields.CREATEDAT);
return Sort.by(Sort.Direction.ASC, JavaFields.CREATEDAT);
} else {
val orders =
Arrays.stream(sort.split(","))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import static java.lang.String.format;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.NOT_FOUND;

import bio.overture.ego.utils.Joiners;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.ConstraintViolationException;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -17,6 +20,21 @@
@ControllerAdvice
public class ExceptionHandlers {

@ExceptionHandler(NotFoundException.class)
public ResponseEntity<Object> handleConstraintViolationException(
HttpServletRequest req, NotFoundException ex) {
val message = ex.getMessage();
log.error(message);
return new ResponseEntity<Object>(
Map.of(
"message", ex.getMessage(),
"timestamp", new Date(),
"path", req.getServletPath(),
"error", NOT_FOUND.getReasonPhrase()),
new HttpHeaders(),
NOT_FOUND);
}

@ExceptionHandler(ConstraintViolationException.class)
public ResponseEntity<Object> handleConstraintViolationException(
HttpServletRequest req, ConstraintViolationException ex) {
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/bio/overture/ego/utils/IgnoreCaseSortDecorator.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.springframework.util.StringUtils.isEmpty;

import java.util.Map;
import java.util.Optional;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.val;
Expand All @@ -29,11 +30,26 @@ public Sort getSort() {
return Sort.by(orders);
}

@Override
public Sort getSortOr(Sort sort) {
return delegate.getSortOr(sort);
}

private String getSortField(String sort) {
val mapValue = SORT_MAP.get(sort);
return isEmpty(mapValue) ? sort : mapValue;
}

@Override
public boolean isPaged() {
return delegate.isPaged();
}

@Override
public boolean isUnpaged() {
return delegate.isUnpaged();
}

/** Delegated methods */
@Override
public int getPageNumber() {
Expand Down Expand Up @@ -65,8 +81,18 @@ public Pageable first() {
return delegate.first();
}

@Override
public Pageable withPage(int pageNumber) {
return delegate.withPage(pageNumber);
}

@Override
public boolean hasPrevious() {
return delegate.hasPrevious();
}

@Override
public Optional<Pageable> toOptional() {
return Optional.of(delegate);
}
}
26 changes: 18 additions & 8 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,16 @@ spring.main.allow-bean-definition-overriding: true
spring.datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://localhost:5432/ego?stringtype=unspecified

username: postgres
password: password
max-active: 10
max-idle: 1
min-idle: 1

spring:
cloud:
vault:
enabled: false
flyway:
enabled: false
placeholders:
Expand Down Expand Up @@ -198,7 +200,9 @@ initialization:
# Profile - "jks"
###############################################################################
spring:
profiles: jks
config:
activate:
on-profile: jks

token:
key-store: src/main/resources/ego-jwt.jks
Expand All @@ -210,8 +214,9 @@ token:
# Profile - "auth"
###############################################################################
spring:
profiles: auth
profiles.include: secure
config:
activate:
on-profile: auth

# security
auth:
Expand All @@ -231,7 +236,9 @@ logging:
# Profile - "demo"
###############################################################################
spring:
profiles: grpc
config:
activate:
on-profile: grpc

grpc:
port: 50051
Expand All @@ -241,14 +248,17 @@ grpc:
# Profile - "demo"
###############################################################################
spring:
profiles: demo

config:
activate:
on-profile: demo
---
###############################################################################
# Profile - "test"
###############################################################################
spring:
profiles: test
config:
activate:
on-profile: test

# To log the httpRequests and httpResponses for the controllers, set to true
logging.test.controller.enable: false
Expand Down

0 comments on commit bc906d5

Please sign in to comment.