Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e874a58
Use SclFileType from CoMPAS Common.
Dec 14, 2021
d205d5b
Merge pull request #160 from com-pas/refactor-sclfiletype
Dec 15, 2021
60b0971
Bump actions/setup-java from 2.4.0 to 2.5.0
dependabot[bot] Dec 21, 2021
cf7033f
Merge pull request #161 from com-pas/dependabot/github_actions/action…
Dec 22, 2021
5dc9843
Bump quarkus.platform.version from 2.4.2.Final to 2.6.0.Final
dependabot[bot] Dec 23, 2021
2d1f8e1
Merge pull request #162 from com-pas/dependabot/maven/quarkus.platfor…
Dec 23, 2021
19b9afb
Bump quarkus.platform.version from 2.6.0.Final to 2.6.1.Final
dependabot[bot] Dec 27, 2021
e413d11
Merge pull request #163 from com-pas/dependabot/maven/quarkus.platfor…
Dec 27, 2021
61b8cc4
Bump maven-jar-plugin from 3.2.0 to 3.2.1
dependabot[bot] Jan 10, 2022
5491129
Bump jandex-maven-plugin from 1.2.1 to 1.2.2
dependabot[bot] Jan 10, 2022
f678f66
Merge pull request #164 from com-pas/dependabot/maven/org.apache.mave…
Jan 11, 2022
dd21393
Merge pull request #165 from com-pas/dependabot/maven/org.jboss.jande…
Jan 11, 2022
ec5ecd7
Bump quarkus.platform.version from 2.6.1.Final to 2.6.2.Final
dependabot[bot] Jan 11, 2022
c40731c
Bump maven-jar-plugin from 3.2.1 to 3.2.2
dependabot[bot] Jan 12, 2022
2df4e6c
Merge pull request #166 from com-pas/dependabot/maven/quarkus.platfor…
Jan 13, 2022
aceb5ad
Merge pull request #167 from com-pas/dependabot/maven/org.apache.mave…
Jan 13, 2022
520b8d0
Configure release note generation.
Jan 13, 2022
51163c6
Bump maven-compiler-plugin from 3.8.1 to 3.9.0
dependabot[bot] Jan 13, 2022
d0c8ebd
Merge pull request #168 from com-pas/simple_release_notes
Jan 13, 2022
1983225
Merge pull request #169 from com-pas/dependabot/maven/org.apache.mave…
Jan 13, 2022
e9820e1
Bump slf4j.version from 1.7.32 to 1.7.33
dependabot[bot] Jan 14, 2022
bfeac0a
Added Dependabot PR fix
Jan 16, 2022
c3545e1
Merge pull request #170 from com-pas/dependabot/maven/slf4j.version-1…
Jan 17, 2022
e441c49
Merge pull request #171 from com-pas/dependabot-pr-fix
Jan 17, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# SPDX-FileCopyrightText: 2021 Alliander N.V.
#
# SPDX-License-Identifier: Apache-2.0

changelog:
exclude:
labels:
- wontfix
- duplicate
- invalid
categories:
- title: New Features
labels:
- enhancement
- title: Bugfixes
labels:
- bug
- title: Tooling changes
labels:
- tooling
- title: Dependency updates
labels:
- dependencies
- title: Other Changes
labels:
- "*"
8 changes: 5 additions & 3 deletions .github/workflows/automate-projects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

name: Add issues and pull request to project boards

on: [ issues, pull_request ]
on: [ issues, pull_request, pull_request_target ]

jobs:
github-actions-automate-projects:
runs-on: ubuntu-latest

