Skip to content

Commit f7758a2

Browse files
authored
Merge pull request #572 from Heigvd/dev
Dev -> main
2 parents 75ee25b + bc52498 commit f7758a2

File tree

61 files changed

+1944
-721
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1944
-721
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,41 +43,41 @@ jobs:
4343

4444
steps:
4545
- name: Checkout repository
46-
uses: actions/checkout@v3
46+
uses: actions/checkout@v4
4747

4848
- name: Set up Node
49-
uses: actions/setup-node@v3
49+
uses: actions/setup-node@v4
5050
with:
51-
node-version: 16.20.2
51+
node-version: 20
5252
cache: yarn
5353
cache-dependency-path: |
5454
colab-webapp/yarn.lock
5555
colab-tests/src/test/node/yarn.lock
5656
colab-api/src/main/node/colab-yjs/yarn.lock
5757
5858
- name: Set up Java
59-
uses: actions/setup-java@v3
59+
uses: actions/setup-java@v4
6060
with:
6161
distribution: "temurin"
6262
java-version: 11
6363
cache: "maven"
6464

6565
- name: Set up QEMU
66-
uses: docker/setup-qemu-action@v2
66+
uses: docker/setup-qemu-action@v3
6767

6868
- name: Set up Docker Buildx
69-
uses: docker/setup-buildx-action@v2
69+
uses: docker/setup-buildx-action@v3
7070

7171
- name: Log in to the Container registry
72-
uses: docker/login-action@v2
72+
uses: docker/login-action@v3
7373
with:
7474
registry: ${{ env.REGISTRY }}
7575
username: ${{ github.actor }}
7676
password: ${{ secrets.GITHUB_TOKEN }}
7777

7878
- name: Extract Docker metadata
7979
id: docker-meta-yjs
80-
uses: docker/metadata-action@v4
80+
uses: docker/metadata-action@v5
8181
with:
8282
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-yjs
8383
tags: |
@@ -94,7 +94,7 @@ jobs:
9494
run: yarn --cwd colab-api/src/main/node/colab-yjs build
9595

9696
- name: Build YJS image
97-
uses: docker/build-push-action@v3
97+
uses: docker/build-push-action@v5
9898
with:
9999
context: colab-api/src/main/node/colab-yjs
100100
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8
@@ -117,7 +117,7 @@ jobs:
117117
118118
- name: Extract Docker metadata
119119
id: docker-meta
120-
uses: docker/metadata-action@v4
120+
uses: docker/metadata-action@v5
121121
with:
122122
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
123123
tags: |
@@ -128,7 +128,7 @@ jobs:
128128
type=semver,pattern={{major}}
129129
130130
- name: Build and push Docker image
131-
uses: docker/build-push-action@v3
131+
uses: docker/build-push-action@v5
132132
with:
133133
context: colab-webapp/src/main/docker/colab
134134
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8

.github/workflows/gh-pages.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ jobs:
3131

3232
steps:
3333
- name: Checkout repository
34-
uses: actions/checkout@v3
34+
uses: actions/checkout@v4
3535

3636
- name: Set up Node
37-
uses: actions/setup-node@v3
37+
uses: actions/setup-node@v4
3838
with:
39-
node-version: 16.20.2
39+
node-version: 20
4040
cache: yarn
4141
cache-dependency-path: |
4242
colab-webapp/yarn.lock
4343
colab-tests/src/test/node/yarn.lock
4444
4545
- name: Set up Java
46-
uses: actions/setup-java@v3
46+
uses: actions/setup-java@v4
4747
with:
4848
distribution: "temurin"
4949
java-version: 11

colab-api/src/main/java/ch/colabproject/colab/api/controller/CronTab.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
import ch.colabproject.colab.api.controller.monitoring.CronJobLogManager;
1111
import ch.colabproject.colab.api.model.monitoring.CronJobLogName;
1212
import ch.colabproject.colab.api.security.SessionManager;
13+
import org.slf4j.Logger;
14+
import org.slf4j.LoggerFactory;
15+
1316
import javax.ejb.Schedule;
1417
import javax.ejb.Singleton;
1518
import javax.ejb.Startup;
1619
import javax.inject.Inject;
17-
import org.slf4j.Logger;
18-
import org.slf4j.LoggerFactory;
1920

