From 77680d9f8217fa2ec13cccbc2240216cc3fc145c Mon Sep 17 00:00:00 2001 From: lhameury <43-lhameury@users.noreply.gitlab.libriciel.fr> Date: Tue, 5 Nov 2024 14:35:51 +0100 Subject: [PATCH] getDossierFromBureauAndName function now use "LANGUAGE_FTS_ALFRESCO" instead of base lucene for searching, as FTS does not need for node to be indexed to be found. "dossierService.deleteDossier" is now only called from "handleDeleteDossier", to always use worker to handle deletion --- .../parapheur/repo/ParapheurService.java | 2 + .../repo/impl/ParapheurServiceImpl.java | 49 +++++++++++++++++-- .../iparapheur/_1/InterfaceParapheurImpl.java | 8 +-- 3 files changed, 51 insertions(+), 8 deletions(-) diff --git a/iparapheur-core/src/main/java/com/atolcd/parapheur/repo/ParapheurService.java b/iparapheur-core/src/main/java/com/atolcd/parapheur/repo/ParapheurService.java index f9f0759..944f994 100755 --- a/iparapheur-core/src/main/java/com/atolcd/parapheur/repo/ParapheurService.java +++ b/iparapheur-core/src/main/java/com/atolcd/parapheur/repo/ParapheurService.java @@ -754,6 +754,8 @@ public interface ParapheurService { */ public abstract NodeRef reprendreDossier(NodeRef dossier); + void handleDeleteDossier(NodeRef dossier, NodeRef parapheur, boolean notify, String username); + File produceZipSignatures(String docFileName, NodeRef dossier) throws IOException; /** diff --git a/iparapheur-core/src/main/java/com/atolcd/parapheur/repo/impl/ParapheurServiceImpl.java b/iparapheur-core/src/main/java/com/atolcd/parapheur/repo/impl/ParapheurServiceImpl.java index fec66c6..e1d602f 100755 --- a/iparapheur-core/src/main/java/com/atolcd/parapheur/repo/impl/ParapheurServiceImpl.java +++ b/iparapheur-core/src/main/java/com/atolcd/parapheur/repo/impl/ParapheurServiceImpl.java @@ -57,6 +57,7 @@ import fr.bl.iparapheur.srci.SrciService; import fr.starxpert.iparapheur.calque.repo.CalqueService; import fr.starxpert.iparapheur.calque.repo.ImpressionCalqueService; import org.adullact.iparapheur.comparator.NameNodeRefComparator; +import org.adullact.iparapheur.repo.amq.MessagesSender; import org.adullact.iparapheur.repo.jscript.pastell.mailsec.MailsecPastellService; import org.adullact.iparapheur.repo.notification.NotificationService; import org.adullact.iparapheur.repo.worker.WorkerService; @@ -259,6 +260,8 @@ public final class ParapheurServiceImpl implements ParapheurService, Initializin private MailsecPastellService mailsecPastellService; @Autowired private SignatureService signatureService; + @Autowired + private MessagesSender messagesSender; private TransactionListener transactionListener; private String habillage; private String uploadFileSizeLimit; @@ -449,6 +452,14 @@ public final class ParapheurServiceImpl implements ParapheurService, Initializin this.usersService = usersService; } + public MessagesSender getMessagesSender() { + return messagesSender; + } + + public void setMessagesSender(MessagesSender messagesSender) { + this.messagesSender = messagesSender; + } + @Override public Properties getConfiguration() { return configuration; @@ -748,18 +759,25 @@ public final class ParapheurServiceImpl implements ParapheurService, Initializin public NodeRef getDossierFromBureauAndName(NodeRef bureauNodeRef, String dossierName) { List<NodeRef> results; Path lePrimaryPath = nodeService.getPath(bureauNodeRef); - String xpath = lePrimaryPath.toPrefixString(namespaceService) - + "/*/*[@cm:name=\"" + dossierName + "\"]"; + String xpath = lePrimaryPath.toPrefixString(namespaceService) + "/*/*"; try { if (logger.isDebugEnabled()) { logger.debug("le xpath ISO9075decode: " + ISO9075.decode(xpath) + "\nle xpath:\t" + xpath); } - results = searchService.selectNodes(nodeService.getRootNode(new StoreRef(this.configuration.getProperty("spaces.store"))), xpath, null, namespaceService, false); + String query = "PATH:\"" + xpath + "\""; + query += " AND cm:name:\"" + CakeFilter.luceneEscapeString(dossierName) + "\""; + + SearchParameters searchParameters = new SearchParameters(); + searchParameters.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO); + searchParameters.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE); + searchParameters.setQuery(query); + + results = searchService.query(searchParameters).getNodeRefs(); } catch (AccessDeniedException e) { logger.error("Impossible d'accéder au répertoire de stockage du dossier."); return null; } - if (results != null && results.size() > 0) { + if (results != null && !results.isEmpty()) { return results.get(0); } else { if (logger.isDebugEnabled()) { @@ -4358,7 +4376,8 @@ public final class ParapheurServiceImpl implements ParapheurService, Initializin // On supprime le dossier archivé logger.debug("ARCHIVER - Suppression du dossier"); - dossierService.deleteDossier(dossier, false); + handleDeleteDossier(dossier, bureauParent, false, currentUser); +// dossierService.deleteDossier(dossier, false); } catch (org.alfresco.service.cmr.model.FileExistsException ex1) { throw new RuntimeException("Une archive nommée '" + nomArchive + "' existe déjà .", ex1); } @@ -4366,6 +4385,26 @@ public final class ParapheurServiceImpl implements ParapheurService, Initializin return urlArchive; } + @Override + public void handleDeleteDossier(NodeRef dossier, NodeRef parapheur, boolean notify, String username) { + try { + JSONObject sendDeleteDossier = new JSONObject(); + + sendDeleteDossier.put(WorkerService.ID, dossier.getId()); + sendDeleteDossier.put(WorkerService.USERNAME, username); + if(notify) { + sendDeleteDossier.put(WorkerService.BUREAUCOURANT, parapheur.getId()); + } + sendDeleteDossier.put(WorkerService.ACTION, DossierService.ACTION_DOSSIER.SUPPRESSION); + sendDeleteDossier.put(WorkerService.TYPE, WorkerService.TYPE_DOSSIER); + sendDeleteDossier.put(WorkerService.NOTIFME, notify); + + messagesSender.sendWorker(sendDeleteDossier.toString(), dossier.getId()); + } catch (JSONException e) { + throw new RuntimeException(e); + } + } + private String getEntryZipName(String docName, int ordre, String signataire, List<String> existingNames) { String sigdetacheeFormat = this.configuration.getProperty("parapheur.filename.signature.detachee"); if(sigdetacheeFormat == null) { diff --git a/iparapheur-core/src/main/java/org/adullact/spring_ws/iparapheur/_1/InterfaceParapheurImpl.java b/iparapheur-core/src/main/java/org/adullact/spring_ws/iparapheur/_1/InterfaceParapheurImpl.java index 4b158bc..2d4a846 100644 --- a/iparapheur-core/src/main/java/org/adullact/spring_ws/iparapheur/_1/InterfaceParapheurImpl.java +++ b/iparapheur-core/src/main/java/org/adullact/spring_ws/iparapheur/_1/InterfaceParapheurImpl.java @@ -610,8 +610,8 @@ public class InterfaceParapheurImpl implements InterfaceParapheur, InitializingB if ((mail_id != null) && getS2lowService().isMailServiceEnabled()) { getS2lowService().deleteSecureMail(mail_id); } - - finalDossierService.deleteDossier(dossierRef, false); + parapheurService.handleDeleteDossier(dossierRef, parapheur, false, userName); +// finalDossierService.deleteDossier(dossierRef, false); msg.setCodeRetour("OK"); msg.setSeverite("INFO"); msg.setMessage("Dossier " + finalDossierID + " supprimé du Parapheur."); @@ -1003,7 +1003,8 @@ public class InterfaceParapheurImpl implements InterfaceParapheur, InitializingB res.getMessageRetour().setMessage("Le dossierID '" + effacerDossierRejeteRequest + "' n'est pas accessible."); throw new DocumentException("Le dossierID '" + effacerDossierRejeteRequest + "' n'est pas accessible."); } - this.getDossierService().deleteDossier(dossierRef, true); + parapheurService.handleDeleteDossier(dossierRef, parapheur, true, userName); +// this.getDossierService().deleteDossier(dossierRef, true); res.getMessageRetour().setCodeRetour("OK"); res.getMessageRetour().setSeverite("INFO"); res.getMessageRetour().setMessage("Dossier " + effacerDossierRejeteRequest + " supprimé du Parapheur."); @@ -2466,6 +2467,7 @@ public class InterfaceParapheurImpl implements InterfaceParapheur, InitializingB retMsg.setMessage("" + e.getMessage()); retVal.setMessageRetour(retMsg); logger.error(e.getMessage()); + e.printStackTrace(); } return retVal; } -- GitLab