Skip to content

Commit

Permalink
Release 1.16.2 (#431)
Browse files Browse the repository at this point in the history
* Release 1.16.2

Co-authored-by: Alex Cumarav <[email protected]>
Co-authored-by: Vitaly Koulakov <[email protected]>
Co-authored-by: Konstantin Iaroshovets <[email protected]>
Co-authored-by: molodkov yaroslav <[email protected]>
Co-authored-by: Anton Gackovka <[email protected]>
Co-authored-by: anastasiia klochkova <[email protected]>
Co-authored-by: OdysseusBot <[email protected]>
Co-authored-by: mpozhidaeva <[email protected]>
Co-authored-by: Pavel Grafkin <[email protected]>
Co-authored-by: Alexandr Ryabokon <[email protected]>
Co-authored-by: Anastasiia Klochkova <[email protected]>
Co-authored-by: Maria Pozhidaeva <[email protected]>
Co-authored-by: Sergey Suvorov <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: alexandr cumarav <https://localhost:8080/study-manager/studies/6>
  • Loading branch information
15 people authored Sep 11, 2020
1 parent 6644595 commit b314f92
Show file tree
Hide file tree
Showing 50 changed files with 1,015 additions and 572 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# ArachneNodeAPI
Arachne Data Node is a component that facilitates connection and communication between local databases and Arachne Central

## Instalation
### Prerequisites
For building and run the Data Node please install following applications:
- [Apache Maven 3](https://maven.apache.org/download.cgi)
- [JDK up to 8u241](https://www.oracle.com/java/technologies/javase/javase8u211-later-archive-downloads.html)
- [Postgres DBMS 9.6+](https://www.postgresql.org/download/)

## Running with Authenticator in a standalone mode

- Create database to store users (or use another authentication provided by Authenticator)
Expand Down
56 changes: 0 additions & 56 deletions build.sh

This file was deleted.

16 changes: 12 additions & 4 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.16.0</version>
<version>1.16.2</version>
<packaging>jar</packaging>


Expand Down Expand Up @@ -236,7 +236,7 @@
<dependency>
<groupId>org.ohdsi.sql</groupId>
<artifactId>SqlRender</artifactId>
<version>1.6.3</version>
<version>1.6.5</version>
</dependency>
<dependency>
<groupId>org.ohdsi</groupId>
Expand Down Expand Up @@ -309,7 +309,7 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.30</version>
<version>8.0.16</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.microsoft.sqlserver/sqljdbc4 -->
<dependency>
Expand All @@ -334,7 +334,11 @@
<artifactId>authenticator</artifactId>
<version>0.0.3-QA</version>
</dependency>

<dependency>
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-oauth2-http</artifactId>
<version>0.20.0</version>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -532,6 +536,10 @@
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
<testResource>
<directory>src/test/resources-binary</directory>
<filtering>false</filtering>
</testResource>
</testResources>
<finalName>datanode</finalName>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public interface Constants {
int PASSWORD_MIN_LENGTH = 6;
int PASSWORD_MAX_LENGTH = 100;
String DUMMY_PASSWORD = "password_was_set";
String DUMMY_KEYFILE = "Replace current keyfile";
String GOOGLE_AUTH_SCOPE = "https://www.googleapis.com/auth/userinfo.email";

interface AppConf {
String PROFILE_DEVELOPMENT = "dev";
Expand Down Expand Up @@ -65,9 +67,9 @@ interface User {
String PROFESSIONAL_TYPES = "/api/v1/user-management/professional-types";
String COUNTRIES = "/api/v1/user-management/countries/search";
String STATES_PROVINCES = "/api/v1/user-management/state-province/search";
String REGISTER_USER = "/api/v1/auth/registration";
String LOGOUT = "/api/v1/auth/logout";
String REGISTRATION = "/api/v1/auth/registration";
String REMIND_PASSWORD = "/api/v1/auth/remind-password";
String SUGGEST = "/api/v1/user-management/users/suggest";
String GET_USER = "/api/v1/user-management/users/byusername/{id}";
String LINK_TO_NODE = "/api/v1/user-management/datanodes/{datanodeId}/users";
Expand Down Expand Up @@ -159,6 +161,7 @@ interface AnalysisMessages {
}

interface Analysis {
String ERROR_REPORT_FILENAME = "errorReport.txt";
String SUBMISSION_ARCHIVE_SUBDIR = "archive";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ protected void configure(HttpSecurity http) throws Exception {
.antMatchers("/api/v1/user-management/countries/**").permitAll()
.antMatchers("/api/v1/user-management/state-province/**").permitAll()
.antMatchers("/api/v1/auth/registration**").permitAll()
.antMatchers("/api/v1/auth/remind-password/**").permitAll()
.antMatchers("/configuration/**").permitAll()
.antMatchers("/api/v1/submissions/**").permitAll()
.antMatchers("/admin-settings/**").permitAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,23 @@
import com.odysseusinc.arachne.datanode.service.DataNodeService;
import com.odysseusinc.arachne.datanode.util.DataNodeUtils;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.io.IOUtils;
import org.springframework.core.convert.ConversionService;
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.data.web.SortDefault;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Objects;

@RestController
public class AtlasController {
Expand Down Expand Up @@ -86,26 +92,39 @@ public AtlasDetailedDTO get(@PathVariable("id") Long id) {

@ApiOperation("Create new Atlas")
@RequestMapping(value = "/api/v1/atlases", method = POST)
public AtlasDetailedDTO save(@RequestBody AtlasDetailedDTO atlasDetailedDTO) {
public AtlasDetailedDTO save(@RequestPart("atlas") AtlasDetailedDTO atlasDetailedDTO,
@RequestPart(name = "keyfile", required = false) MultipartFile keyfile) throws IOException {

Atlas atlas = conversionService.convert(atlasDetailedDTO, Atlas.class);
initKeyfile(atlas, keyfile);
atlas = atlasService.save(atlas);
return conversionService.convert(atlas, AtlasDetailedDTO.class);
}

@ApiOperation("Update Atlas entity")
@RequestMapping(value = "/api/v1/atlases/{id}", method = PUT)
@RequestMapping(value = "/api/v1/atlases/{id}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE,
method = PUT)
public AtlasDetailedDTO update(
@PathVariable("id") Long id,
@RequestBody AtlasDetailedDTO atlasDetailedDTO
) {
@RequestPart(name = "atlas") AtlasDetailedDTO atlasDetailedDTO,
@RequestPart(name = "keyfile", required = false) MultipartFile keyfile
) throws IOException {

DataNodeUtils.requireNetworkMode(dataNodeService);
Atlas atlas = conversionService.convert(atlasDetailedDTO, Atlas.class);
initKeyfile(atlas, keyfile);
atlas = atlasService.update(id, atlas);
return conversionService.convert(atlas, AtlasDetailedDTO.class);
}

private void initKeyfile(Atlas atlas, MultipartFile keyfile) throws IOException {
if (Objects.nonNull(keyfile)) {
try (InputStream in = keyfile.getInputStream()) {
atlas.setKeyfile(IOUtils.toString(in, StandardCharsets.UTF_8));
}
}
}

@ApiOperation("Delete Atlas entity")
@RequestMapping(value = "/api/v1/atlases/{id}", method = DELETE)
public void delete(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

package com.odysseusinc.arachne.datanode.controller;

import static com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR;
import static com.odysseusinc.arachne.datanode.util.RestUtils.requireNetworkMode;
import static org.springframework.web.bind.annotation.RequestMethod.GET;

Expand All @@ -36,6 +37,7 @@
import com.odysseusinc.arachne.commons.api.v1.dto.CommonUserDTO;
import com.odysseusinc.arachne.commons.api.v1.dto.CommonUserRegistrationDTO;
import com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult;
import com.odysseusinc.arachne.datanode.dto.user.RemindPasswordDTO;
import com.odysseusinc.arachne.datanode.dto.user.UserInfoDTO;
import com.odysseusinc.arachne.datanode.exception.AuthException;
import com.odysseusinc.arachne.datanode.exception.BadRequestException;
Expand Down Expand Up @@ -63,6 +65,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.convert.ConversionService;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
Expand Down Expand Up @@ -250,4 +253,13 @@ public ArachnePasswordInfoDTO getPasswordPolicies() throws URISyntaxException {
requireNetworkMode(dataNodeService.getDataNodeMode());
return integrationService.getPasswordInfo();
}

@ApiOperation("Remind Password")
@PostMapping(value = "/api/v1/auth/remind-password")
public JsonResult remindPassword(@Valid @RequestBody RemindPasswordDTO remindPasswordDTO) {

requireNetworkMode(dataNodeService.getDataNodeMode());
integrationService.remindPassword(remindPasswordDTO);
return new JsonResult(NO_ERROR);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import static com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.SYSTEM_ERROR;
import static com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.UNAUTHORIZED;
import static com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.VALIDATION_ERROR;
import static com.odysseusinc.arachne.commons.utils.ErrorMessages.BAD_CREDENTIALS;
import static com.odysseusinc.arachne.commons.utils.ErrorMessages.USER_NOT_REGISTERED;
import static java.util.Arrays.asList;

import com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult;
Expand All @@ -45,6 +43,8 @@
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.ohdsi.authenticator.exception.AuthenticationException;
import org.ohdsi.authenticator.exception.BadCredentialsAuthenticationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -118,13 +118,36 @@ public ResponseEntity<JsonResult> exceptionHandler(IOException ex) {
@ExceptionHandler(AuthException.class)
public ResponseEntity<JsonResult> exceptionHandler(AuthException ex) {

return authExceptionHandler(ex);
}

@ExceptionHandler(org.springframework.security.core.AuthenticationException.class)
public ResponseEntity<JsonResult> exceptionHandler(org.springframework.security.core.AuthenticationException ex) {

return authExceptionHandler(ex);
}

@ExceptionHandler(BadCredentialsAuthenticationException.class)
public ResponseEntity<JsonResult> exceptionHandler(BadCredentialsAuthenticationException ex) {
return getErrorResponse(UNAUTHORIZED, ex);
}

@ExceptionHandler(AuthenticationException.class)
public ResponseEntity<JsonResult> exceptionHandler(AuthenticationException ex) {

return authExceptionHandler(ex);
}

public ResponseEntity<JsonResult> authExceptionHandler(Exception ex) {

JsonResult result = new JsonResult(UNAUTHORIZED);
result.setErrorMessage(ex.getMessage());
return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.body(result);
}


private ResponseEntity<JsonResult> getErrorResponse(JsonResult.ErrorCode errorCode, Exception ex) {

JsonResult result = new JsonResult<>(errorCode);
Expand All @@ -138,10 +161,8 @@ private ResponseEntity<JsonResult> getErrorResponse(final JsonResult result, fin

if (errorsTokenEnabled) {
final String errorToken = generateErrorToken();
LOGGER.error(message + " token: " + errorToken, ex);
result.setErrorMessage(String.format(ERROR_MESSAGE_WITH_TOKEN, errorToken));
} else if (asList(BAD_CREDENTIALS.getMessage().toLowerCase(), USER_NOT_REGISTERED.getMessage().toLowerCase()).contains(message.toLowerCase())) {
LOGGER.error(message);
LOGGER.error("{}. error-token: {}", message, errorToken, ex);
} else {
LOGGER.error(message, ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

package com.odysseusinc.arachne.datanode.controller.analysis;

import com.odysseusinc.arachne.datanode.service.AnalysisResultsService;
import com.odysseusinc.arachne.datanode.service.AnalysisService;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -30,8 +31,9 @@
public class AnalysisCallbackController extends BaseCallbackAnalysisController {

public AnalysisCallbackController(GenericConversionService conversionService,
AnalysisService analysisService) {
AnalysisService analysisService,
AnalysisResultsService analysisResultsService) {

super(conversionService, analysisService);
super(conversionService, analysisService, analysisResultsService);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.odysseusinc.arachne.datanode.model.analysis.AnalysisFile;
import com.odysseusinc.arachne.datanode.model.analysis.AnalysisOrigin;
import com.odysseusinc.arachne.datanode.model.user.User;
import com.odysseusinc.arachne.datanode.service.AnalysisResultsService;
import com.odysseusinc.arachne.datanode.service.AnalysisService;
import com.odysseusinc.arachne.datanode.service.UserService;
import java.io.FileInputStream;
Expand All @@ -51,6 +52,7 @@
import java.util.stream.Stream;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
Expand All @@ -72,15 +74,18 @@ public class AnalysisController {
private static final Logger logger = LoggerFactory.getLogger(AnalysisController.class);
private static final String ERROR_MESSAGE = "Failed to save analysis files";
private final AnalysisService analysisService;
private final AnalysisResultsService analysisResultsService;
private final UserService userService;

private final GenericConversionService conversionService;

public AnalysisController(AnalysisService analysisService,
AnalysisResultsService analysisResultsService,
UserService userService,
GenericConversionService conversionService) {

this.analysisService = analysisService;
this.analysisResultsService = analysisResultsService;
this.userService = userService;
this.conversionService = conversionService;
}
Expand Down Expand Up @@ -121,7 +126,7 @@ public void downloadResults(@PathVariable("id") Long analysisId, HttpServletResp

Analysis analysis = analysisService.findAnalysis(analysisId)
.orElseThrow(() -> new NotExistException(Analysis.class));
List<AnalysisFile> resultFiles = analysisService.getAnalysisResults(analysis);
List<AnalysisFile> resultFiles = analysisResultsService.getAnalysisResults(analysis);
Path stdoutDir = Files.createTempDirectory("node_analysis");
Path stdoutFile = stdoutDir.resolve("stdout.txt");
try(Writer writer = new FileWriter(stdoutFile.toFile())) {
Expand Down
Loading

0 comments on commit b314f92

Please sign in to comment.