2021
/**
2122
* Do periodic tasks
@@ -44,7 +45,7 @@ public class CronTab {
4445
/**
4546
* Each minute
4647
*/
47-
@Schedule(hour = "*", minute = "*")
48+
@Schedule(hour = "*", minute = "*", persistent = false)
4849
public void saveActivityDates() {
4950
logger.trace("CRON: Persist activity dates to database");
5051
sessionManager.writeActivityDatesToDatabase();
@@ -54,7 +55,7 @@ public void saveActivityDates() {
5455
/**
5556
* each midnight, clear expired sessions
5657
*/
57-
@Schedule(hour = "0", minute = "0")
58+
@Schedule(hour = "0", minute = "0", persistent = false)
5859
public void dropOldHttpSession() {
5960
logger.info("CRON: drop expired http session");
6061
sessionManager.clearExpiredHttpSessions();
@@ -64,7 +65,7 @@ public void dropOldHttpSession() {
6465
/**
6566
* each 00:30, clean outdated UrlMetadata
6667
*/
67-
@Schedule(hour = "0", minute = "30")
68+
@Schedule(hour = "0", minute = "30", persistent = false)
6869
public void dropOldUrlMetadata() {
6970
logger.info("CRON: clean url metadata cache");
7071
externalDataManager.clearOutdated();

colab-api/src/main/java/ch/colabproject/colab/api/controller/card/CardContentManager.java

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The coLAB project
3-
* Copyright (C) 2021-2023 AlbaSim, MEI, HEIG-VD, HES-SO
3+
* Copyright (C) 2021-2024 AlbaSim, MEI, HEIG-VD, HES-SO
44
*
55
* Licensed under the MIT License
66
*/
@@ -22,12 +22,14 @@
2222
import ch.colabproject.colab.api.persistence.jpa.document.DocumentDao;
2323
import ch.colabproject.colab.generator.model.exceptions.HttpErrorMessage;
2424
import ch.colabproject.colab.generator.model.exceptions.MessageI18nKey;
25-
import java.util.List;
25+
import org.slf4j.Logger;
26+
import org.slf4j.LoggerFactory;
27+
2628
import javax.ejb.LocalBean;
2729
import javax.ejb.Stateless;
2830
import javax.inject.Inject;
29-
import org.slf4j.Logger;
30-
import org.slf4j.LoggerFactory;
31+
import java.util.List;
32+
import java.util.Objects;
3133

3234
/**
3335
* Card content specific logic
@@ -269,38 +271,46 @@ public void putCardContentInBin(Long cardContentId) {
269271

270272
CardContent cardContent = assertAndGetCardContent(cardContentId);
271273

274+
if (!checkDeletionAcceptability(cardContent)) {
275+
throw HttpErrorMessage.dataError(MessageI18nKey.DATA_INTEGRITY_FAILURE);
276+
}
277+
272278
deletionManager.putInBin(cardContent);
273279
}
274280

275-
// /**
276-
// * Restore from the bin. The object won't contain any deletion or erasure data anymore.
277-
// * <p>
278-
// * It means that the card content is back at its place.
279-
// *
280-
// * @param cardContentId the id of the card content
281-
// */
282-
// public void restoreCardContentFromBin(Long cardContentId) {
283-
// logger.debug("restore from bin card content #{}", cardContentId);
284-
//
285-
// CardContent cardContent = assertAndGetCardContent(cardContentId);
286-
//
287-
// deletionManager.restoreFromBin(cardContent);
288-
// }
289-
//
290-
// /**
291-
// * Set the deletion status to TO_DELETE.
292-
// * <p>
293-
// * It means that the card content is only visible in the bin panel.
294-
// *
295-
// * @param cardContentId the id of the card content
296-
// */
297-
// public void markCardContentAsToDeleteForever(Long cardContentId) {
298-
// logger.debug("mark card content #{} as to delete forever", cardContentId);
299-
//
300-
// CardContent cardContent = assertAndGetCardContent(cardContentId);
301-
//
302-
// deletionManager.markAsToDeleteForever(cardContent);
303-
// }
281+
/**
282+
* Restore from the bin. The object won't contain any deletion or erasure data anymore.
283+
* <p>
284+
* It means that the card content is back at its place.
285+
*
286+
* @param cardContentId the id of the card content
287+
*/
288+
public void restoreCardContentFromBin(Long cardContentId) {
289+
logger.debug("restore from bin card content #{}", cardContentId);
290+
291+
CardContent cardContent = assertAndGetCardContent(cardContentId);
292+
293+
deletionManager.restoreFromBin(cardContent);
294+
}
295+
296+
/**
297+
* Set the deletion status to TO_DELETE.
298+
* <p>
299+
* It means that the card content is only visible in the bin panel.
300+
*
301+
* @param cardContentId the id of the card content
302+
*/
303+
public void markCardContentAsToDeleteForever(Long cardContentId) {
304+
logger.debug("mark card content #{} as to delete forever", cardContentId);
305+
306+
CardContent cardContent = assertAndGetCardContent(cardContentId);
307+
308+
if (!checkDeletionAcceptability(cardContent)) {
309+
throw HttpErrorMessage.dataError(MessageI18nKey.DATA_INTEGRITY_FAILURE);
310+
}
311+
312+
deletionManager.markAsToDeleteForever(cardContent);
313+
}
304314

305315
/**
306316
* Delete the given card content
@@ -327,8 +337,12 @@ public void deleteCardContent(Long cardContentId) {
327337
* @return True iff it can be safely deleted
328338
*/
329339
private boolean checkDeletionAcceptability(CardContent cardContent) {
330-
// A card must have at least one card content
331-
if (cardContent.getCard().getContentVariants().size() == 1) {
340+
// A card must have at least one other alive card content
341+
if (cardContent.getCard().getContentVariants()
342+
.stream()
343+
.filter(content -> !Objects.equals(content, cardContent))
344+
.noneMatch(content -> deletionManager.isAlive(content))
345+
) {
332346
return false;
333347
}
334348

colab-api/src/main/java/ch/colabproject/colab/api/controller/card/CardManager.java

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* The coLAB project
3-
* Copyright (C) 2021-2023 AlbaSim, MEI, HEIG-VD, HES-SO
3+
* Copyright (C) 2021-2024 AlbaSim, MEI, HEIG-VD, HES-SO
44
*
55
* Licensed under the MIT License
66
*/
@@ -21,18 +21,14 @@
2121
import ch.colabproject.colab.api.persistence.jpa.card.CardDao;
2222
import ch.colabproject.colab.generator.model.exceptions.HttpErrorMessage;
2323
import ch.colabproject.colab.generator.model.exceptions.MessageI18nKey;
24-
import java.util.ArrayList;
25-
import java.util.HashSet;
26-
import java.util.LinkedList;
27-
import java.util.List;
28-
import java.util.Objects;
29-
import java.util.Set;
30-
import java.util.stream.Collectors;
24+
import org.slf4j.Logger;
25+
import org.slf4j.LoggerFactory;
26+
3127
import javax.ejb.LocalBean;
3228
import javax.ejb.Stateless;
3329
import javax.inject.Inject;
34-
import org.slf4j.Logger;
35-
import org.slf4j.LoggerFactory;
30+
import java.util.*;
31+
import java.util.stream.Collectors;
3632

3733
/**
3834
* Card, card type and card content specific logic
@@ -148,15 +144,6 @@ public Set<CardContent> getAllCardContents(Card rootCard) {
148144
// helper
149145
// *********************************************************************************************
150146

151-
/**
152-
* @param card The card
153-
*
154-
* @return True if the card is not marked as deleted
155-
*/
156-
public boolean isAlive(Card card) {
157-
return card.getDeletionStatus() == null;
158-
}
159-
160147
/**
161148
* @param card the card to check
162149
*
@@ -179,7 +166,8 @@ private CardContent getRootCardContent(Project project) {
179166
public List<Card> getAliveSubCards(CardContent parent) {
180167
if (parent != null) {
181168
List<Card> subCardsOfParent = new ArrayList<>(parent.getSubCards());
182-
return subCardsOfParent.stream().filter(this::isAlive).collect(Collectors.toList());
169+
return subCardsOfParent.stream()
170+
.filter((card) -> deletionManager.isAlive(card)).collect(Collectors.toList());
183171
}
184172

185173
return new ArrayList<>();

colab-api/src/main/java/ch/colabproject/colab/api/controller/common/DeletionManager.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/*
2+
* The coLAB project
3+
* Copyright (C) 2021-2024 AlbaSim, MEI, HEIG-VD, HES-SO
4+
*
5+
* Licensed under the MIT License
6+
*/
17
package ch.colabproject.colab.api.controller.common;
28

39
import ch.colabproject.colab.api.controller.security.SecurityManager;
@@ -35,6 +41,14 @@ public class DeletionManager {
3541
// check deletion status
3642
// *********************************************************************************************
3743

44+
/**
45+
* @param object The colab entity to check
46+
* @return True if the colab entity is deleted, false otherwise
47+
*/
48+
public boolean isAlive(ColabEntity object) {
49+
return object.getDeletionStatus() == null;
50+
}
51+
3852
/**
3953
* @param object The colab entity to check
4054
* @return True if the colab entity is deleted, false otherwise

0 commit comments

Comments
 (0)