r206 - in trunk: faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities faxtomail-persistence/src/main/xmi faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin faxtomail-ui-web/src/main/webapp/WEB-INF faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin faxtomail-ui-web/src/main/webapp/WEB-INF/decorators
Author: echatellier Date: 2014-06-15 12:41:28 +0200 (Sun, 15 Jun 2014) New Revision: 206 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/206 Log: Ajout des v?\195?\169rrouillages de mail dans le mod?\195?\168le (et d?\195?\169verrouillage dans l'admin) Added: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/LockAction.java trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/lock-input.jsp Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailTopiaDao.java trunk/faxtomail-persistence/src/main/xmi/faxtomail.zargo trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators/layout.jsp trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/wro.xml Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailTopiaDao.java =================================================================== --- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailTopiaDao.java 2014-06-12 20:00:25 UTC (rev 205) +++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailTopiaDao.java 2014-06-15 10:41:28 UTC (rev 206) @@ -362,4 +362,16 @@ } return result; } + + /** + * Retourne les email vérrouillés. + * + * @return email list + */ + public List<Email> getLockedEmail() { + String query = "FROM " + Email.class.getName() + " where " + Email.PROPERTY_LOCKED_BY + " is not null"; + + List<Email> results = findAll(query); + return results; + } } Modified: trunk/faxtomail-persistence/src/main/xmi/faxtomail.zargo =================================================================== (Binary files differ) Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java 2014-06-12 20:00:25 UTC (rev 205) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java 2014-06-15 10:41:28 UTC (rev 206) @@ -47,6 +47,7 @@ import javax.mail.MessagingException; import com.franciaflex.faxtomail.persistence.entities.MailField; + import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.Predicate; import org.apache.commons.io.IOUtils; @@ -575,4 +576,31 @@ } return attachmentFile; } + + /** + * Retourne la liste des email ayant un verrouillage actif. + * + * @return email list + */ + public List<Email> getLockedMail() { + EmailTopiaDao emailDao = getPersistenceContext().getEmailDao(); + List<Email> result = emailDao.getLockedEmail(); + return result; + } + + /** + * Dévérrouille les mails specifié. + * + * @param unlockMails + */ + public void unlockMails(List<String> unlockMails) { + EmailTopiaDao emailDao = getPersistenceContext().getEmailDao(); + for (String unlockMail : unlockMails) { + Email mail = emailDao.findByTopiaId(unlockMail); + mail.setLockedBy(null); + emailDao.update(mail); + } + + getPersistenceContext().commit(); + } } Added: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/LockAction.java =================================================================== --- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/LockAction.java (rev 0) +++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/LockAction.java 2014-06-15 10:41:28 UTC (rev 206) @@ -0,0 +1,99 @@ +package com.franciaflex.faxtomail.web.action.admin; + +/* + * #%L + * FaxToMail :: Web + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Franciaflex, Code Lutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import java.lang.reflect.Type; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.struts2.convention.annotation.Action; +import org.apache.struts2.convention.annotation.InterceptorRef; +import org.apache.struts2.convention.annotation.InterceptorRefs; +import org.apache.struts2.convention.annotation.Result; + +import com.franciaflex.faxtomail.persistence.entities.Email; +import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; +import com.franciaflex.faxtomail.persistence.entities.MailFolder; +import com.franciaflex.faxtomail.services.service.ConfigurationService; +import com.franciaflex.faxtomail.services.service.EmailService; +import com.franciaflex.faxtomail.services.service.MailFolderService; +import com.franciaflex.faxtomail.web.FaxToMailActionSupport; +import com.google.gson.reflect.TypeToken; +import com.opensymphony.xwork2.Preparable; + +@InterceptorRefs({ + @InterceptorRef("faxToMailInterceptor"), + @InterceptorRef("loginInterceptor"), + @InterceptorRef("paramsPrepareParamsStack") +}) +public class LockAction extends FaxToMailActionSupport implements Preparable { + + private static final Log log = LogFactory.getLog(LockAction.class); + + protected EmailService emailService; + + protected List<Email> lockedMails; + + protected List<String> unlockMails; + + public void setEmailService(EmailService emailService) { + this.emailService = emailService; + } + + @Override + public void prepare() throws Exception { + // check authorization + if (!getSession().isAdmin()) { + throw new RuntimeException("Not authorized"); + } + } + + @Override + @Action("lock-input") + public String input() throws Exception { + lockedMails = emailService.getLockedMail(); + return INPUT; + } + + @Override + @Action(results = {@Result(type = "redirectAction", params = {"actionName", "lock-input"})}) + public String execute() throws Exception { + emailService.unlockMails(unlockMails); + return SUCCESS; + } + + public List<Email> getLockedMails() { + return lockedMails; + } + + public void setUnlockMails(List<String> unlockMails) { + this.unlockMails = unlockMails; + } +} Property changes on: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/LockAction.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/lock-input.jsp =================================================================== --- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/lock-input.jsp (rev 0) +++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/lock-input.jsp 2014-06-15 10:41:28 UTC (rev 206) @@ -0,0 +1,76 @@ +<%-- + #%L + FaxToMail :: Web + $Id$ + $HeadURL$ + %% + Copyright (C) 2014 Franciaflex, Code Lutin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program. If not, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --%> +<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> +<!DOCTYPE html> +<%@taglib uri="/struts-tags" prefix="s" %> + +<html> + <head> + <title>Vérrouillages</title> + <link rel="stylesheet" type="text/css" href="<s:url value='/nuiton-js/faxtomail-lock.css' />" /> + </head> + + <body> + + <div id="main-container" class="container"> + + <h1 class="page-header">Liste des verrous actifs sur les demandes</h1> + + <s:form id="main_form" action="lock" method="post"> + + <table id='table-snapshot' class="table table-bordered"> + <thead> + <tr> + <th></th> + <th>Demande</th> + <th>Vérrouillé par</th> + </tr> + </thead> + <tbody> + <s:iterator value="lockedMails"> + <tr> + <td><input type="checkbox" name="unlockMails" value="<s:property value="topiaId" />" /> + <td><s:property value="object" /></td> + <td> + <s:property value="lockedBy.firstName" /> <s:property value="lockedBy.lastName" /> + </td> + </tr> + </s:iterator> + <s:if test="lockedMails == null || lockedMails.empty"> + <tr class="emptyTable"> + <td colspan="3">Aucune demande n'est actuellement vérrouillée.</td> + </tr> + </s:if> + </tbody> + </table> + + <nav class="navbar navbar-default navbar-fixed-bottom"> + <div class="container"> + <button type="submit" class="btn btn-primary navbar-btn pull-right">Valider</button> + </div> + </nav> + </s:form> + </div> + </body> +</html> Property changes on: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/lock-input.jsp ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators/layout.jsp =================================================================== --- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators/layout.jsp 2014-06-12 20:00:25 UTC (rev 205) +++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators/layout.jsp 2014-06-15 10:41:28 UTC (rev 206) @@ -63,6 +63,8 @@ <span class="fa fa-cog"></span> Configuration</a></li> <li><a href="<s:url action='import-input' namespace="/admin" />"> <span class="fa fa-upload"></span> Import</a></li> + <li><a href="<s:url action='lock-input' namespace="/admin" />"> + <span class="fa fa-unlock-alt"></span> Vérrouillages</a></li> </s:if> <li><a href="<s:url action='user-folder-input' namespace="/admin" />"> Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/wro.xml =================================================================== --- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/wro.xml 2014-06-12 20:00:25 UTC (rev 205) +++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/wro.xml 2014-06-15 10:41:28 UTC (rev 206) @@ -94,4 +94,8 @@ <js>/js/user-folder.js</js> <css>/css/faxtomail.css</css> </group> + + <group name='faxtomail-lock'> + <css>/css/faxtomail.css</css> + </group> </groups> \ No newline at end of file
participants (1)
-
echatellier@users.forge.codelutin.com