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 f9f0759ad5a94bc1124497c5b8b7a4fd4df167f3..944f9944055f5c07d026dbb581807327b57ff302 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 fec66c61d8fdfec7d9208cdc92507173f9593784..e1d602f19f2e546935276a350475e26164ee8eb1 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 4b158bcb6ada6361d81741ad17ab7f4812f1a862..2d4a846293e711b6f9b8857a2c2c7f1c2bf6afff 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; }