Skip to content

Commit

Permalink
Merge pull request #468 from OHDSI/release-1.17.1
Browse files Browse the repository at this point in the history
Release 1.17.1
  • Loading branch information
acumarav authored Apr 8, 2021
2 parents 9afbaff + bd3bd38 commit b7d357b
Show file tree
Hide file tree
Showing 29 changed files with 352 additions and 259 deletions.
26 changes: 11 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<artifactId>datanode</artifactId>
<groupId>com.odysseusinc.arachne</groupId>
<version>1.17.0</version>
<version>1.17.1</version>
<packaging>jar</packaging>


Expand All @@ -25,15 +25,16 @@
<start-class>com.odysseusinc.arachne.datanode.WebApplicationStarter</start-class>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<jjwt.version>0.10.5</jjwt.version>
<postgresql.version>42.2.1</postgresql.version>
<jjwt.version>0.10.8</jjwt.version>
<postgresql.version>42.2.15</postgresql.version>
<flywayVersion>4.2.0</flywayVersion>
<javaDockerVersion>3.2.6</javaDockerVersion>
<javaDockerVersion>3.2.7</javaDockerVersion>
<springRetryVersion>1.2.4.RELEASE</springRetryVersion>
<hikaricp.version>2.6.3</hikaricp.version>
<build.number>${BUILD_NUMBER}</build.number>
<build.id>${BUILD_TIMESTAMP}</build.id>
<dockerImagePrefix>hub.arachnenetwork.com</dockerImagePrefix>
<dockerImagePrefix>hub.odysseusinc.com</dockerImagePrefix>
<jackson.version>2.10.5.20201202</jackson.version>
<!-- Overrides SpringBoot defaults to conform Hydra -->
<json.version>20170516</json.version>
<feign.version>10.11</feign.version>
Expand Down Expand Up @@ -100,10 +101,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down Expand Up @@ -159,11 +156,10 @@
<artifactId>docker-java</artifactId>
<version>${javaDockerVersion}</version>
</dependency>

<dependency>
<groupId>org.springframework.statemachine</groupId>
<artifactId>spring-statemachine-core</artifactId>
<version>1.1.1.RELEASE</version>
<groupId>com.github.docker-java</groupId>
<artifactId>docker-java-transport-httpclient5</artifactId>
<version>${javaDockerVersion}</version>
</dependency>

<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
Expand Down Expand Up @@ -465,8 +461,8 @@
<include>${project.build.finalName}-exec.${project.packaging}</include>
</resource>
</resources>
<serverId>arachne-hub</serverId>
<registryUrl>https://hub.arachnenetwork.com/v2/</registryUrl>
<serverId>hub.odysseusinc.com</serverId>
<registryUrl>https://hub.odysseusinc.com/v2/</registryUrl>
</configuration>
<executions>
<execution>
Expand Down
4 changes: 2 additions & 2 deletions src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM hub.arachnenetwork.com/datanode_env:1.0.1
MAINTAINER alexandr.ryabokon@odysseusinc.com
FROM hub.odysseusinc.com/datanode_env:1.1.0
MAINTAINER alexandr.cumarav@odysseusinc.com
USER root
VOLUME /tmp
ADD datanode-exec.jar /datanode.jar
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package com.odysseusinc.arachne.datanode.config;

/*
*
* Copyright 2018 Odysseus Data Services, inc.
Expand All @@ -20,11 +22,7 @@
*
*/

package com.odysseusinc.arachne.datanode.config;

import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.core.DefaultDockerClientConfig;
import com.github.dockerjava.core.DockerClientBuilder;
import com.github.dockerjava.core.DockerClientConfig;
import com.odysseusinc.arachne.datanode.config.properties.DockerProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
Expand All @@ -33,21 +31,17 @@

