Skip to content

Commit

Permalink
Merge pull request #953 from qbicsoftware/development
Browse files Browse the repository at this point in the history
Release PR
  • Loading branch information
KochTobi authored Dec 17, 2024
2 parents 082788a + e70a389 commit 1f71890
Show file tree
Hide file tree
Showing 72 changed files with 1,527 additions and 2,488 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: SonarCloud Analysis

# Run this workflow on commits to the development branch
on:
push:
branches:
- development
pull_request:
branches:
- development
- main
jobs:
sonarcloud:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Load local Maven repository cache
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# Build the project using Maven
- name: Build with Maven
run: mvn clean install

# Run SonarCloud analysis
- name: SonarCloud Scan
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Use the token stored in GitHub secrets
run: mvn sonar:sonar

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
public class ProjectManagementEmailServiceProvider implements EmailService {

private static final Logger log = logger(ProjectManagementEmailServiceProvider.class);
public static final String EMAIL_SUBMISSION_FAILED = "Email submission failed";

private final EmailServiceProvider emailServiceProvider;

Expand All @@ -39,7 +40,7 @@ public void send(Subject subject, Recipient recipient, Content content)
MessageTranslator.translate(content));
} catch (EmailSubmissionException e) {
log.error("Email submission failed!", e);
throw new CommunicationException("Email submission failed");
throw new CommunicationException(EMAIL_SUBMISSION_FAILED);
}
}

Expand All @@ -50,8 +51,8 @@ public void send(Subject subject, Recipient recipient, Content content, Attachme
emailServiceProvider.send(MessageTranslator.translate(subject), MessageTranslator.translate(recipient),
MessageTranslator.translate(content), MessageTranslator.translate(attachment));
} catch (EmailSubmissionException e) {
log.error("Email submission failed", e);
throw new CommunicationException("Email submission failed");
log.error(EMAIL_SUBMISSION_FAILED, e);
throw new CommunicationException(EMAIL_SUBMISSION_FAILED);
}
}

Expand Down
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
<jakarta.persistence.version>3.2.0</jakarta.persistence.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jackson.version>2.18.1</jackson.version>
<sonar.projectKey>qbicsoftware_data-manager-app</sonar.projectKey>
<sonar.organization>qbicsoftware</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>

<parent>
Expand Down Expand Up @@ -233,6 +236,11 @@
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>5.0.0.4389</version>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import life.qbic.logging.api.Logger;
import life.qbic.projectmanagement.application.OrganisationRepository;
import life.qbic.projectmanagement.domain.Organisation;
import org.springframework.stereotype.Component;