if: ${{ (github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') || (github.actor == 'dependabot[bot]' && github.event_name == 'pull_request_target') }}
steps:
- name: add-new-issues-to-repository-based-project-column
uses: docker://takanabe/github-actions-automate-projects:v0.0.1
Expand All @@ -19,7 +21,7 @@ jobs:
GITHUB_PROJECT_COLUMN_NAME: To do
- name: add-new-pull-request-to-repository-based-project-column
uses: docker://takanabe/github-actions-automate-projects:v0.0.1
if: github.event_name == 'pull_request' && github.event.action == 'opened'
if: (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.event.action == 'opened'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PROJECT_URL: https://github.com/com-pas/compas-scl-data-service/projects/1
Expand All @@ -33,7 +35,7 @@ jobs:
GITHUB_PROJECT_COLUMN_NAME: To do
- name: add-new-pull-request-to-organization-based-project-column
uses: docker://takanabe/github-actions-automate-projects:v0.0.1
if: github.event_name == 'pull_request' && github.event.action == 'opened'
if: (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.event.action == 'opened'
env:
GITHUB_TOKEN: ${{ secrets.ORG_GITHUB_ACTION_SECRET }}
GITHUB_PROJECT_URL: https://github.com/orgs/com-pas/projects/2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
restore-keys: ${{ runner.os }}-m2

- name: Set up JDK 1.11
uses: actions/setup-java@v2.4.0
uses: actions/setup-java@v2.5.0
with:
distribution: 'zulu'
java-version: '11'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
# Extra the tagname form the git reference, value of GITHUB_REF will be something like refs/tags/<tag_name>.
run: echo "##[set-output name=tagname;]$(echo ${GITHUB_REF##*/})"
- name: Set up JDK 1.11
uses: actions/setup-java@v2.4.0
uses: actions/setup-java@v2.5.0
with:
distribution: 'zulu'
java-version: '11'
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/sonarcloud-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,26 @@ on:
branches:
- 'main'
- 'develop'
pull_request_target:
branches:
- 'main'
- 'develop'

jobs:
sonar-check:
name: Sonar Check
runs-on: ubuntu-latest
timeout-minutes: 15

if: ${{ (github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') || (github.actor == 'dependabot[bot]' && github.event_name == 'pull_request_target') }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up JDK 11
uses: actions/setup-java@v2.4.0
uses: actions/setup-java@v2.5.0
with:
distribution: 'zulu'
java-version: '11'
Expand Down Expand Up @@ -58,4 +63,5 @@ jobs:
-Dsonar.projectKey=com-pas_compas-scl-data-service \
-Dsonar.organization=com-pas \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }} \
clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,8 @@ configured as needed.
- SED_DELETE
- SED_READ
- SED_UPDATE
- STD_CREATE
- STD_DELETE
- STD_READ
- STD_UPDATE

4 changes: 4 additions & 0 deletions app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ SPDX-License-Identifier: Apache-2.0
<groupId>org.lfenergy.compas.core</groupId>
<artifactId>commons</artifactId>
</dependency>
<dependency>
<groupId>org.lfenergy.compas.core</groupId>
<artifactId>scl-extension</artifactId>
</dependency>
<dependency>
<groupId>org.lfenergy.compas.core</groupId>
<artifactId>jaxrs-commons</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

import io.quarkus.security.Authenticated;
import org.eclipse.microprofile.jwt.JsonWebToken;
import org.lfenergy.compas.scl.data.model.SclType;
import org.lfenergy.compas.scl.data.rest.UserInfoProperties;
import org.lfenergy.compas.scl.data.rest.v1.model.Type;
import org.lfenergy.compas.scl.data.rest.v1.model.TypeListResponse;
import org.lfenergy.compas.scl.data.rest.v1.model.UserInfoResponse;
import org.lfenergy.compas.scl.extensions.model.SclFileType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -49,10 +49,10 @@ public TypeListResponse list(@HeaderParam("Authorization") String authHeader) {

var response = new TypeListResponse();
response.setTypes(
Arrays.stream(SclType.values())
Arrays.stream(SclFileType.values())
// Filter on the type the user has read rights.
.filter(sclType -> roles.contains(sclType.name() + "_" + READ_ROLE))
.map(sclType -> new Type(sclType.name(), sclType.getDescription()))
.filter(sclFileType -> roles.contains(sclFileType.name() + "_" + READ_ROLE))
.map(sclFileType -> new Type(sclFileType.name(), sclFileType.getDescription()))
.sorted(Comparator.comparing(Type::getDescription))
.collect(Collectors.toList()));
return response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

import io.quarkus.security.Authenticated;
import org.eclipse.microprofile.jwt.JsonWebToken;
import org.lfenergy.compas.scl.data.model.SclType;
import org.lfenergy.compas.scl.data.model.Version;
import org.lfenergy.compas.scl.data.rest.UserInfoProperties;
import org.lfenergy.compas.scl.data.rest.v1.model.*;
import org.lfenergy.compas.scl.data.service.CompasSclDataService;
import org.lfenergy.compas.scl.extensions.model.SclFileType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -44,7 +44,7 @@ public CompasSclDataResource(CompasSclDataService compasSclDataService) {
@POST
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_XML)
public CreateResponse create(@PathParam(TYPE_PATH_PARAM) SclType type,
public CreateResponse create(@PathParam(TYPE_PATH_PARAM) SclFileType type,
@Valid CreateRequest request) {
String who = jsonWebToken.getClaim(userInfoProperties.who());
LOGGER.trace("Username used for Who {}", who);
Expand All @@ -58,7 +58,7 @@ public CreateResponse create(@PathParam(TYPE_PATH_PARAM) SclType type,
@GET
@Path("/list")
@Produces(MediaType.APPLICATION_XML)
public ListResponse list(@PathParam(TYPE_PATH_PARAM) SclType type) {
public ListResponse list(@PathParam(TYPE_PATH_PARAM) SclFileType type) {
var response = new ListResponse();
response.setItems(compasSclDataService.list(type));
return response;
Expand All @@ -67,7 +67,7 @@ public ListResponse list(@PathParam(TYPE_PATH_PARAM) SclType type) {
@GET
@Path("/{" + ID_PATH_PARAM + "}/versions")
@Produces(MediaType.APPLICATION_XML)
public VersionsResponse listVersionsByUUID(@PathParam(TYPE_PATH_PARAM) SclType type,
public VersionsResponse listVersionsByUUID(@PathParam(TYPE_PATH_PARAM) SclFileType type,
@PathParam(ID_PATH_PARAM) UUID id) {
var response = new VersionsResponse();
response.setItems(compasSclDataService.listVersionsByUUID(type, id));
Expand All @@ -77,7 +77,7 @@ public VersionsResponse listVersionsByUUID(@PathParam(TYPE_PATH_PARAM) SclType t
@GET
@Path("/{" + ID_PATH_PARAM + "}")
@Produces(MediaType.APPLICATION_XML)
public GetResponse findByUUID(@PathParam(TYPE_PATH_PARAM) SclType type,
public GetResponse findByUUID(@PathParam(TYPE_PATH_PARAM) SclFileType type,
@PathParam(ID_PATH_PARAM) UUID id) {
var response = new GetResponse();
response.setSclData(compasSclDataService.findByUUID(type, id));
Expand All @@ -87,7 +87,7 @@ public GetResponse findByUUID(@PathParam(TYPE_PATH_PARAM) SclType type,
@GET
@Path("/{" + ID_PATH_PARAM + "}/{" + VERSION_PATH_PARAM + "}")
@Produces(MediaType.APPLICATION_XML)
public GetResponse findByUUIDAndVersion(@PathParam(TYPE_PATH_PARAM) SclType type,
public GetResponse findByUUIDAndVersion(@PathParam(TYPE_PATH_PARAM) SclFileType type,
@PathParam(ID_PATH_PARAM) UUID id,
@PathParam(VERSION_PATH_PARAM) Version version) {
var response = new GetResponse();
Expand All @@ -99,7 +99,7 @@ public GetResponse findByUUIDAndVersion(@PathParam(TYPE_PATH_PARAM) SclType type
@Path("/{" + ID_PATH_PARAM + "}")
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_XML)
public UpdateResponse update(@PathParam(TYPE_PATH_PARAM) SclType type,
public UpdateResponse update(@PathParam(TYPE_PATH_PARAM) SclFileType type,
@PathParam(ID_PATH_PARAM) UUID id,
@Valid UpdateRequest request) {
String who = jsonWebToken.getClaim(userInfoProperties.who());
Expand All @@ -114,15 +114,15 @@ public UpdateResponse update(@PathParam(TYPE_PATH_PARAM) SclType type,
@DELETE
@Path("/{" + ID_PATH_PARAM + "}")
@Produces(MediaType.APPLICATION_XML)
public void deleteAll(@PathParam(TYPE_PATH_PARAM) SclType type,
public void deleteAll(@PathParam(TYPE_PATH_PARAM) SclFileType type,
@PathParam(ID_PATH_PARAM) UUID id) {
compasSclDataService.delete(type, id);
}

@DELETE
@Path("/{" + ID_PATH_PARAM + "}/{" + VERSION_PATH_PARAM + "}")
@Produces(MediaType.APPLICATION_XML)
public void deleteVersion(@PathParam(TYPE_PATH_PARAM) SclType type,
public void deleteVersion(@PathParam(TYPE_PATH_PARAM) SclFileType type,
@PathParam(ID_PATH_PARAM) UUID id,
@PathParam(VERSION_PATH_PARAM) Version version) {
compasSclDataService.delete(type, id, version);
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,20 @@ quarkus.http.auth.policy.ISD_DELETE.roles-allowed=ISD_DELETE
quarkus.http.auth.permission.ISD_DELETE_DELETE.paths=/compas-scl-data-service/scl/v1/ISD/*
quarkus.http.auth.permission.ISD_DELETE_DELETE.policy=ISD_DELETE
quarkus.http.auth.permission.ISD_DELETE_DELETE.methods=DELETE

quarkus.http.auth.policy.STD_READ.roles-allowed=STD_READ
quarkus.http.auth.permission.STD_READ_GET.paths=/compas-scl-data-service/scl/v1/STD/*
quarkus.http.auth.permission.STD_READ_GET.policy=STD_READ
quarkus.http.auth.permission.STD_READ_GET.methods=GET
quarkus.http.auth.policy.STD_CREATE.roles-allowed=STD_CREATE
quarkus.http.auth.permission.STD_CREATE_POST.paths=/compas-scl-data-service/scl/v1/STD
quarkus.http.auth.permission.STD_CREATE_POST.policy=STD_CREATE
quarkus.http.auth.permission.STD_CREATE_POST.methods=POST
quarkus.http.auth.policy.STD_UPDATE.roles-allowed=STD_UPDATE
quarkus.http.auth.permission.STD_UPDATE_PUT.paths=/compas-scl-data-service/scl/v1/STD/*
quarkus.http.auth.permission.STD_UPDATE_PUT.policy=STD_UPDATE
quarkus.http.auth.permission.STD_UPDATE_PUT.methods=PUT
quarkus.http.auth.policy.STD_DELETE.roles-allowed=STD_DELETE
quarkus.http.auth.permission.STD_DELETE_DELETE.paths=/compas-scl-data-service/scl/v1/STD/*
quarkus.http.auth.permission.STD_DELETE_DELETE.policy=STD_DELETE
quarkus.http.auth.permission.STD_DELETE_DELETE.methods=DELETE
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import io.quarkus.test.Mock;
import org.lfenergy.compas.scl.data.model.Item;
import org.lfenergy.compas.scl.data.model.SclMetaInfo;
import org.lfenergy.compas.scl.data.model.SclType;
import org.lfenergy.compas.scl.data.model.Version;
import org.lfenergy.compas.scl.data.repository.CompasSclDataRepository;
import org.lfenergy.compas.scl.extensions.model.SclFileType;

import javax.enterprise.context.ApplicationScoped;
import java.util.List;
Expand All @@ -18,42 +18,42 @@
@ApplicationScoped
public class CompasSclDataRepositoryMock implements CompasSclDataRepository {
@Override
public List<Item> list(SclType type) {
public List<Item> list(SclFileType type) {
throw new IllegalStateException("Mock method using Mockito. Only needed to startup.");
}

@Override
public List<Item> listVersionsByUUID(SclType type, UUID id) {
public List<Item> listVersionsByUUID(SclFileType type, UUID id) {
throw new IllegalStateException("Mock method using Mockito. Only needed to startup.");
}

@Override
public String findByUUID(SclType type, UUID id) {
public String findByUUID(SclFileType type, UUID id) {
throw new IllegalStateException("Mock method using Mockito. Only needed to startup.");
}

@Override
public SclMetaInfo findMetaInfoByUUID(SclType type, UUID id) {
public SclMetaInfo findMetaInfoByUUID(SclFileType type, UUID id) {
throw new IllegalStateException("Mock method using Mockito. Only needed to startup.");
}

@Override
public String findByUUID(SclType type, UUID id, Version version) {
public String findByUUID(SclFileType type, UUID id, Version version) {
throw new IllegalStateException("Mock method using Mockito. Only needed to startup.");
}

@Override
public void create(SclType type, UUID id, String name, String scl, Version version, String who) {
public void create(SclFileType type, UUID id, String name, String scl, Version version, String who) {
throw new IllegalStateException("Mock method using Mockito. Only needed to startup.");
}

@Override
public void delete(SclType type, UUID id) {
public void delete(SclFileType type, UUID id) {
throw new IllegalStateException("Mock method using Mockito. Only needed to startup.");
}

@Override
public void delete(SclType type, UUID id, Version version) {
public void delete(SclFileType type, UUID id, Version version) {
throw new IllegalStateException("Mock method using Mockito. Only needed to startup.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ void list_WhenCalledWithMultipleReadRights_ThenMultipleItemResponseRetrieved() {

var xmlPath = response.xmlPath();
// User has read rights for 2 types, so these types are returned.
var sclTypes = xmlPath.getList("TypeListResponse.Type.Code");
assertEquals(2, sclTypes.size());
assertEquals("IID", sclTypes.get(0));
assertEquals("SCD", sclTypes.get(1));
var sclFileTypes = xmlPath.getList("TypeListResponse.Type.Code");
assertEquals(2, sclFileTypes.size());
assertEquals("IID", sclFileTypes.get(0));
assertEquals("SCD", sclFileTypes.get(1));
}

@Test
Expand All @@ -48,9 +48,9 @@ void list_WhenCalledWithOneReadRights_ThenOneItemResponseRetrieved() {

var xmlPath = response.xmlPath();
// User has read rights for one type, so this type is returned.
var sclTypes = xmlPath.getList("TypeListResponse.Type.Code");
assertEquals(1, sclTypes.size());
assertEquals("SCD", sclTypes.get(0));
var sclFileTypes = xmlPath.getList("TypeListResponse.Type.Code");
assertEquals(1, sclFileTypes.size());
assertEquals("SCD", sclFileTypes.get(0));
}

@Test
Expand All @@ -65,8 +65,8 @@ void list_WhenCalledWithNoReadRights_ThenNoItemResponseRetrieved() {

var xmlPath = response.xmlPath();
// User has read rights for no types, so empty list is returned.
var sclTypes = xmlPath.getList("TypeListResponse.Type.Code");
assertEquals(0, sclTypes.size());
var sclFileTypes = xmlPath.getList("TypeListResponse.Type.Code");
assertEquals(0, sclFileTypes.size());
}

@Test
Expand Down
Loading