@Configuration
@EnableConfigurationProperties(DockerProperties.class)
public class DockerClientConfiguration {

public class DockerConfig {
@Bean
public DockerClient dockerClient(DockerProperties properties) {
public DockerClientConfig dockerClient(DockerProperties properties) {

DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder()
return DefaultDockerClientConfig.createDefaultConfigBuilder()
.withDockerHost(properties.getHost())
.withDockerTlsVerify(properties.isTlsVerify())
.withDockerCertPath(properties.getCertPath())
.withRegistryUrl(properties.getRegistry().getHost())
.withRegistryUsername(properties.getRegistry().getUsername())
.withRegistryPassword(properties.getRegistry().getPassword())
.build();

return DockerClientBuilder.getInstance(config)
.build();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public class AuthController {
@Deprecated
public JsonResult<CommonAuthMethodDTO> authMethod() {

if (dataNodeService.getDataNodeMode() == FunctionalMode.NETWORK) {
if (dataNodeService.isNetworkMode()) {
return integrationService.getAuthMethod();
}
throw new BadRequestException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,8 @@ public JsonResult<List<DataSourceDTO>> list(
List<DataSourceDTO> dtos = dataSourceService.findAllNotDeleted(sortBy, sortAsc).stream()
.map(dataSource -> conversionService.convert(dataSource, DataSourceDTO.class))
.collect(Collectors.toList());
FunctionalMode mode = dataNodeService.getDataNodeMode();

if (!CollectionUtils.isEmpty(dtos) && Objects.equals(mode, FunctionalMode.NETWORK)) {
if (!CollectionUtils.isEmpty(dtos) && dataNodeService.isNetworkMode()) {
dtos = setFieldsFromCentral(getUser(principal), dtos);
}
result.setResult(dtos);
Expand Down Expand Up @@ -250,7 +249,7 @@ public JsonResult<DataSourceDTO> get(Principal principal, @PathVariable("id") Lo
JsonResult<DataSourceDTO> result = new JsonResult<>(NO_ERROR);
DataSource dataSource = dataSourceService.getById(id);
DataSourceDTO resultDTO = conversionService.convert(dataSource, DataSourceDTO.class);
if (Objects.equals(dataNodeService.getDataNodeMode(), FunctionalMode.NETWORK)) {
if (dataNodeService.isNetworkMode()) {
resultDTO = setFieldsFromCentral(getUser(principal), Collections.singletonList(resultDTO)).get(0);
}
result.setResult(resultDTO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
package com.odysseusinc.arachne.datanode.controller.admin;

import com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult;
import com.odysseusinc.arachne.commons.utils.UserIdUtils;
import com.odysseusinc.arachne.datanode.Constants;
import com.odysseusinc.arachne.datanode.controller.BaseController;
import com.odysseusinc.arachne.datanode.dto.submission.SubmissionDTO;
Expand All @@ -33,34 +32,34 @@
import com.odysseusinc.arachne.datanode.exception.PermissionDeniedException;
import com.odysseusinc.arachne.datanode.model.analysis.Analysis;
import com.odysseusinc.arachne.datanode.model.atlas.Atlas;
import com.odysseusinc.arachne.datanode.model.datanode.FunctionalMode;
import com.odysseusinc.arachne.datanode.model.user.User;
import com.odysseusinc.arachne.datanode.repository.AnalysisRepository;
import com.odysseusinc.arachne.datanode.service.AnalysisService;
import com.odysseusinc.arachne.datanode.service.AtlasService;
import com.odysseusinc.arachne.datanode.service.DataNodeService;
import com.odysseusinc.arachne.datanode.service.UserService;
import com.odysseusinc.arachne.datanode.service.events.user.UserDeletedEvent;
import io.swagger.annotations.ApiOperation;

import java.security.Principal;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

public abstract class BaseAdminController extends BaseController {
Expand Down Expand Up @@ -94,7 +93,7 @@ public BaseAdminController(
}

@ApiOperation(value = "Get all admins", hidden = true)
@RequestMapping(value = "/api/v1/admin/admins", method = RequestMethod.GET)
@GetMapping("/api/v1/admin/admins")
public JsonResult<List<UserDTO>> getAdmins(
@RequestParam(name = "sortBy", required = false) String sortBy,
@RequestParam(name = "sortAsc", required = false) Boolean sortAsc
Expand All @@ -111,7 +110,7 @@ public JsonResult<List<UserDTO>> getAdmins(
}

@ApiOperation("Suggests user according to query to add admin")
@RequestMapping(value = "/api/v1/admin/admins/suggest", method = RequestMethod.GET)
@GetMapping("/api/v1/admin/admins/suggest")
public JsonResult<List<UserDTO>> suggestAdmins(
Principal principal,
@RequestParam("query") String query,
Expand All @@ -132,25 +131,25 @@ public JsonResult<List<UserDTO>> suggestAdmins(
}

@ApiOperation("Remove admin")
@RequestMapping(value = "/api/v1/admin/admins/{username:.+}", method = RequestMethod.DELETE)
@DeleteMapping("/api/v1/admin/admins/{username:.+}")
public JsonResult removeAdmin(@PathVariable String username) {

userService.findByUsername(username).ifPresent(user -> userService.remove(user.getId()));
return new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
}

@ApiOperation("Add admin from central")
@RequestMapping(value = "/api/v1/admin/admins/{username:.+}", method = RequestMethod.POST)
@PostMapping("/api/v1/admin/admins/{username:.+}")
public JsonResult addAdminFromCentral(
Principal principal,
@PathVariable String username) {

JsonResult<UserDTO> result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
if (Objects.equals(dataNodeService.getDataNodeMode(), FunctionalMode.NETWORK)) {
if (dataNodeService.isNetworkMode()) {
userService
.findByUsername(principal.getName())
.ifPresent(loginedUser -> {
final User user = userService.addUserFromCentral(loginedUser, username);
.ifPresent(currentUser -> {
final User user = userService.addUserFromCentral(currentUser, username);
result.setResult(conversionService.convert(user, UserDTO.class));
});
} else {
Expand All @@ -160,7 +159,7 @@ public JsonResult addAdminFromCentral(
}

@ApiOperation("Check Atlas Connection")
@RequestMapping(value = "/api/v1/admin/atlases/{id}/connection", method = RequestMethod.POST)
@PostMapping("/api/v1/admin/atlases/{id}/connection")
public JsonResult checkAtlasConnection(@PathVariable("id") Long id) {

JsonResult result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
Expand All @@ -171,7 +170,7 @@ public JsonResult checkAtlasConnection(@PathVariable("id") Long id) {
}

@ApiOperation(value = "Invalidate all unfinished analyses")
@RequestMapping(value = Constants.Api.Analysis.INVALIDATE_ALL_UNFINISHED, method = RequestMethod.POST)
@PostMapping(Constants.Api.Analysis.INVALIDATE_ALL_UNFINISHED)
public Integer invalidateAllUnfinishedAnalyses(final Principal principal) throws PermissionDeniedException {

if (principal == null) {
Expand All @@ -182,7 +181,7 @@ public Integer invalidateAllUnfinishedAnalyses(final Principal principal) throws
}

@ApiOperation(value = "list submissions")
@RequestMapping(value = "/api/v1/admin/submissions", method = RequestMethod.GET)
@GetMapping("/api/v1/admin/submissions")
public Page<SubmissionDTO> list(@PageableDefault(value = DEFAULT_PAGE_SIZE, sort = "id",
direction = Sort.Direction.DESC) Pageable pageable) {

Expand All @@ -195,7 +194,7 @@ public Page<SubmissionDTO> list(@PageableDefault(value = DEFAULT_PAGE_SIZE, sort
Page<Analysis> analyses;
if (isFinishedSort(pageable)) {
analyses = analysisRepository.findAllPagedOrderByFinished(p);
} else if (isSubmittedSort(pageable)) {
} else if (isSubmittedSort(pageable)) {
analyses = analysisRepository.findAllPagedOrderBySubmitted(p);
} else if (isStatusSort(pageable)) {
analyses = analysisRepository.findAllPagedOrderByState(p);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
package com.odysseusinc.arachne.datanode.model.datanode.validation;

import com.odysseusinc.arachne.datanode.model.datanode.DataNode;
import com.odysseusinc.arachne.datanode.model.datanode.FunctionalMode;
import com.odysseusinc.arachne.datanode.service.DataNodeService;
import java.util.Objects;
import javax.validation.ConstraintValidator;
Expand All @@ -43,7 +42,7 @@ public void initialize(NonEmptyToken nonEmptyToken) {
@Override
public boolean isValid(DataNode dataNode, ConstraintValidatorContext context) {

if (FunctionalMode.NETWORK == dataNodeService.getDataNodeMode()) {
if (dataNodeService.isNetworkMode()) {
boolean valid = Objects.nonNull(dataNode) && StringUtils.isNotBlank(dataNode.getToken());
if (!valid) {
context.disableDefaultConstraintViolation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,19 @@
package com.odysseusinc.arachne.datanode.repository;

import com.odysseusinc.arachne.datanode.model.user.User;
import java.util.List;
import java.util.Optional;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
import java.util.Optional;

public interface UserRepository extends JpaRepository<User, Long> {

Optional<User> findOneByUsernameAndEnabled(String username, boolean enabled);
Optional<User> findOneByUsernameIgnoreCaseAndEnabled(String username, boolean enabled);

List<User> findAll(Sort sort);

Optional<User> findOneByUsername(String username);
Optional<User> findOneByUsernameIgnoreCase(String username);

List<User> findBySync(boolean isSync);
List<User> findBySyncAndEnabledIsTrue(boolean isSync);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import com.odysseusinc.arachne.datanode.model.datanode.DataNode;
import com.odysseusinc.arachne.datanode.model.datasource.DataSource;
import com.odysseusinc.arachne.datanode.model.user.User;
import com.odysseusinc.arachne.datanode.service.CentralIntegrationService;
import com.odysseusinc.arachne.datanode.service.DataNodeService;
import com.odysseusinc.arachne.datanode.service.DataSourceService;
import com.odysseusinc.arachne.datanode.service.UserRegistrationStrategy;
Expand All @@ -51,14 +51,17 @@ public class CentralScheduler {
private final DataSourceService dataSourceService;
@Value("${authenticator.user.registrationStrategy}")
private String userRegistrationStrategy;
private final CentralIntegrationService centralIntegrationService;

public CentralScheduler(DataNodeService dataNodeService,
UserService userService,
DataSourceService dataSourceService) {
DataSourceService dataSourceService,
CentralIntegrationService centralIntegrationService) {

this.dataNodeService = dataNodeService;
this.userService = userService;
this.dataSourceService = dataSourceService;
this.centralIntegrationService = centralIntegrationService;
}

@PostConstruct
Expand All @@ -74,20 +77,18 @@ public void checkRunMode() {

private void checkModeSwitching() {

List<User> users = userService.findStandaloneUsers();
if (users.size() > 0) {
throw new BeanInitializationException("Cannot switch mode from Standalone to Network - there are some users not linked to the Central.");
DataNode currentDataNode = dataNodeService.findCurrentDataNode().orElse(null);
if (currentDataNode != null && !userService.findStandaloneUsers().isEmpty()) {
centralIntegrationService.relinkUsersToDataNodeOnCentral(currentDataNode, userService.findStandaloneUsers());
}
List<DataSource> dataSources = dataSourceService.findStandaloneSources();
if (dataSources.size() > 0) {
throw new BeanInitializationException("Cannot switch mode from Standalone to Network - there are some data sources not linked to the Central.");
}

DataNode currentDataNode = dataNodeService.findCurrentDataNode().orElse(null);
if (currentDataNode != null && StringUtils.isEmpty(currentDataNode.getToken())) {
throw new BeanInitializationException("Cannot switch mode from Standalone to Network - Data node is not linked to the Central.");
}

}

private void warnUserRegistration() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ DTO sendDataSourceUpdateRequest(

void unlinkUserToDataNodeOnCentral(DataNode dataNode, User user);

List<User> relinkAllUsersToDataNodeOnCentral(DataNode dataNode, List<User> users);
void relinkUsersToDataNodeOnCentral(DataNode dataNode, List<User> users);

JsonResult<List<CommonStateProvinceDTO>> getStateProvinces(String countryId, String query, Integer limit, String includeId);

Expand Down
Loading

0 comments on commit b7d357b

Please sign in to comment.