Skip to content

Commit

Permalink
Merge pull request #434 from RADAR-base/release-2.4.0
Browse files Browse the repository at this point in the history
Release 2.4.0
  • Loading branch information
mpgxvii authored Oct 10, 2023
2 parents 25d53a8 + 7249224 commit ae21553
Show file tree
Hide file tree
Showing 26 changed files with 413 additions and 202 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,16 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- uses: actions/setup-java@v3
if: matrix.language == 'java'
with:
java-version: 17
distribution: temurin

- uses: gradle/gradle-build-action@v2
if: matrix.language == 'java'

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ bin/

docker/prod

*__pycache__
*__pycache__
google-credentials.json
7 changes: 3 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ apply plugin: 'io.spring.dependency-management'
apply plugin: 'scala'

group = 'org.radarbase'
version = '2.3.0'
version = '2.4.0'

java {
toolchain {
Expand All @@ -36,7 +36,7 @@ ext {
springBootVersion = '2.6.6'
springVersion = '6.0.6'
springOauth2Version = "2.5.1.RELEASE"
springDocVersion = '1.6.14'
springDocVersion = '2.2.0'
lombokVersion = '1.18.26'
junit5Version = '5.9.2'
radarSpringAuthVersion = '1.2.0'
Expand All @@ -57,7 +57,6 @@ sourceSets {

dependencies {
implementation('org.springframework.boot:spring-boot-starter-data-jpa')
implementation('org.springframework.boot:spring-boot-starter-data-rest')
implementation('org.springframework.boot:spring-boot-starter-web')
implementation('org.springframework.boot:spring-boot-starter-quartz')
implementation('org.springframework.boot:spring-boot-starter-security')
Expand All @@ -68,7 +67,7 @@ dependencies {
runtimeOnly("org.hibernate.validator:hibernate-validator:$hibernateValidatorVersion")

// Open API spec
implementation(group: 'org.springdoc', name: 'springdoc-openapi-ui', version: springDocVersion)
implementation(group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: springDocVersion)


//runtimeOnly('org.springframework.boot:spring-boot-devtools')
Expand Down
6 changes: 6 additions & 0 deletions src/integrationTest/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,9 @@ security.radar.managementportal.url=http://localhost:8081

# Github Authentication
security.github.client.token=
security.github.client.timeout=10
# max content size 1 MB
security.github.client.maxContentLength=1000000
security.github.cache.size=10000
security.github.cache.duration=3600
security.github.cache.retryDuration=60
2 changes: 1 addition & 1 deletion src/integrationTest/resources/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ services:
# Management Portal #
#---------------------------------------------------------------------------#
managementportal:
image: radarbase/management-portal:0.5.6
image: radarbase/management-portal:2.0.0
ports:
- "8081:8081"
environment:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
package org.radarbase.appserver.controller;

import org.radarbase.appserver.config.AuthConfig;
import org.radarbase.appserver.service.GithubClient;
import org.radarbase.appserver.service.GithubService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand All @@ -32,18 +32,17 @@
import org.springframework.web.bind.annotation.RestController;
import radar.spring.auth.common.Authorized;

import java.io.IOException;
import java.net.MalformedURLException;

@CrossOrigin
@RestController
public class GithubEndpoint {

private transient GithubClient githubClient;
private final transient GithubService githubService;

@Autowired
public GithubEndpoint(GithubClient githubClient) {
this.githubClient = githubClient;
public GithubEndpoint(GithubService githubService) {
this.githubService = githubService;
}

@Authorized(
Expand All @@ -53,13 +52,13 @@ public GithubEndpoint(GithubClient githubClient) {
PathsUtil.GITHUB_PATH
+ "/" +
PathsUtil.GITHUB_CONTENT_PATH)
public ResponseEntity getGithubContent(@RequestParam() String url
public ResponseEntity<String> getGithubContent(@RequestParam() String url
) {
try {
return ResponseEntity.ok().body(this.githubClient.getGithubContent(url));
return ResponseEntity.ok().body(this.githubService.getGithubContent(url));
} catch (MalformedURLException e) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getMessage());
} catch (IOException | InterruptedException e) {
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.BAD_GATEWAY).body("Error getting content from Github.");
}
}
Expand Down
31 changes: 22 additions & 9 deletions src/main/java/org/radarbase/appserver/entity/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,36 @@
package org.radarbase.appserver.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;

import java.io.Serializable;
import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import jakarta.persistence.*;
import jakarta.persistence.CascadeType;
import jakarta.persistence.CollectionTable;
import jakarta.persistence.Column;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.MapKeyColumn;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;

import lombok.Getter;
import lombok.ToString;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
import org.radarbase.appserver.dto.fcm.FcmUserDto;
import org.springframework.lang.Nullable;

import java.io.Serializable;
import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
* {@link Entity} for persisting users. The corresponding DTO is {@link FcmUserDto}. A {@link
* Project} can have multiple {@link User} (Many-to-One).
Expand Down Expand Up @@ -97,7 +110,7 @@ public class User extends AuditModel implements Serializable {
@CollectionTable(name = "attributes_map")
@MapKeyColumn(name = "key", nullable = true)
@Column(name = "value")
private Map<String, String> attributes = new HashMap<String, String>();
private Map<String, String> attributes = new HashMap<>();

public User setSubjectId(String subjectId) {
this.subjectId = subjectId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.radarbase.appserver.event.state.dto.DataMessageStateEventDto;
import org.radarbase.appserver.event.state.dto.NotificationStateEventDto;
import org.radarbase.appserver.service.DataMessageStateEventService;
import org.radarbase.appserver.service.NotificationStateEventService;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.event.TransactionalEventListener;

import java.util.Map;

@Slf4j
@Component
Expand All @@ -55,7 +59,9 @@ public MessageStateEventListener(ObjectMapper objectMapper,
*
* @param event the event to respond to
*/
@EventListener(value = NotificationStateEventDto.class)
@Transactional(propagation = Propagation.REQUIRES_NEW)
@TransactionalEventListener(classes = NotificationStateEventDto.class)
@Async
public void onNotificationStateChange(NotificationStateEventDto event) {
String info = convertMapToString(event.getAdditionalInfo());
log.debug("ID: {}, STATE: {}", event.getNotification().getId(), event.getState());
Expand All @@ -65,7 +71,9 @@ public void onNotificationStateChange(NotificationStateEventDto event) {
notificationStateEventService.addNotificationStateEvent(eventEntity);
}

@EventListener(value = DataMessageStateEventDto.class)
@Transactional(propagation = Propagation.REQUIRES_NEW)
@TransactionalEventListener(value = DataMessageStateEventDto.class)
@Async
public void onDataMessageStateChange(DataMessageStateEventDto event) {
String info = convertMapToString(event.getAdditionalInfo());
log.debug("ID: {}, STATE: {}", event.getDataMessage().getId(), event.getState());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.radarbase.appserver.event.state.dto.NotificationStateEventDto;
import org.radarbase.appserver.event.state.dto.TaskStateEventDto;
import org.radarbase.appserver.service.TaskStateEventService;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.event.TransactionalEventListener;

import java.util.Map;

Expand All @@ -51,7 +56,9 @@ public TaskStateEventListener(ObjectMapper objectMapper,
*
* @param event the event to respond to
*/
@EventListener(value = TaskStateEventDto.class)
@Transactional(propagation = Propagation.REQUIRES_NEW)
@TransactionalEventListener(classes = TaskStateEventDto.class)
@Async
public void onTaskStateChange(TaskStateEventDto event) {
String info = convertMapToString(event.getAdditionalInfo());
log.debug("ID: {}, STATE: {}", event.getTask().getId(), event.getState());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.NoArgsConstructor;
import net.minidev.json.annotate.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.radarbase.appserver.dto.fcm.FcmNotificationDto;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@
import java.util.Optional;
import org.radarbase.appserver.entity.DataMessage;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.stereotype.Repository;

/**
* @author yatharthranjan
*/
@Repository
@RepositoryRestResource(exported = false)
public interface DataMessageRepository extends JpaRepository<DataMessage, Long> {

List<DataMessage> findByUserId(Long userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@
import java.util.List;
import org.radarbase.appserver.entity.DataMessageStateEvent;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.stereotype.Repository;

@Repository
@RepositoryRestResource(exported = false)
public interface DataMessageStateEventRepository extends
JpaRepository<DataMessageStateEvent, Long> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@
import jakarta.validation.constraints.NotNull;
import org.radarbase.appserver.entity.Notification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.stereotype.Repository;

/** @author yatharthranjan */
@Repository
@RepositoryRestResource(exported = false)
public interface NotificationRepository extends JpaRepository<Notification, Long> {

List<Notification> findByUserId(Long userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@
import java.util.List;
import org.radarbase.appserver.entity.NotificationStateEvent;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.stereotype.Repository;

@Repository
@RepositoryRestResource(exported = false)
public interface NotificationStateEventRepository extends
JpaRepository<NotificationStateEvent, Long> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@
import java.util.Optional;
import org.radarbase.appserver.entity.Project;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.stereotype.Repository;

/** @author yatharthranjan */
@Repository
@RepositoryRestResource(exported = false)
public interface ProjectRepository extends JpaRepository<Project, Long> {

Optional<Project> findByProjectId(String projectId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@

import org.radarbase.appserver.entity.TaskStateEvent;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@RepositoryRestResource(exported = false)
public interface TaskStateEventRepository extends
JpaRepository<TaskStateEvent, Long> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@
import jakarta.validation.constraints.NotNull;
import org.radarbase.appserver.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.stereotype.Repository;

/** @author yatharthranjan */
@Repository
@RepositoryRestResource(exported = false)
public interface UserRepository extends JpaRepository<User, Long> {

Optional<User> findBySubjectId(String subjectId);
Expand Down
Loading

0 comments on commit ae21553

Please sign in to comment.