Skip to content

Commit

Permalink
v1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemaignent committed Mar 15, 2021
1 parent f5e2dcb commit 1001990
Show file tree
Hide file tree
Showing 27 changed files with 279 additions and 219 deletions.
71 changes: 6 additions & 65 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</parent>
<groupId>org.esupportail</groupId>
<artifactId>esup-signature</artifactId>
<version>1.9.1</version>
<version>1.10-SNAPSHOT</version>
<name>esup-signature</name>
<properties>
<start-class>org.esupportail.esupsignature.EsupSignatureApplication</start-class>
Expand All @@ -38,6 +38,10 @@
<name>cefdigital</name>
<url>https://ec.europa.eu/cefdigital/artifact/content/repositories/esignaturedss/</url>
</repository>
<repository>
<id>localrepository</id>
<url>file:///${pom.basedir}/src/libs</url>
</repository>
</repositories>
<distributionManagement>
<repository>
Expand Down Expand Up @@ -385,7 +389,7 @@
<dependency>
<groupId>fr.gouv.vitam.tools</groupId>
<artifactId>sedalib</artifactId>
<version>2.5.0-SNAPSHOT</version>
<version>2.5.0</version>
<exclusions>
<exclusion>
<groupId>xerces</groupId>
Expand Down Expand Up @@ -691,69 +695,6 @@
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>droid-core</id>
<phase>initialize</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${pom.basedir}/src/libs/droid-core-6.5-VITAM.jar</file>
<groupId>uk.gov.nationalarchives</groupId>
<artifactId>droid-core</artifactId>
<version>6.5-VITAM</version>
<packaging>jar</packaging>
</configuration>
</execution>
<execution>
<id>droid-contenaire</id>
<phase>initialize</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${pom.basedir}/src/libs/droid-container-6.5-VITAM.jar</file>
<groupId>uk.gov.nationalarchives</groupId>
<artifactId>droid-container</artifactId>
<version>6.5-VITAM</version>
<packaging>jar</packaging>
</configuration>
</execution>
<execution>
<id>droid-core-interface</id>
<phase>initialize</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${pom.basedir}/src/libs/droid-core-interfaces-6.5-VITAM.jar</file>
<groupId>uk.gov.nationalarchives</groupId>
<artifactId>droid-core-interfaces</artifactId>
<version>6.5-VITAM</version>
<packaging>jar</packaging>
</configuration>
</execution>
<execution>
<id>sedalib</id>
<phase>initialize</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${pom.basedir}/src/libs/sedalib-2.5.0-SNAPSHOT.jar</file>
<groupId>fr.gouv.vitam.tools</groupId>
<artifactId>sedalib</artifactId>
<version>2.5.0-SNAPSHOT</version>
<packaging>jar</packaging>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
Expand Down
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public class SignBook {
@Transient
transient String comment;

@OneToMany
private List<User> viewers = new ArrayList<>();

public Long getId() {
return id;
}
Expand Down Expand Up @@ -172,6 +175,11 @@ public void setComment(String comment) {
this.comment = comment;
}

public List<User> getViewers() {
return viewers;
}


public void setViewers(List<User> viewers) {
this.viewers = viewers;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ public class SignRequest {
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE, orphanRemoval = true)
private Map<Recipient, Action> recipientHasSigned = new HashMap<>();

@OneToMany
private List<User> viewers = new ArrayList<>();

public Long getId() {
return id;
}
Expand Down Expand Up @@ -237,14 +234,6 @@ public void setRecipientHasSigned(Map<Recipient, Action> recipientHasSigned) {
this.recipientHasSigned = recipientHasSigned;
}

public List<User> getViewers() {
return viewers;
}

public void setViewers(List<User> viewers) {
this.viewers = viewers;
}

public List<Document> getLiteOriginalDocuments() {
List<Document> liteDocuments = new ArrayList<>();
for (Document document : this.originalDocuments) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,8 @@ public SignBook sendForSign(Data data, List<String> recipientsEmails, List<Strin
dataRepository.save(data);
signBookService.pendingSignBook(signBook, data, user.getEppn(), authUser.getEppn());
data.setStatus(SignRequestStatus.pending);
if(recipientsEmails != null) {
for (String recipientEmail : recipientsEmails) {
userPropertieService.createUserPropertieFromMails(userService.getByEppn(authUser.getEppn()), Collections.singletonList(recipientEmail.split("\\*")[1]));
}
for (String recipientEmail : recipientsEmails) {
userPropertieService.createUserPropertieFromMails(userService.getByEppn(authUser.getEppn()), Collections.singletonList(recipientEmail.split("\\*")[1]));
}
return signBook;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,12 +536,12 @@ public List<LiveWorkflowStep> getAllSteps(SignBook signBook) {
@Transactional
public void addLiveStep(Long id, String[] recipientsEmails, int stepNumber, Boolean allSignToComplete, SignType signType, boolean repeatable, String authUserEppn) throws EsupSignatureException {
SignBook signBook = this.getById(id);
int currentSetNumber = signBook.getLiveWorkflow().getCurrentStepNumber();
int currentStepNumber = signBook.getLiveWorkflow().getCurrentStepNumber();
LiveWorkflowStep liveWorkflowStep = liveWorkflowStepService.createLiveWorkflowStep(null, repeatable, allSignToComplete, signType, recipientsEmails);
if (stepNumber == -1) {
signBook.getLiveWorkflow().getLiveWorkflowSteps().add(liveWorkflowStep);
} else {
if (stepNumber >= currentSetNumber) {
if (stepNumber >= currentStepNumber) {
signBook.getLiveWorkflow().getLiveWorkflowSteps().add(stepNumber, liveWorkflowStep);
} else {
throw new EsupSignatureException("L'étape ne peut pas être ajoutée");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,12 @@ public void initSignrequestMetrics() {
}

public SignRequest getById(long id) {
Optional<SignRequest> signRequest = signRequestRepository.findById(id);
return signRequest.orElse(null);
SignRequest signRequest = signRequestRepository.findById(id).get();
Data data = dataService.getBySignBook(signRequest.getParentSignBook());
if(data != null) {
signRequest.setData(data);
}
return signRequest;
}

public List<SignRequest> getSignRequestsByToken(String token) {
Expand Down Expand Up @@ -712,7 +716,7 @@ public void sendSignRequestsToTarget(List<SignRequest> signRequests, String titl
try {
for (SignRequest signRequest : signRequests) {
for (String email : targetUrl.split(";")) {
signRequest.getViewers().add(userService.getUserByEmail(email));
signRequest.getParentSignBook().getViewers().add(userService.getUserByEmail(email));
}
}
mailService.sendFile(title, signRequests, targetUrl);
Expand Down Expand Up @@ -845,7 +849,7 @@ public boolean checkUserSignRights(SignRequest signRequest, String userEppn, Str
public boolean checkUserViewRights(SignRequest signRequest, String userEppn, String authUserEppn) {
if(userEppn.equals(authUserEppn) || userShareService.checkShare(userEppn, authUserEppn, signRequest)) {
List<SignRequest> signRequests = signRequestRepository.findByIdAndRecipient(signRequest.getId(), userEppn);
if(signRequest.getCreateBy().getEppn().equals(userEppn) || signRequest.getViewers().contains(userService.getUserByEppn(authUserEppn)) || signRequests.size() > 0) {
if(signRequest.getCreateBy().getEppn().equals(userEppn) || signRequest.getParentSignBook().getViewers().contains(userService.getUserByEppn(authUserEppn)) || signRequests.size() > 0) {
return true;
}
}
Expand Down Expand Up @@ -995,7 +999,7 @@ public boolean isTempUsers(Long signRequestId) {
}
return isTempUsers;
}

public boolean checkTempUsers(Long id, List<String> recipientEmails, String[] names, String[] firstnames, String[] phones) throws MessagingException {
SignRequest signRequest = getById(id);
List<User> tempUsers = userService.getTempUsers(signRequest, recipientEmails);
Expand Down Expand Up @@ -1110,8 +1114,15 @@ public void addStep(Long id, String[] recipientsEmails, SignType signType, Boole
}

@Transactional
public Map<SignBook, String> sendSignRequest(MultipartFile[] multipartFiles, String[] recipientsEmails, Boolean allSignToComplete, Boolean userSignFirst, Boolean pending, String comment, SignType signType, User user, User authUser) throws EsupSignatureException, EsupSignatureIOException {
public Map<SignBook, String> sendSignRequest(MultipartFile[] multipartFiles, String[] recipientsEmails, String[] recipientsCCEmails, Boolean allSignToComplete, Boolean userSignFirst, Boolean pending, String comment, SignType signType, User user, User authUser) throws EsupSignatureException, EsupSignatureIOException {
SignBook signBook = signBookService.addDocsInNewSignBookSeparated("", "Demande simple", multipartFiles, user);
List<User> viewers = new ArrayList<>();
if(recipientsCCEmails != null) {
for (String recipientsEmail : recipientsCCEmails) {
viewers.add(userService.getUserByEmail(recipientsEmail));
}
signBook.setViewers(viewers);
}
return signBookService.sendSignBook(signBook, recipientsEmails, allSignToComplete, userSignFirst, pending, comment, signType, user, authUser);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ public void sendCompletedMail(SignBook signBook) throws EsupSignatureException {
message.setSubject("Esup-Signature : demande signature terminée");
message.setFrom(mailConfig.getIfAvailable().getMailFrom());
message.setTo(user.getEmail());
String[] viewersArray = new String[signBook.getViewers().size()];
for (int i = 0 ; i < signBook.getViewers().size() ; i++) {
viewersArray[i] = signBook.getViewers().get(i).getEmail();
}
message.setCc(viewersArray);
String htmlContent = templateEngine.process("mail/email-completed.html", ctx);
message.setText(htmlContent, true);
logger.info("send email completes for " + user.getEppn());
Expand Down Expand Up @@ -111,6 +116,11 @@ public void sendRefusedMail(SignBook signBook, String comment) {
message.setSubject("Esup-Signature : demande signature refusée");
message.setFrom(mailConfig.getIfAvailable().getMailFrom());
message.setTo(toEmails.toArray(String[]::new));
String[] viewersArray = new String[signBook.getViewers().size()];
for (int i = 0 ; i < signBook.getViewers().size() ; i++) {
viewersArray[i] = signBook.getViewers().get(i).getEmail();
}
message.setCc(viewersArray);
String htmlContent = templateEngine.process("mail/email-refused.html", ctx);
message.setText(htmlContent, true);
logger.info("send email refude for " + toEmails.get(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import io.swagger.v3.oas.annotations.Hidden;
import org.apache.commons.io.IOUtils;
import org.esupportail.esupsignature.entity.*;
import org.esupportail.esupsignature.entity.enums.SignRequestStatus;
import org.esupportail.esupsignature.exception.EsupSignatureException;
import org.esupportail.esupsignature.exception.EsupSignatureIOException;
import org.esupportail.esupsignature.service.*;
Expand Down Expand Up @@ -103,28 +102,17 @@ public String show(@ModelAttribute("userEppn") String userEppn, @PathVariable("i
}
}

@GetMapping("form/{id}")
@PostMapping("sendForm/{id}")
public String updateData(@ModelAttribute("userEppn") String userEppn, @ModelAttribute("authUserEppn") String authUserEppn,
@PathVariable("id") Long id,
@RequestParam(required = false) Integer page, Model model, RedirectAttributes redirectAttributes) {
@RequestParam(required = false) List<String> recipientEmails,
@RequestParam(required = false) List<String> targetEmails,
@PathVariable("id") Long id, Model model, RedirectAttributes redirectAttributes) throws EsupSignatureIOException, EsupSignatureException {
User user = (User) model.getAttribute("user");
User authUser = (User) model.getAttribute("authUser");
if(formService.isFormAuthorized(userEppn, authUserEppn, id)) {
if (page == null) {
page = 1;
}
Form form = formService.getById(id);
model.addAttribute("form", form);
model.addAttribute("fields", dataService.getPrefilledFields(form, user));
model.addAttribute("data", new Data());
model.addAttribute("activeForm", form.getName());
model.addAttribute("page", page);
String message = formService.getHelpMessage(user, form);
if(message != null) {
model.addAttribute("message", new JsonMessage("help", message));
}
Data data = dataService.addData(id, user, authUser);
return "redirect:/user/datas/" + data.getId() + "/update";
SignBook signBook = dataService.sendForSign(data, recipientEmails, targetEmails, user, authUser);
return "redirect:/user/signrequests/" + signBook.getSignRequests().get(0).getId();
} else {
redirectAttributes.addFlashAttribute("message", new JsonMessage("error", "Formulaire non autorisé"));
return "redirect:/user/";
Expand All @@ -136,22 +124,7 @@ public String updateData(@ModelAttribute("userEppn") String userEppn, @ModelAttr
@GetMapping("{id}/update")
public String updateData(@ModelAttribute("userEppn") String userEppn, @PathVariable("id") Long id, Model model) throws EsupSignatureException {
Data data = dataService.getById(id);
model.addAttribute("data", data);
if(data.getStatus().equals(SignRequestStatus.draft)) {
Form form = data.getForm();
model.addAttribute("fields", dataService.setFieldsDefaultsValues(data, form, userService.getUserByEppn(userEppn)));
if (data.getSignBook() != null && recipientService.needSign(data.getSignBook().getLiveWorkflow().getCurrentStep().getRecipients(), userEppn)) {
model.addAttribute("toSign", true);
}
Workflow workflow = workflowService.computeWorkflow(data.getForm().getWorkflow().getId(), null, userEppn, true);
model.addAttribute("steps", workflow.getWorkflowSteps());
model.addAttribute("form", form);
model.addAttribute("activeForm", form.getName());
model.addAttribute("document", form.getDocument());
return "user/datas/create";
} else {
return "redirect:/user/datas/" + data.getId();
}
return "redirect:/user/signrequests/" + data.getSignBook().getSignRequests().get(0).getId();
}

@PostMapping("form/{id}")
Expand All @@ -176,27 +149,6 @@ public String addData(@ModelAttribute("userEppn") String userEppn, @ModelAttribu
return data.getId().toString();
}

// @PutMapping("{id}")
// public String updateData(@ModelAttribute("userEppn") String userEppn, @PathVariable("id") Long id, @RequestParam String name, @RequestParam(required = false) String navPage, @RequestParam(required = false) Integer page, @RequestParam MultiValueMap<String, String> formData, RedirectAttributes redirectAttributes) {
// User user = userService.getUserById(userEppn);
// Data data = dataService.getById(id);
// if(page == null) {
// page = 1;
// }
// if("next".equals(navPage)) {
// page++;
// } else if("prev".equals(navPage)) {
// page--;
// }
// dataService.setDatas(name, formData, data);
// redirectAttributes.addAttribute("page", page);
// if(navPage != null && !navPage.isEmpty()) {
// return "redirect:/user/" + userEppn + "/data/" + data.getId() + "/update?page=" + page;
// } else {
// return "redirect:/user/" + userEppn + "/data/" + data.getId();
// }
// }

@PreAuthorize("@preAuthorizeService.dataUpdate(#id, #userEppn)")
@PostMapping("{id}/send")
public String sendDataById(@ModelAttribute("userEppn") String userEppn, @ModelAttribute("authUserEppn") String authUserEppn,
Expand Down
Loading

0 comments on commit 1001990

Please sign in to comment.