r1034 - in trunk: coser-business/src/main/java/fr/ifremer/coser/services coser-business/src/main/resources/i18n coser-web/src/main/java/fr/ifremer/coser/web/actions
Author: echatellier Date: 2012-08-09 17:38:09 +0200 (Thu, 09 Aug 2012) New Revision: 1034 Url: http://forge.codelutin.com/repositories/revision/coser/1034 Log: fixes #1333 : Am?\195?\169liorer le contenu du mail de mise ?\195?\160 jour des donn?\195?\169es du site Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/UploadResultAction.java Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java 2012-08-09 10:36:21 UTC (rev 1033) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java 2012-08-09 15:38:09 UTC (rev 1034) @@ -692,10 +692,11 @@ * TODO chatellier 20110125 l'algorithme n'est pour l'instant pas performant * et contient pas mal de code dupliqué, mais pour la v1.0 ca ira. * + * @param login user login * @param archiveFile uploaded file * @throws CoserBusinessException */ - public void registerNewUploadedResults(File archiveFile) throws CoserBusinessException { + public void registerNewUploadedResults(String login, File archiveFile) throws CoserBusinessException { try { @@ -708,31 +709,29 @@ // suppression des resultats qui ont été envoyé mais // ne sont ni maps result, ni indicator result - List<String> noIndicatorsResultZoneIds = getZonesIds(tempDirectory, false, null); - cleanCurrentProjectDirectory(projectsDirectory, noIndicatorsResultZoneIds); - List<String> noMapsResultZoneIds = getZonesIds(tempDirectory, null, false); - cleanCurrentProjectDirectory(mapsDirectory, noMapsResultZoneIds); + Map<String, String> noIndicatorsResultZoneIds = getZonesIds(tempDirectory, false, null); + cleanCurrentProjectDirectory(projectsDirectory, noIndicatorsResultZoneIds.keySet()); + Map<String, String> noMapsResultZoneIds = getZonesIds(tempDirectory, null, false); + cleanCurrentProjectDirectory(mapsDirectory, noMapsResultZoneIds.keySet()); // recuperation des noms zone des nouveau fichiers - List<String> indicatorsResultZoneIds = getZonesIds(tempDirectory, true, false); + Map<String, String> indicatorsResultZoneIds = getZonesIds(tempDirectory, true, false); // suppression dans l'ancien répertoire des resultat deja present // dans le nouveau (pour les conflits) - cleanCurrentProjectDirectory(projectsDirectory, indicatorsResultZoneIds); + cleanCurrentProjectDirectory(projectsDirectory, indicatorsResultZoneIds.keySet()); // creation du filter qui copiera juste ce qu'il faut FileFilter indicatorsFileFilter = getCopyFileFilter(tempDirectory, false); // copie (avec ecrasement) des nouveaux fichiers dans l'ancien répertoire - //FileUtils.copyDirectory(tempDirectory, projectsDirectory, indicatorsFileFilter); customCopyDirectory(tempDirectory, projectsDirectory, indicatorsFileFilter); // recuperation des noms zone des nouveau fichiers - List<String> mapsResultZoneIds = getZonesIds(tempDirectory, false, true); + Map<String, String> mapsResultZoneIds = getZonesIds(tempDirectory, false, true); // suppression dans l'ancien répertoire des resultat deja present // dans le nouveau (pour les conflits) - cleanCurrentProjectDirectory(mapsDirectory, mapsResultZoneIds); + cleanCurrentProjectDirectory(mapsDirectory, mapsResultZoneIds.keySet()); // creation du filter qui copiera juste ce qu'il faut FileFilter mapsFileFilter = getCopyFileFilter(tempDirectory, true); // copie (avec ecrasement) des nouveaux fichiers dans l'ancien répertoire - //FileUtils.copyDirectory(tempDirectory, mapsDirectory, mapsFileFilter); customCopyDirectory(tempDirectory, mapsDirectory, mapsFileFilter); FileUtils.deleteDirectory(tempDirectory); @@ -741,8 +740,42 @@ log.info("Unzipping file " + archiveFile + " to " + projectsDirectory); } + // generate email content + StringBuffer content = new StringBuffer(); + if (!noMapsResultZoneIds.isEmpty() || !mapsResultZoneIds.isEmpty()) { + content.append(_("coser.business.notificationmail.mapsresults") + "\n"); + for (Map.Entry<String, String> noMapsResultZoneId : noMapsResultZoneIds.entrySet()) { + content.append(" - " + _("coser.business.notificationmail.deleted", + getZoneFullName(noMapsResultZoneId.getKey()), + noMapsResultZoneId.getValue()) + "\n"); + } + for (Map.Entry<String, String> mapsResultZoneId : mapsResultZoneIds.entrySet()) { + content.append(" - " + _("coser.business.notificationmail.added", + getZoneFullName(mapsResultZoneId.getKey()), + mapsResultZoneId.getValue()) + "\n"); + } + content.append("\n"); + } + + if (!noIndicatorsResultZoneIds.isEmpty() || !indicatorsResultZoneIds.isEmpty()) { + content.append(_("coser.business.notificationmail.indicatorsresults") + "\n"); + for (Map.Entry<String, String> noIndicatorsResultZoneId : noIndicatorsResultZoneIds.entrySet()) { + content.append(" - " + _("coser.business.notificationmail.deleted", + getZoneFullName(noIndicatorsResultZoneId.getKey()), + noIndicatorsResultZoneId.getValue()) + "\n"); + } + for (Map.Entry<String, String> indicatorsResultZoneId : indicatorsResultZoneIds.entrySet()) { + content.append(" - " + _("coser.business.notificationmail.added", + getZoneFullName(indicatorsResultZoneId.getKey()), + indicatorsResultZoneId.getValue()) + "\n"); + } + content.append("\n"); + } + // send notification mails - sendNewResultNotifications(); + int count = noMapsResultZoneIds.size() + mapsResultZoneIds.size() + + noIndicatorsResultZoneIds.size() + indicatorsResultZoneIds.size(); + sendNewResultNotifications(login, count, content.toString()); // update data date updateDataProperties(); @@ -850,7 +883,8 @@ } /** - * Recupere dans un repertoire donné, les zoneid des resultat. + * Recupere dans un repertoire donné, les zoneid des resultat avec + * pour chaque id, le nom du projet associé. * * Les boolean sont des grands {@code Boolean} car si la valeur * est {@code null}, on ne tient pas compte du critere lors de la recherche. @@ -858,12 +892,12 @@ * @param scanDirectory le repertoire a scanner * @param indicatorResults if true get indicator results * @param mapResults if true get map results - * @return la liste des resultid + * @return une map de resultid/nom visuel des projets * @throws CoserBusinessException */ - protected List<String> getZonesIds(File scanDirectory, Boolean indicatorResults, Boolean mapResults) throws CoserBusinessException { + protected Map<String, String> getZonesIds(File scanDirectory, Boolean indicatorResults, Boolean mapResults) throws CoserBusinessException { - List<String> resultIds = new ArrayList<String>(); + Map<String, String> resultIds = new HashMap<String, String>(); File[] projectFiles = scanDirectory.listFiles(); if (projectFiles != null) { for (File projectFile : projectFiles) { @@ -888,7 +922,10 @@ ( mapResults == null || rsufiResult.isMapsResult() == mapResults ) ) { String resultResultId = rsufiResult.getZone(); if (StringUtils.isNotBlank(resultResultId)) { - resultIds.add(resultResultId); + String resultPath = projectFile.getName() + "/" + + selectionFile.getName() + "/" + + resultFile.getName(); + resultIds.put(resultResultId, resultPath); } } } @@ -971,7 +1008,7 @@ * @param newResultIds new ids * @throws CoserBusinessException */ - protected void cleanCurrentProjectDirectory(File projectsDirectory, List<String> newResultIds) throws CoserBusinessException { + protected void cleanCurrentProjectDirectory(File projectsDirectory, Collection<String> newResultIds) throws CoserBusinessException { try { File[] projectFiles = projectsDirectory.listFiles(); @@ -1030,8 +1067,12 @@ /** * Envoi un mail de notification apres la publication des resultat à la * liste des adresses email renseignées dans la configuration. + * + * @param login user login + * @param count updated data count + * @param detail body mail detail */ - protected void sendNewResultNotifications() { + protected void sendNewResultNotifications(String login, int count, String detail) { List<String> emails = config.getNewResultNotificationList(); for (String email : emails) { @@ -1040,8 +1081,8 @@ emailPart.setHostName(config.getSmtpHost()); emailPart.addTo(email); emailPart.setFrom("noreply-coser@ifremer.fr", "Coser"); - emailPart.setSubject(_("coser.business.notificationmail.subject")); - emailPart.setContent(_("coser.business.notificationmail.body"), "text/plain; charset=ISO-8859-9"); + emailPart.setSubject(_("coser.business.notificationmail.subject", count)); + emailPart.setContent(_("coser.business.notificationmail.body", login, detail), "text/plain; charset=ISO-8859-9"); // send mail emailPart.send(); Modified: trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties =================================================================== --- trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties 2012-08-09 10:36:21 UTC (rev 1033) +++ trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties 2012-08-09 15:38:09 UTC (rev 1034) @@ -109,8 +109,12 @@ coser.business.matrix.lengthstructure=Length structures coser.business.matrix.occurrence=Occurrence coser.business.matrix.samplingeffort=Sampling effort -coser.business.notificationmail.body=Data has been updated on website.\n\n--\nCoser. -coser.business.notificationmail.subject=Coser \: Data updated +coser.business.notificationmail.added=added \: %s (%s) +coser.business.notificationmail.body=Data has been updated on website by %s.\n\n%s--\nCoser. +coser.business.notificationmail.deleted=deleted \: %s (%s) +coser.business.notificationmail.indicatorsresults=Indicator results \: +coser.business.notificationmail.mapsresults=Map results \: +coser.business.notificationmail.subject=Coser \: %d data updated coser.business.publication.author=Author coser.business.publication.catchfilename=Catch file name coser.business.publication.comment=Comment Modified: trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties =================================================================== --- trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties 2012-08-09 10:36:21 UTC (rev 1033) +++ trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties 2012-08-09 15:38:09 UTC (rev 1034) @@ -109,8 +109,12 @@ coser.business.matrix.lengthstructure=Structures en taille coser.business.matrix.occurrence=Occurrence coser.business.matrix.samplingeffort=Effort d'échantillonnage -coser.business.notificationmail.body=Les données du site internet viennent d'être mises à jour\n\n--\nCoser. -coser.business.notificationmail.subject=Coser \: Données mises à jour +coser.business.notificationmail.added=ajouté \: %s (%s) +coser.business.notificationmail.body=Les données du site internet viennent d'être mises à jour par %s.\n\n%s--\nCoser. +coser.business.notificationmail.deleted=supprimé \: %s (%s) +coser.business.notificationmail.indicatorsresults=Résultats d'indicateur \: +coser.business.notificationmail.mapsresults=Résultat de carte \: +coser.business.notificationmail.subject=Coser \: %d résultats mis à jour coser.business.publication.author=Auteur coser.business.publication.catchfilename=Nom du fichier captures coser.business.publication.comment=Commentaire Modified: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/UploadResultAction.java =================================================================== --- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/UploadResultAction.java 2012-08-09 10:36:21 UTC (rev 1033) +++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/UploadResultAction.java 2012-08-09 15:38:09 UTC (rev 1034) @@ -106,7 +106,7 @@ if (resultFile != null) { WebService webService = ServiceFactory.getWebService(); try { - webService.registerNewUploadedResults(resultFile); + webService.registerNewUploadedResults(login, resultFile); } catch (CoserBusinessException ex) { throw new CoserWebException("Can't register new result file", ex); }
participants (1)
-
echatellier@users.forge.codelutin.com