Skip to content

Commit

Permalink
[256] Switch to Java 21
Browse files Browse the repository at this point in the history
Bug: #256
Signed-off-by: Stéphane Bégaudeau <[email protected]>
  • Loading branch information
sbegaudeau committed Oct 9, 2023
1 parent 090fb9e commit d9b8790
Show file tree
Hide file tree
Showing 22 changed files with 242 additions and 302 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ jobs:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4.0.0

- name: Setup Node SDK
uses: actions/setup-node@v3
uses: actions/setup-node@v3.8.1
with:
node-version: '18.x'
cache: 'npm'
cache-dependency-path: frontend/svalyn-studio-app/package-lock.json

- name: Setup Java SDK
uses: actions/setup-java@v3
uses: actions/setup-java@v3.13.0
with:
distribution: 'temurin'
java-version: 20
distribution: 'zulu'
java-version: 21
cache: 'maven'

- name: Build the frontend
Expand Down
4 changes: 2 additions & 2 deletions backend/svalyn-studio-application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
<version>2023.10.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>20</maven.compiler.source>
<maven.compiler.target>20</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,30 +107,20 @@ public Page<AccountDTO> findAll(int page, int rowsPerPage) {
@Override
@Transactional
public IPayload createAccount(CreateAccountInput input) {
IPayload payload = null;

var result = this.accountCreationService.createAccount(input.name(), input.email(), input.username(), input.password());
if (result instanceof Failure<Account> failure) {
payload = new ErrorPayload(input.id(), failure.message());
} else if (result instanceof Success<Account> success) {
payload = new CreateAccountSuccessPayload(input.id(), this.toDTO(success.data()));
}

return payload;
return switch (result) {
case Failure<Account> failure -> new ErrorPayload(input.id(), failure.message());
case Success<Account> success -> new CreateAccountSuccessPayload(input.id(), this.toDTO(success.data()));
};
}

@Override
@Transactional
public IPayload deleteAccount(DeleteAccountInput input) {
IPayload payload = null;

var result = this.accountDeletionService.deleteAccount(input.username());
if (result instanceof Failure<Void> failure) {
payload = new ErrorPayload(input.id(), failure.message());
} else if (result instanceof Success<Void>) {
payload = new SuccessPayload(input.id());
}

return payload;
return switch (result) {
case Failure<Void> failure -> new ErrorPayload(input.id(), failure.message());
case Success<Void> success -> new SuccessPayload(input.id());
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,31 +89,23 @@ private AuthenticationTokenDTO toDTO(AuthenticationToken authenticationToken) {
@Override
@Transactional
public IPayload createAuthenticationToken(CreateAuthenticationTokenInput input) {
IPayload payload = null;

var result = this.accountUpdateService.createAuthenticationToken(input.name());
if (result instanceof Failure<AuthenticationTokenCreated> failure) {
payload = new ErrorPayload(input.id(), failure.message());
} else if (result instanceof Success<AuthenticationTokenCreated> success) {
var authenticationTokenCreatedDTO = new AuthenticationTokenCreatedDTO(success.data().name(), success.data().accessKey(), success.data().secretKey());
payload = new CreateAuthenticationTokenSuccessPayload(input.id(), authenticationTokenCreatedDTO);
}

return payload;
return switch (result) {
case Failure<AuthenticationTokenCreated> failure -> new ErrorPayload(input.id(), failure.message());
case Success<AuthenticationTokenCreated> success -> {
var authenticationTokenCreatedDTO = new AuthenticationTokenCreatedDTO(success.data().name(), success.data().accessKey(), success.data().secretKey());
yield new CreateAuthenticationTokenSuccessPayload(input.id(), authenticationTokenCreatedDTO);
}
};
}

@Override
@Transactional
public IPayload updateAuthenticationTokensStatus(UpdateAuthenticationTokensStatusInput input) {
IPayload payload = null;

var result = this.accountUpdateService.updateAuthenticationTokensStatus(input.authenticationTokenIds(), input.status());
if (result instanceof Failure<Void> failure) {
payload = new ErrorPayload(input.id(), failure.message());
} else if (result instanceof Success<Void> success) {
payload = new SuccessPayload(input.id());
}

return payload;
return switch (result) {
case Failure<Void> failure -> new ErrorPayload(input.id(), failure.message());
case Success<Void> success -> new SuccessPayload(input.id());
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,11 @@ public Page<ChangeProposalDTO> findAllByProjectIdAndStatus(UUID projectId, List<
@Override
@Transactional
public IPayload createChangeProposal(CreateChangeProposalInput input) {
IPayload payload = null;

var result = this.changeProposalCreationService.createChangeProposal(input.projectIdentifier(), input.name(), input.resourceIds());
if (result instanceof Failure<ChangeProposal> failure) {
payload = new ErrorPayload(input.id(), failure.message());
} else if (result instanceof Success<ChangeProposal> success) {
payload = new CreateChangeProposalSuccessPayload(input.id(), this.toDTO(success.data()).orElse(null));
}

return payload;
return switch (result) {
case Failure<ChangeProposal> failure -> new ErrorPayload(input.id(), failure.message());
case Success<ChangeProposal> success -> new CreateChangeProposalSuccessPayload(input.id(), this.toDTO(success.data()).orElse(null));
};
}

private Optional<ReviewDTO> toDTO(Review review) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,10 @@ public Page<NotificationDTO> findAllByStatus(List<NotificationStatus> status, in
@Override
@Transactional
public IPayload updateStatus(UpdateNotificationsStatusInput input) {
IPayload payload = null;

var result = this.notificationUpdateService.updateStatus(input.notificationIds(), input.status());
if (result instanceof Failure<Void> failure) {
payload = new ErrorPayload(input.id(), failure.message());
} else if (result instanceof Success<Void>) {
payload = new SuccessPayload(input.id());
}

return payload;
return switch (result) {
case Failure<Void> failure -> new ErrorPayload(input.id(), failure.message());
case Success<Void> success -> new SuccessPayload(input.id());
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,65 +128,42 @@ public Page<InvitationDTO> findAll(OrganizationDTO organization, int page, int r
@Override
@Transactional
public IPayload inviteMember(InviteMemberInput input) {
IPayload payload = null;

var optionalAccount = this.accountRepository.findByEmail(input.email());
if (optionalAccount.isPresent()) {
var account = optionalAccount.get();
return this.accountRepository.findByEmail(input.email()).map(account -> {
var result = this.organizationUpdateService.inviteMember(input.organizationIdentifier(), account.getId());
if (result instanceof Success<Void> success) {
payload = new SuccessPayload(input.id());
} else if (result instanceof Failure<Void> failure) {
payload = new ErrorPayload(input.id(), failure.message());
}
} else {
payload = new ErrorPayload(input.id(), this.messageService.doesNotExist("account"));
}
return payload;
return switch (result) {
case Failure<Void> failure -> new ErrorPayload(input.id(), failure.message());
case Success<Void> success -> new SuccessPayload(input.id());
};
}).orElse(new ErrorPayload(input.id(), this.messageService.doesNotExist("account")));
}

@Override
@Transactional
public IPayload revokeInvitation(RevokeInvitationInput input) {
IPayload payload = null;

var result = this.organizationUpdateService.revokeInvitation(input.organizationIdentifier(), input.invitationId());
if (result instanceof Failure<Void> failure) {
payload = new ErrorPayload(input.id(), failure.message());
} else if (result instanceof Success<Void> success) {
payload = new SuccessPayload(input.id());
}

return payload;
return switch (result) {
case Failure<Void> failure -> new ErrorPayload(input.id(), failure.message());
case Success<Void> success -> new SuccessPayload(input.id());
};
}

@Override
@Transactional
public IPayload acceptInvitation(AcceptInvitationInput input) {
IPayload payload = null;

var result = this.organizationUpdateService.acceptInvitation(input.organizationIdentifier(), input.invitationId());
if (result instanceof Failure<Void> failure) {
payload = new ErrorPayload(input.id(), failure.message());
} else if (result instanceof Success<Void> success) {
payload = new SuccessPayload(input.id());
}

return payload;
return switch (result) {
case Failure<Void> failure -> new ErrorPayload(input.id(), failure.message());
case Success<Void> success -> new SuccessPayload(input.id());
};
}

@Override
@Transactional
public IPayload declineInvitation(DeclineInvitationInput input) {
IPayload payload = null;

var result = this.organizationUpdateService.declineInvitation(input.organizationIdentifier(), input.invitationId());
if (result instanceof Failure<Void> failure) {
payload = new ErrorPayload(input.id(), failure.message());
} else if (result instanceof Success<Void> success) {
payload = new SuccessPayload(input.id());
}

return payload;
return switch (result) {
case Failure<Void> failure -> new ErrorPayload(input.id(), failure.message());
case Success<Void> success -> new SuccessPayload(input.id());
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,10 @@ public Page<MembershipDTO> findAll(OrganizationDTO organization, int page, int r
@Override
@Transactional
public IPayload revokeMemberships(RevokeMembershipsInput input) {
IPayload payload = null;

var result = this.organizationUpdateService.revokeMemberships(input.organizationIdentifier(), input.membershipIds());
if (result instanceof Failure<Void> failure) {
payload = new ErrorPayload(input.id(), failure.message());
} else if (result instanceof Success<Void> success) {
payload = new SuccessPayload(input.id());
}

return payload;
return switch (result) {
case Failure<Void> failure -> new ErrorPayload(input.id(), failure.message());
case Success<Void> success -> new SuccessPayload(input.id());
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,59 +138,40 @@ public List<OrganizationDTO> searchAllMatching(String query) {
@Override
@Transactional
public IPayload createOrganization(CreateOrganizationInput input) {
IPayload payload = null;

var result = this.organizationCreationService.createOrganization(input.identifier(), input.name());
if (result instanceof Failure<Organization> failure) {
payload = new ErrorPayload(input.id(), failure.message());
} else if (result instanceof Success<Organization> success) {
payload = new CreateOrganizationSuccessPayload(input.id(), this.toDTO(success.data()).orElse(null));
}
return payload;
return switch (result) {
case Failure<Organization> failure -> new ErrorPayload(input.id(), failure.message());
case Success<Organization> success -> new CreateOrganizationSuccessPayload(input.id(), this.toDTO(success.data()).orElse(null));
};
}

@Override
@Transactional
public IPayload updateOrganizationName(UpdateOrganizationNameInput input) {
IPayload payload = null;

var result = this.organizationUpdateService.renameOrganization(input.organizationIdentifier(), input.name());
if (result instanceof Failure<Void> failure) {
payload = new ErrorPayload(input.id(), failure.message());
} else if (result instanceof Success<Void>) {
payload = new SuccessPayload(input.id());
}

return payload;
return switch (result) {
case Failure<Void> failure -> new ErrorPayload(input.id(), failure.message());
case Success<Void> success -> new SuccessPayload(input.id());
};
}

@Override
@Transactional
public IPayload leaveOrganization(LeaveOrganizationInput input) {
IPayload payload = null;

var result = this.organizationUpdateService.leaveOrganization(input.organizationIdentifier());
if (result instanceof Failure<Void> failure) {
payload = new ErrorPayload(input.id(), failure.message());
} else if (result instanceof Success<Void>) {
payload = new SuccessPayload(input.id());
}

return payload;
return switch (result) {
case Failure<Void> failure -> new ErrorPayload(input.id(), failure.message());
case Success<Void> success -> new SuccessPayload(input.id());
};
}

@Override
@Transactional
public IPayload deleteOrganization(DeleteOrganizationInput input) {
IPayload payload = null;

var result = this.organizationDeletionService.deleteOrganization(input.organizationIdentifier());
if (result instanceof Failure<Void> failure) {
payload = new ErrorPayload(input.id(), failure.message());
} else if (result instanceof Success<Void>) {
payload = new SuccessPayload(input.id());
}

return payload;
return switch (result) {
case Failure<Void> failure -> new ErrorPayload(input.id(), failure.message());
case Success<Void> success -> new SuccessPayload(input.id());
};
}
}
Loading

0 comments on commit d9b8790

Please sign in to comment.