Skip to content

Commit 75ee25b

Browse files
Merge pull request #567 from Heigvd/dev
- URL changes - text editor fix - icon picker review - some links can be opened in a new tab browser - schedule job monitoring
2 parents f0f1e55 + 3732a48 commit 75ee25b

File tree

222 files changed

+4609
-5413
lines changed

Some content is hidden

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

222 files changed

+4609
-5413
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
- name: Set up Node
4949
uses: actions/setup-node@v3
5050
with:
51-
node-version: 16.18.1
51+
node-version: 16.20.2
5252
cache: yarn
5353
cache-dependency-path: |
5454
colab-webapp/yarn.lock

.github/workflows/gh-pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- name: Set up Node
3737
uses: actions/setup-node@v3
3838
with:
39-
node-version: 16.18.1
39+
node-version: 16.20.2
4040
cache: yarn
4141
cache-dependency-path: |
4242
colab-webapp/yarn.lock

client-generator-plugin/src/main/resources/templates/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"strict": true,
99
"moduleResolution": "node",
1010
"allowSyntheticDefaultImports": true,
11-
"suppressImplicitAnyIndexErrors": true,
1211
"declaration": true
1312
},
1413
"files": [

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
package ch.colabproject.colab.api.controller;
88

99
import ch.colabproject.colab.api.controller.document.ExternalDataManager;
10+
import ch.colabproject.colab.api.controller.monitoring.CronJobLogManager;
11+
import ch.colabproject.colab.api.model.monitoring.CronJobLogName;
1012
import ch.colabproject.colab.api.security.SessionManager;
1113
import javax.ejb.Schedule;
1214
import javax.ejb.Singleton;
@@ -35,13 +37,18 @@ public class CronTab {
3537
@Inject
3638
private ExternalDataManager externalDataManager;
3739

40+
/** To manage CronJobLogs */
41+
@Inject
42+
private CronJobLogManager cronJobLogManager;
43+
3844
/**
39-
* Each minutes
45+
* Each minute
4046
*/
4147
@Schedule(hour = "*", minute = "*")
4248
public void saveActivityDates() {
4349
logger.trace("CRON: Persist activity dates to database");
4450
sessionManager.writeActivityDatesToDatabase();
51+
cronJobLogManager.updateCronJobLogLastRunTime(CronJobLogName.SAVE_ACTIVITIES_DATE);
4552
}
4653

4754
/**
@@ -51,6 +58,7 @@ public void saveActivityDates() {
5158
public void dropOldHttpSession() {
5259
logger.info("CRON: drop expired http session");
5360
sessionManager.clearExpiredHttpSessions();
61+
cronJobLogManager.updateCronJobLogLastRunTime(CronJobLogName.DROP_OLD_HTTP_SESSIONS);
5462
}
5563

5664
/**
@@ -60,5 +68,6 @@ public void dropOldHttpSession() {
6068
public void dropOldUrlMetadata() {
6169
logger.info("CRON: clean url metadata cache");
6270
externalDataManager.clearOutdated();
71+
cronJobLogManager.updateCronJobLogLastRunTime(CronJobLogName.DROP_OLD_URL_METADATA);
6372
}
6473
}

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,23 @@
88

99
import ch.colabproject.colab.api.model.WithWebsocketChannels;
1010
import ch.colabproject.colab.api.persistence.jpa.card.CardTypeDao;
11+
import ch.colabproject.colab.api.persistence.jpa.project.ProjectDao;
1112
import ch.colabproject.colab.api.persistence.jpa.team.TeamMemberDao;
1213
import ch.colabproject.colab.api.persistence.jpa.user.UserDao;
1314
import ch.colabproject.colab.api.ws.WebsocketMessagePreparer;
1415
import ch.colabproject.colab.api.ws.message.IndexEntry;
1516
import ch.colabproject.colab.api.ws.message.PrecomputedWsMessages;
17+
import org.slf4j.Logger;
18+
import org.slf4j.LoggerFactory;
19+
20+
import javax.enterprise.context.RequestScoped;
21+
import javax.inject.Inject;
22+
import javax.transaction.Status;
1623
import java.io.Serializable;
1724
import java.util.Collection;
1825
import java.util.HashSet;
1926
import java.util.Set;
2027
import java.util.stream.Collectors;
21-
import javax.enterprise.context.RequestScoped;
22-
import javax.inject.Inject;
23-
import javax.transaction.Status;
24-
import org.slf4j.Logger;
25-
import org.slf4j.LoggerFactory;
2628

2729
/**
2830
* Transaction sidekick used to collect updated and deleted entities. Once the transaction is
@@ -69,6 +71,12 @@ public class EntityGatheringBagForPropagation implements Serializable {
6971
@Inject
7072
private CardTypeDao cardTypeDao;
7173

74+
/**
75+
* To resolve nested channels
76+
*/
77+
@Inject
78+
private ProjectDao projectDao;
79+
7280
/**
7381
* TO sudo
7482
*/
@@ -205,7 +213,7 @@ private void precomputeMessage() {
205213
this.precomputed = true;
206214
requestManager.sudo(() -> {
207215
return this.message = WebsocketMessagePreparer.prepareWsMessage(userDao, teamDao,
208-
cardTypeDao, filtered, deleted);
216+
cardTypeDao, projectDao, filtered, deleted);
209217
});
210218
logger.debug("Precomputed: {}", message);
211219
} catch (Exception ex) {

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import ch.colabproject.colab.api.model.user.HttpSession;
1515
import ch.colabproject.colab.api.model.user.User;
1616
import ch.colabproject.colab.api.persistence.jpa.card.CardTypeDao;
17+
import ch.colabproject.colab.api.persistence.jpa.project.ProjectDao;
1718
import ch.colabproject.colab.api.persistence.jpa.team.TeamMemberDao;
1819
import ch.colabproject.colab.api.persistence.jpa.user.UserDao;
1920
import ch.colabproject.colab.api.presence.PresenceManager;
@@ -157,6 +158,12 @@ public class WebsocketManager {
157158
@Inject
158159
private CardTypeDao cardTypeDao;
159160

161+
/**
162+
* Project persistence handler
163+
*/
164+
@Inject
165+
private ProjectDao projectDao;
166+
160167
/**
161168
* Presence Manager
162169
*/
@@ -479,8 +486,7 @@ public void processSubscription(
479486
/**
480487
* Add the given session to the set identified by the given channel, in the given map.
481488
*
482-
* @param map map which contains sets
483-
* @param keyId set id
489+
* @param channel websocket channel to which we subscribe
484490
* @param session session to remove from the set
485491
*/
486492
private void subscribe(WebsocketChannel channel, Session session) {
@@ -676,6 +682,7 @@ private void propagateSignOut(HttpSession httpSession) {
676682
userDao,
677683
teamMemberDao,
678684
cardTypeDao,
685+
projectDao,
679686
httpSession.getChannelsBuilder(),
680687
new WsSignOutMessage(httpSession));
681688
this.propagate(prepareWsMessage);

colab-api/src/main/java/ch/colabproject/colab/api/controller/config/ConfigurationManager.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public ColabConfig getConfig() {
3030
config
3131
.setDisplayCreateLocalAccountButton(ColabConfiguration.getDisplayLocalAccountButton());
3232
config.setYjsApiEndpoint(ColabConfiguration.getYjsUrlWs());
33+
config.setJcrRepositoryFileSizeLimit(ColabConfiguration.getJcrRepositoryFileSizeLimit());
3334
return config;
3435
}
3536

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* The coLAB project
3+
* Copyright (C) 2021-2023 AlbaSim, MEI, HEIG-VD, HES-SO
4+
*
5+
* Licensed under the MIT License
6+
*/
7+
package ch.colabproject.colab.api.controller.monitoring;
8+
9+
import ch.colabproject.colab.api.model.monitoring.CronJobLog;
10+
import ch.colabproject.colab.api.model.monitoring.CronJobLogName;
11+
import ch.colabproject.colab.api.persistence.jpa.monitoring.CronJobLogDao;
12+
import org.slf4j.Logger;
13+
import org.slf4j.LoggerFactory;
14+
15+
import javax.ejb.LocalBean;
16+
import javax.ejb.Stateless;
17+
import javax.ejb.TransactionAttribute;
18+
import javax.ejb.TransactionAttributeType;
19+
import javax.inject.Inject;
20+
import java.time.OffsetDateTime;
21+
22+
/**
23+
* Logic to manage cron job logging
24+
*
25+
* @author mikkelvestergaard
26+
*/
27+
@Stateless
28+
@LocalBean
29+
public class CronJobLogManager {
30+
31+
/**
32+
* logger
33+
*/
34+
private static final Logger logger = LoggerFactory.getLogger(CronJobLogManager.class);
35+
36+
/**
37+
* CronJobLog persistence
38+
*/
39+
@Inject
40+
private CronJobLogDao cronJobLogDao;
41+
42+
/**
43+
* Create a new cronJobLog with given cronJobLogName
44+
*
45+
* @param jobLogName name of the cronJobLog to create
46+
*
47+
* @return created cronJobLog
48+
*/
49+
private CronJobLog createCronJobLog(CronJobLogName jobLogName) {
50+
CronJobLog cronJobLog = new CronJobLog();
51+
cronJobLog.setJobName(jobLogName);
52+
cronJobLogDao.persistCronJobLog(cronJobLog);
53+
54+
return cronJobLog;
55+
}
56+
57+
/**
58+
* Update a cronJobLog's lastRunTime
59+
*
60+
* @param jobName name of cronJob to update
61+
*/
62+
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
63+
public void updateCronJobLogLastRunTime(CronJobLogName jobName) {
64+
logger.debug("Update cronJobLog lastRunTime {}", jobName);
65+
66+
CronJobLog cronJobLog = cronJobLogDao.findCronJobLogByName(jobName);
67+
68+
if (cronJobLog == null) {
69+
cronJobLog = createCronJobLog(jobName);
70+
}
71+
72+
OffsetDateTime now = OffsetDateTime.now();
73+
cronJobLog.setLastRunTime(now);
74+
75+
}
76+
}

colab-api/src/main/java/ch/colabproject/colab/api/controller/team/InstanceMakerManager.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public List<InstanceMaker> getInstanceMakersForProject(Long projectId) {
8787
Project project = projectManager.assertAndGetProject(projectId);
8888
logger.debug("Get instanceMakers: {}", project);
8989

90-
return instanceMakerDao.findInstanceMakersByProject(project);
90+
return project.getInstanceMakers();
9191
}
9292

9393
/**
@@ -148,15 +148,19 @@ public InstanceMaker addAndPersistInstanceMaker(Project model, User user) {
148148
public InstanceMaker addInstanceMaker(Project model, User user) {
149149
logger.debug("Add instance maker to user {} for model {}", user, model);
150150

151-
if (model != null && user != null
152-
&& findInstanceMakerByProjectAndUser(model, user) != null) {
151+
if (model == null) {
152+
throw HttpErrorMessage.dataError(MessageI18nKey.DATA_INTEGRITY_FAILURE);
153+
}
154+
155+
if (user != null && findInstanceMakerByProjectAndUser(model, user) != null) {
153156
throw HttpErrorMessage.dataError(MessageI18nKey.DATA_INTEGRITY_FAILURE);
154157
}
155158

156159
InstanceMaker instanceMaker = new InstanceMaker();
157160

158161
instanceMaker.setUser(user);
159162
instanceMaker.setProject(model);
163+
model.getInstanceMakers().add(instanceMaker);
160164

161165
return instanceMaker;
162166
}

colab-api/src/main/java/ch/colabproject/colab/api/controller/user/UserManager.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import ch.colabproject.colab.api.Helper;
1010
import ch.colabproject.colab.api.controller.RequestManager;
1111
import ch.colabproject.colab.api.controller.ValidationManager;
12+
import ch.colabproject.colab.api.controller.team.InstanceMakerManager;
1213
import ch.colabproject.colab.api.controller.team.TeamManager;
1314
import ch.colabproject.colab.api.controller.token.TokenManager;
1415
import ch.colabproject.colab.api.exceptions.ColabMergeException;
@@ -36,6 +37,8 @@
3637
import javax.ejb.TransactionAttribute;
3738
import javax.ejb.TransactionAttributeType;
3839
import javax.inject.Inject;
40+
41+
import com.google.common.collect.Lists;
3942
import org.slf4j.Logger;
4043
import org.slf4j.LoggerFactory;
4144

@@ -92,6 +95,10 @@ public class UserManager {
9295
@Inject
9396
private TeamManager teamManager;
9497

98+
/** InstanceMaker specific logic management */
99+
@Inject
100+
private InstanceMakerManager instanceMakerManager;
101+
95102
/** Account persistence handling */
96103
@Inject
97104
private AccountDao accountDao;
@@ -149,7 +156,14 @@ public User getUserById(Long id) {
149156
public List<User> getUsersForProject(Long projectId) {
150157
logger.debug("Get users of project #{}", projectId);
151158

152-
return teamManager.getUsersForProject(projectId);
159+
List<User> teamMembers = teamManager.getUsersForProject(projectId);
160+
List<User> instanceMakers = instanceMakerManager.getUsersForProject(projectId);
161+
162+
List<User> allUsers = Lists.newArrayList();
163+
allUsers.addAll(teamMembers);
164+
allUsers.addAll(instanceMakers);
165+
166+
return allUsers;
153167
}
154168

155169
/**

0 commit comments

Comments
 (0)