Skip to content

Commit b19eb86

Browse files
authored
Merge pull request #457 from EsupPortail/test
Test
2 parents 27e157b + f089e4e commit b19eb86

Some content is hidden

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

47 files changed

+1020
-1011
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</parent>
1313
<groupId>org.esupportail</groupId>
1414
<artifactId>esup-signature</artifactId>
15-
<version>1.30.1</version>
15+
<version>1.30.3-SNAPSHOT</version>
1616
<name>esup-signature</name>
1717
<properties>
1818
<startClass>org.esupportail.esupsignature.EsupSignatureApplication</startClass>

src/main/java/org/esupportail/esupsignature/repository/SignBookRepository.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,12 @@ and size(sb.signRequests) > 0
6565
and (:docTitleFilter is null or sb.subject = :docTitleFilter)
6666
and (:recipientUser is null or key(rhs).user = :recipientUser or :recipientUser in (u))
6767
and (:creatorFilter is null or sb.createBy = :creatorFilter)
68+
and (:statusFilter is null or sb.status = :statusFilter)
69+
and sb.status <> 'deleted' and (sb.deleted is null or sb.deleted != true)
6870
and size(sb.signRequests) > 0
6971
and (sb.createDate between :startDateFilter and :endDateFilter)
7072
""")
71-
Page<SignBook> findByWorkflowName(User recipientUser, String workflowFilter, String docTitleFilter, User creatorFilter, Date startDateFilter, Date endDateFilter, Pageable pageable);
73+
Page<SignBook> findByWorkflowName(User recipientUser, SignRequestStatus statusFilter, String workflowFilter, String docTitleFilter, User creatorFilter, Date startDateFilter, Date endDateFilter, Pageable pageable);
7274

7375
@Query("""
7476
select distinct sb.subject from SignBook sb

src/main/java/org/esupportail/esupsignature/service/FieldPropertieService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ private void addPropertie(User user, Field field, String value) {
4343
fieldPropertieRepository.save(fieldPropertie);
4444
}
4545

46+
@Transactional
4647
public List<String> getFavoritesValues(String userEppn, Long id) {
4748
List<String> favoriteValues = new ArrayList<>();
4849
FieldPropertie fieldPropertie = getFieldPropertie(id, userEppn);

src/main/java/org/esupportail/esupsignature/service/SignBookService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public Long nbToSignSignBooks(String userEppn) {
184184
}
185185

186186
@Transactional
187-
public Page<SignBook> getSignBooksForManagers(String userEppn, String authUserEppn, String statusFilter, String recipientsFilter, String workflowFilter, String docTitleFilter, String creatorFilter, String dateFilter, Pageable pageable) {
187+
public Page<SignBook> getSignBooksForManagers(String userEppn, String authUserEppn, SignRequestStatus statusFilter, String recipientsFilter, String workflowFilter, String docTitleFilter, String creatorFilter, String dateFilter, Pageable pageable) {
188188
User creatorFilterUser = null;
189189
if(creatorFilter != null) {
190190
creatorFilterUser = userService.getByEppn(creatorFilter);
@@ -210,7 +210,7 @@ public Page<SignBook> getSignBooksForManagers(String userEppn, String authUserEp
210210
logger.error("unable to parse date : " + dateFilter);
211211
}
212212
}
213-
return signBookRepository.findByWorkflowName(userFilter, workflowFilter, docTitleFilter, creatorFilterUser, startDateFilter, endDateFilter, pageable);
213+
return signBookRepository.findByWorkflowName(userFilter, statusFilter, workflowFilter, docTitleFilter, creatorFilterUser, startDateFilter, endDateFilter, pageable);
214214
}
215215

216216
@Transactional

src/main/java/org/esupportail/esupsignature/service/mail/MailService.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
package org.esupportail.esupsignature.service.mail;
22

3+
import jakarta.annotation.Resource;
4+
import jakarta.mail.MessagingException;
5+
import jakarta.mail.internet.MimeMessage;
6+
import jakarta.transaction.Transactional;
37
import org.apache.commons.lang.BooleanUtils;
48
import org.apache.commons.lang.StringUtils;
9+
import org.eclipse.angus.mail.smtp.SMTPAddressFailedException;
510
import org.esupportail.esupsignature.config.GlobalProperties;
611
import org.esupportail.esupsignature.config.mail.MailConfig;
712
import org.esupportail.esupsignature.entity.*;
@@ -13,7 +18,6 @@
1318
import org.esupportail.esupsignature.service.UserShareService;
1419
import org.esupportail.esupsignature.service.ldap.entry.OrganizationalUnitLdap;
1520
import org.esupportail.esupsignature.service.ldap.entry.PersonLdap;
16-
import org.esupportail.esupsignature.entity.Otp;
1721
import org.esupportail.esupsignature.service.utils.file.FileService;
1822
import org.jetbrains.annotations.NotNull;
1923
import org.slf4j.Logger;
@@ -30,10 +34,6 @@
3034
import org.thymeleaf.TemplateEngine;
3135
import org.thymeleaf.context.Context;
3236

33-
import jakarta.annotation.Resource;
34-
import jakarta.mail.MessagingException;
35-
import jakarta.mail.internet.MimeMessage;
36-
import jakarta.transaction.Transactional;
3737
import java.io.IOException;
3838
import java.io.InputStreamReader;
3939
import java.io.Reader;
@@ -483,7 +483,9 @@ private void sendMail(MimeMessage mimeMessage, Workflow workflow) {
483483
mailSender.send(mimeMessage);
484484
}
485485
} catch (MessagingException e) {
486-
throw new RuntimeException(e);
486+
if(!(e instanceof SMTPAddressFailedException)) {
487+
throw new RuntimeException(e);
488+
}
487489
}
488490
}
489491