/**
* <b>Cached Organisation Repository</b>
Expand All @@ -35,7 +34,6 @@
*
* @since 1.0.0s
*/
@Component
public class CachedOrganisationRepository implements OrganisationRepository {

private static final Logger log = logger(CachedOrganisationRepository.class);
Expand All @@ -53,7 +51,6 @@ public CachedOrganisationRepository(int cacheSize) {
this.configuredCacheSize = cacheSize;
}


public CachedOrganisationRepository() {
this.configuredCacheSize = DEFAULT_CACHE_SIZE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public List<OntologyClass> query(String searchTerm, int offset, int limit)
} catch (IOException e) {
throw wrapIO(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw wrapInterrupted(e);
} catch (Exception e) {
throw wrapUnknown(e);
Expand Down Expand Up @@ -193,6 +194,7 @@ public List<OntologyClass> search(String searchTerm, int offset, int limit)
} catch (IOException e) {
throw wrapIO(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw wrapInterrupted(e);
} catch (Exception e) {
throw wrapUnknown(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ public interface AppContextProvider {
* Returns a resolvable URL to the target project's sample page resource in the application.
*
* @param projectId the project id
* @param experimentId the experiment id
* @return a fully resolvable URL
* @since 1.0.0
*/
String urlToSamplePage(String projectId);
String urlToSamplePage(String projectId, String experimentId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
public class QbicOidcUser extends DefaultOidcUser {

private final QbicUserInfo qbicUserInfo;
private final transient QbicUserInfo qbicUserInfo;
private final String originalAuthName;

public record QbicUserInfo(String userId, String fullName, String email, boolean active) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
public class QbicUserDetails implements UserDetails {
@Serial
private static final long serialVersionUID = 5812210012669790933L;
private final User user;
private final transient User user;
private final List<GrantedAuthority> grantedAuthorities;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
public class ProjectAccessServiceImpl implements ProjectAccessService {

private static final Logger log = logger(ProjectAccessServiceImpl.class);
public static final String SELECT_IDENTITY = "SELECT @@IDENTITY";
private final MutableAclService aclService;
private final JdbcTemplate jdbcTemplate;

Expand All @@ -59,8 +60,8 @@ private static MutableAcl getAclForProject(ProjectId projectId, List<Sid> sids,
JdbcMutableAclService serviceImpl = (JdbcMutableAclService) mutableAclService;
// these settings are necessary for MySQL to correctly throw several types of exceptions
// instead of an unrelated exception related to the identity function
serviceImpl.setClassIdentityQuery("SELECT @@IDENTITY");
serviceImpl.setSidIdentityQuery("SELECT @@IDENTITY");
serviceImpl.setClassIdentityQuery(SELECT_IDENTITY);
serviceImpl.setSidIdentityQuery(SELECT_IDENTITY);
try {
acl = (MutableAcl) serviceImpl.readAclById(objectIdentity, sids);
} catch (NotFoundException e) {
Expand All @@ -75,8 +76,8 @@ private static MutableAcl createAclForProject(ProjectId projectId,
JdbcMutableAclService serviceImpl = (JdbcMutableAclService) mutableAclService;
// these settings are necessary for MySQL to correctly throw several types of exceptions
// instead of an unrelated exception related to the identity function
serviceImpl.setClassIdentityQuery("SELECT @@IDENTITY");
serviceImpl.setSidIdentityQuery("SELECT @@IDENTITY");
serviceImpl.setClassIdentityQuery(SELECT_IDENTITY);
serviceImpl.setSidIdentityQuery(SELECT_IDENTITY);
return serviceImpl.createAcl(objectIdentity);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import life.qbic.projectmanagement.application.sample.SampleRegistrationService;
import life.qbic.projectmanagement.domain.model.batch.Batch;
import life.qbic.projectmanagement.domain.model.batch.BatchId;
import life.qbic.projectmanagement.domain.model.experiment.ExperimentId;
import life.qbic.projectmanagement.domain.model.project.ProjectId;
import life.qbic.projectmanagement.domain.model.sample.Sample;
import life.qbic.projectmanagement.domain.model.sample.SampleId;
Expand Down Expand Up @@ -70,21 +71,23 @@ public BatchRegistrationService(BatchRepository batchRepository,
* are usually followed by a complete batch that represents the measurements of
* the complete experiment.
* @param projectId id of the project this batch is added to
* @param experimentId id of the experiment this batch is added to
* @return a result object with the response. If the registration failed, a response code will be
* provided.
* @since 1.0.0
*/
@PreAuthorize("hasPermission(#projectId, 'life.qbic.projectmanagement.domain.model.project.Project', 'WRITE')")
public Result<BatchId, ResponseCode> registerBatch(String label, boolean isPilot,
ProjectId projectId) {
ProjectId projectId, ExperimentId experimentId) {
var project = projectInformationService.find(projectId);
if (project.isEmpty()) {
log.error(
"Batch registration aborted. Reason: project with id:" + projectId + " was not found");
return Result.fromError(ResponseCode.BATCH_CREATION_FAILED);
}
String projectTitle = project.get().getProjectIntent().projectTitle().title();
var result = batchDomainService.register(label, isPilot, projectTitle, projectId);
var result = batchDomainService.register(label, isPilot, projectTitle, projectId,
experimentId);
if (result.isError()) {
return Result.fromError(ResponseCode.BATCH_REGISTRATION_FAILED);
}
Expand Down
Loading

0 comments on commit 1f71890

Please sign in to comment.