src/main/java/org/esupportail/esupsignature/service/security/otp/OtpService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ public boolean generateOtpForSignRequest(Long id, Long extUserId, String phone)
8383
String urlId = UUID.randomUUID().toString();
8484
otp.setUrlId(urlId);
8585
signBook.setLastOtp(urlId);
86-
removeOtpFromCache(extUser.getEppn());
87-
removeOtpFromCache(extUser.getEmail());
86+
removeOtpFromCache(extUser.getEppn(), signBook);
87+
removeOtpFromCache(extUser.getEmail(), signBook);
8888
otpCache.put(urlId, otp);
8989
if(StringUtils.hasText(phone)) {
9090
userService.updatePhone(extUser.getEppn(), phone);
@@ -98,9 +98,9 @@ public boolean generateOtpForSignRequest(Long id, Long extUserId, String phone)
9898
}
9999
}
100100

101-
public void removeOtpFromCache(String searchString) {
101+
public void removeOtpFromCache(String searchString, SignBook signBook) {
102102
for (Map.Entry<String, Otp> otpEntry : otpCache.asMap().entrySet()) {
103-
if(otpEntry.getValue().getUser().getEmail().equals(searchString) || (otpEntry.getValue().getPhoneNumber() != null && otpEntry.getValue().getPhoneNumber().equals(searchString))) {
103+
if(otpEntry.getValue().getSignBook().equals(signBook) && (otpEntry.getValue().getUser().getEmail().equals(searchString) || (otpEntry.getValue().getPhoneNumber() != null && otpEntry.getValue().getPhoneNumber().equals(searchString)))) {
104104
clearOTP(otpEntry.getKey());
105105
}
106106
}

src/main/java/org/esupportail/esupsignature/web/controller/admin/IndexAdminController.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,8 @@ public String index() {
4343
return "admin/index";
4444
}
4545

46+
@GetMapping("/trigger-error")
47+
public String triggerError() {
48+
throw new RuntimeException("Test error 500");
49+
}
4650
}

src/main/java/org/esupportail/esupsignature/web/controller/user/ManageController.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.springframework.security.access.prepost.PreAuthorize;
2121
import org.springframework.stereotype.Controller;
2222
import org.springframework.ui.Model;
23+
import org.springframework.util.StringUtils;
2324
import org.springframework.web.bind.annotation.*;
2425
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
2526

@@ -77,7 +78,10 @@ public String list(@ModelAttribute("userEppn") String userEppn, @ModelAttribute(
7778
@RequestParam(value = "creatorFilter", required = false) String creatorFilter,
7879
@RequestParam(value = "dateFilter", required = false) String dateFilter,
7980
@SortDefault(value = "createDate", direction = Sort.Direction.DESC) @PageableDefault(size = 10) Pageable pageable, @PathVariable Long id, Model model) {
80-
if(statusFilter == null || statusFilter.equals("all")) statusFilter = "";
81+
SignRequestStatus signRequestStatus = null;
82+
if(StringUtils.hasText(statusFilter) && !statusFilter.equals("all")) {
83+
signRequestStatus = SignRequestStatus.valueOf(statusFilter);
84+
}
8185
if(creatorFilter == null || creatorFilter.isEmpty() || creatorFilter.equals("all")) {
8286
creatorFilter = "%";
8387
}
@@ -95,7 +99,7 @@ public String list(@ModelAttribute("userEppn") String userEppn, @ModelAttribute(
9599
model.addAttribute("creatorFilter", creatorFilter);
96100
model.addAttribute("statusFilter", statusFilter);
97101
model.addAttribute("workflow", workflow);
98-
Page<SignBook> signBooks = signBookService.getSignBooksForManagers(userEppn, authUserEppn, statusFilter, recipientsFilter, workflow.getDescription(), docTitleFilter, creatorFilter, dateFilter, pageable);
102+
Page<SignBook> signBooks = signBookService.getSignBooksForManagers(userEppn, authUserEppn, signRequestStatus, recipientsFilter, workflow.getDescription(), docTitleFilter, creatorFilter, dateFilter, pageable);
99103
model.addAttribute("signBooks", signBooks);
100104
model.addAttribute("docTitles", signBookService.getSignBooksForManagersSubjects(workflow.getDescription()));
101105
model.addAttribute("creators", signBookService.getSignBooksForManagersCreators(workflow.getDescription()));

src/main/java/org/esupportail/esupsignature/web/controller/user/SignBookController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public String list(@ModelAttribute("userEppn") String userEppn, @ModelAttribute(
8686
@RequestParam(value = "docTitleFilter", required = false) String docTitleFilter,
8787
@RequestParam(value = "creatorFilter", required = false) String creatorFilter,
8888
@RequestParam(value = "dateFilter", required = false) String dateFilter,
89-
@SortDefault(value = "createDate", direction = Sort.Direction.DESC) @PageableDefault(size = 10) Pageable pageable, Model model) {
89+
@SortDefault(value = "createDate", direction = Sort.Direction.DESC) @PageableDefault(size = 15) Pageable pageable, Model model) {
9090
if(statusFilter == null || statusFilter.equals("all")) statusFilter = "";
9191
if(workflowFilter != null && (workflowFilter.isEmpty() || workflowFilter.equals("all"))) {
9292
workflowFilter = null;

src/main/java/org/esupportail/esupsignature/web/ws/FormWsController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public ResponseEntity<?> start(@PathVariable Long id,
147147
}
148148
} catch (Exception e) {
149149
logger.error(e.getMessage(), e);
150-
return ResponseEntity.ok("-1");
150+
return ResponseEntity.internalServerError().body("-1");
151151
}
152152
}
153153

@@ -207,7 +207,7 @@ public ResponseEntity<?> startWithDoc(@PathVariable Long id,
207207
}
208208
} catch (Exception e) {
209209
logger.error(e.getMessage(), e);
210-
return ResponseEntity.ok("-1");
210+
return ResponseEntity.internalServerError().body("-1");
211211
}
212212
}
213213

src/main/java/org/esupportail/esupsignature/web/ws/SignRequestWsController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ public ResponseEntity<?> create(@Parameter(description = "Multipart stream du fi
138138
}
139139
} catch (EsupSignatureException e) {
140140
logger.error(e.getMessage(), e);
141-
return ResponseEntity.ok("-1");
141+
return ResponseEntity.internalServerError().body("-1");
142142
}
143143
}
144-
return ResponseEntity.ok("-1");
144+
return ResponseEntity.internalServerError().body("-1");
145145
}
146146

147147
@CrossOrigin

src/main/java/org/esupportail/esupsignature/web/ws/WorkflowWsController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public ResponseEntity<?> start(@PathVariable Long id,
127127
}
128128
} catch (EsupSignatureRuntimeException e) {
129129
logger.error(e.getMessage(), e);
130-
return ResponseEntity.ok("-1");
130+
return ResponseEntity.internalServerError().body("-1");
131131
}
132132
}
133133

src/main/resources/application.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,9 @@ server:
263263
mbeanregistry:
264264
enabled: true
265265
remoteip:
266+
protocol-header: X-Forwarded-Proto
266267
remote-ip-header: X-Forwarded-For
268+
# internal-proxies: 192\\.168\\.\\d{1,3}\\.\\d{1,3}
267269
basedir: ./temp
268270
max-swallow-size: -1
269271
sign:

src/main/resources/static/css/layout.css

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ header {
7373

7474
.table-fix-head {
7575
overflow-y: auto;
76-
height: calc(100vh - 250px);
76+
height: calc(100vh - 150px);
7777
}
7878

7979
.table-fix-head thead th {
@@ -105,10 +105,6 @@ header {
105105
overflow: auto;
106106
}
107107

108-
.workflow-button {
109-
z-index: 10;
110-
}
111-
112108
.workspace {
113109
margin-top: 128px;
114110
display: flex;
@@ -162,6 +158,7 @@ header {
162158

163159
.workflow-btn {
164160
height: 170px;
161+
z-index: 10;
165162
}
166163

167164
.workflow-btn-perso {

src/main/resources/static/css/overrides.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,10 @@ textarea:invalid {
440440
max-height: 80%;
441441
}
442442

443+
.card {
444+
border: 0;
445+
}
446+
443447
.card-header {
444448
font-weight: bold;
445449
}

src/main/resources/static/css/style.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ td {
138138
border-radius: 4px;
139139
border: 1px solid black;
140140
box-shadow: 0 0 5px rgba(0, 0, 0, 0.02) inset;
141+
background-color: white;
141142
}
142143

143144
#sidebar {
@@ -546,7 +547,7 @@ input:focus, textarea:focus, select:focus {
546547
white-space: normal;
547548
cursor: pointer;
548549
border: 0;
549-
border-radius: .125rem;
550+
border-radius: .3rem;
550551
-webkit-box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16), 0 2px 10px 0 rgba(0,0,0,0.12) !important;
551552
box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16), 0 2px 10px 0 rgba(0,0,0,0.12) !important;
552553
-webkit-transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,-webkit-box-shadow 0.15s ease-in-out !important;

src/main/resources/static/js/modules/ui/signbooks/ListSignBooksUi.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ export class ListSignBooksUi {
257257
if(urlParams.get("sort") != null) {
258258
sort = urlParams.get("sort");
259259
}
260-
$.get("/" + this.mode + "/signbooks/list-ws?statusFilter=" + this.statusFilter + "&sort=" + sort + "&recipientsFilter=" + this.recipientsFilter + "&workflowFilter=" + this.workflowFilter + "&docTitleFilter=" + this.docTitleFilter + "&" + this.csrf.parameterName + "=" + this.csrf.token + "&page=" + this.page + "&size=10", function (data) {
260+
$.get("/" + this.mode + "/signbooks/list-ws?statusFilter=" + this.statusFilter + "&sort=" + sort + "&recipientsFilter=" + this.recipientsFilter + "&workflowFilter=" + this.workflowFilter + "&docTitleFilter=" + this.docTitleFilter + "&" + this.csrf.parameterName + "=" + this.csrf.token + "&page=" + this.page + "&size=15", function (data) {
261261
self.signRequestTable.append(data);
262262
let clickableRows = $(".clickable-row");
263263
clickableRows.unbind();

src/main/resources/static/js/modules/ui/signrequests/SignPosition.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class SignPosition extends EventFactory {
4646
self.scrollTop = $(this).scrollTop();
4747
});
4848
$(document).ready(function() {
49-
if(self.signImages.length === 1) {
49+
if(self.signImages != null && self.signImages.length === 1) {
5050
self.popUserUi();
5151
}
5252
});

src/main/resources/templates/admin/currentsessions.html

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -14,51 +14,51 @@
1414
</ol>
1515
</nav>
1616
<div id="content" class="content">
17-
<div class="card col-lg-10 mx-auto mb-1">
17+
<div class="card text-bg-light col-lg-11 m-2">
18+
<div class="card-header bg-transparent border-light-subtle p-0 pt-1">
19+
<h5 class="ms-4"><b>Sessions courantes</b></h5>
20+
</div>
1821
<div class="card-body">
19-
<h5 class="text-center"><b>Utilisateurs connectés</b></h5>
2022
<span th:text="${httpSessions.size()} + ' session(s) ouverte(s)'"></span>
2123
</div>
2224
</div>
23-
<div class="card mb-1 col-10 mx-auto">
24-
<div class="card-body">
25-
<table class="table table-hover table-responsive">
26-
<tr class="table-secondary">
27-
<th>EPPN</th>
28-
<th>Session ID</th>
29-
<th>Creation time</th>
30-
<th>Remote Ip</th>
31-
<th>Url d'origine</th>
32-
<th>Last access time</th>
33-
<th>Inactif depuis</th>
34-
<th>Alive</th>
35-
<th>Delete</th>
36-
</tr>
37-
<tr th:each="httpSession : ${httpSessions}" th:class="${httpSession.userEppn == null && httpSession.originRequestUri != '/login/casentry'} ? 'table-danger' : ''">
38-
<!--/*@thymesVar id="httpSession" type="org.springframework.session.MapSession"*/-->
39-
<td th:if="${httpSession.userEppn != null}">
40-
<input type="text" th:value="${httpSession.userEppn}" disabled>
41-
</td>
42-
<td th:unless="${httpSession.userEppn != null}">Anonyme</td>
43-
<td th:text="${httpSession.sessionId}"></td>
44-
<td th:text="${#dates.format(httpSession.createdDate, 'dd/MM/yyyy HH:mm:ss')}"></td>
45-
<td th:text="${httpSession.remoteIp}"></td>
46-
<td th:text="${httpSession.originRequestUri}"></td>
47-
<td th:text="${#dates.format(httpSession.lastRequest, 'dd/MM/yyyy HH:mm:ss')}"></td>
48-
<td><span th:if="${httpSession.lastRequest != null}" th:text="${(#dates.createNow().toInstant().toEpochMilli() - httpSession.lastRequest.toInstant().toEpochMilli()) / 1000 / 60 + ' mins'}"></span></td>
49-
<td>
50-
<i th:class="${httpSession.expired} ? 'text-danger fa-solid fa-times-circle' : 'text-success fa-solid fa-check-circle'"></i>
51-
</td>
52-
<td>
53-
<form th:action="'/admin/currentsessions'" th:method="'delete'">
54-
<input type="hidden" name="sessionId" th:value="${httpSession.sessionId}"/>
55-
<button type="submit" class="btn btn-sm btn-danger"><i
56-
class="fa-solid fa-trash-alt"></i></button>
57-
</form>
58-
</td>
59-
</tr>
60-
</table>
61-
</div>
25+
<div class="table-fix-head scrollbar-style rounded-3 col-sm-9 col-md-10 col-xl-11 p-0 m-2">
26+
<table class="table table-hover table-responsive">
27+
<tr class="table-secondary">
28+
<th>EPPN</th>
29+
<th>Session ID</th>
30+
<th>Creation time</th>
31+
<th>Remote Ip</th>
32+
<th>Url d'origine</th>
33+
<th>Last access time</th>
34+
<th>Inactif depuis</th>
35+
<th>Alive</th>
36+
<th>Delete</th>
37+
</tr>
38+
<tr th:each="httpSession : ${httpSessions}" th:class="${httpSession.userEppn == null && httpSession.originRequestUri != '/login/casentry'} ? 'table-danger' : ''">
39+
<!--/*@thymesVar id="httpSession" type="org.springframework.session.MapSession"*/-->
40+
<td th:if="${httpSession.userEppn != null}">
41+
<input type="text" th:value="${httpSession.userEppn}" disabled>
42+
</td>
43+
<td th:unless="${httpSession.userEppn != null}">Anonyme</td>
44+
<td th:text="${httpSession.sessionId}"></td>
45+
<td th:text="${#dates.format(httpSession.createdDate, 'dd/MM/yyyy HH:mm:ss')}"></td>
46+
<td th:text="${httpSession.remoteIp}"></td>
47+
<td th:text="${httpSession.originRequestUri}"></td>
48+
<td th:text="${#dates.format(httpSession.lastRequest, 'dd/MM/yyyy HH:mm:ss')}"></td>
49+
<td><span th:if="${httpSession.lastRequest != null}" th:text="${(#dates.createNow().toInstant().toEpochMilli() - httpSession.lastRequest.toInstant().toEpochMilli()) / 1000 / 60 + ' mins'}"></span></td>
50+
<td>
51+
<i th:class="${httpSession.expired} ? 'text-danger fa-solid fa-times-circle' : 'text-success fa-solid fa-check-circle'"></i>
52+
</td>
53+
<td>
54+
<form th:action="'/admin/currentsessions'" th:method="'delete'">
55+
<input type="hidden" name="sessionId" th:value="${httpSession.sessionId}"/>
56+
<button type="submit" class="btn btn-sm btn-danger"><i
57+
class="fa-solid fa-trash-alt"></i></button>
58+
</form>
59+
</td>
60+
</tr>
61+
</table>
6262
</div>
6363
</div>
6464
</div>

0 commit comments

Comments
 (0)