Faxtomail-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
October 2014
- 3 participants
- 28 discussions
r684 - in trunk: faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin faxtomail-ui-web/src/main/resources
by kmorin@users.forge.codelutin.com 31 Oct '14
by kmorin@users.forge.codelutin.com 31 Oct '14
31 Oct '14
Author: kmorin
Date: 2014-10-31 16:14:53 +0100 (Fri, 31 Oct 2014)
New Revision: 684
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/684
Log:
- fix archive import
Added:
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailExecuteAndWaitInterceptor.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/HasUploadedFile.java
Modified:
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportExportModel.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportArchiveAction.java
trunk/faxtomail-ui-web/src/main/resources/struts.properties
trunk/faxtomail-ui-web/src/main/resources/struts.xml
Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java 2014-10-28 17:17:15 UTC (rev 683)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java 2014-10-31 15:14:53 UTC (rev 684)
@@ -69,6 +69,7 @@
import com.google.common.base.Optional;
import com.google.common.collect.Iterables;
import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.IteratorUtils;
import org.apache.commons.collections4.Predicate;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportExportModel.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportExportModel.java 2014-10-28 17:17:15 UTC (rev 683)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportExportModel.java 2014-10-31 15:14:53 UTC (rev 684)
@@ -54,7 +54,7 @@
/**
* Parse date pattern : dd/MM/yyyy hh:mm:ss.
*/
- protected ValueParserFormatter<Date> dateValueParserFormatter = new ValueParserFormatter<Date>() {
+ protected static final ValueParserFormatter<Date> dateValueParserFormatter = new ValueParserFormatter<Date>() {
protected DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
@Override
public Date parse(String value) throws ParseException {
Added: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailExecuteAndWaitInterceptor.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailExecuteAndWaitInterceptor.java (rev 0)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailExecuteAndWaitInterceptor.java 2014-10-31 15:14:53 UTC (rev 684)
@@ -0,0 +1,59 @@
+package com.franciaflex.faxtomail.web;
+
+import com.opensymphony.xwork2.ActionInvocation;
+import org.apache.commons.io.FileUtils;
+import org.apache.struts2.interceptor.BackgroundProcess;
+import org.apache.struts2.interceptor.ExecuteAndWaitInterceptor;
+
+import java.io.File;
+
+/**
+ * Interceptor to copy the temp file to avoid it is deleted before the execAndWait thread has time to read it
+ * cf http://stackoverflow.com/questions/22382779/file-not-saved-in-temp-path-usi…
+ * @author Kevin Morin (Code Lutin)
+ * @since 1.1
+ */
+public class FaxToMailExecuteAndWaitInterceptor extends ExecuteAndWaitInterceptor {
+
+ @Override
+ protected BackgroundProcess getNewBackgroundProcess(String name,
+ ActionInvocation actionInvocation,
+ int threadPriority) {
+
+ BackgroundProcess bgProcess;
+ if (actionInvocation.getAction() instanceof HasUploadedFile) {
+ HasUploadedFile uploadAction = (HasUploadedFile) actionInvocation.getAction();
+ try {
+ File origFile = uploadAction.getUploadedFile();
+ if (origFile != null) {
+ File altFile = new File(origFile.getParentFile(), origFile.getName() + "-alt.tmp");
+ FileUtils.copyFile(origFile, altFile);
+ altFile.deleteOnExit();
+ uploadAction.setUploadedFile(altFile);
+ }
+ } catch (Exception ex) {
+ throw new RuntimeException("Error copying uploaded file", ex);
+ }
+ bgProcess = new UploadBackgroundProcess(name + "BackgroundThread", actionInvocation, threadPriority);
+ } else {
+ bgProcess = super.getNewBackgroundProcess(name, actionInvocation, threadPriority);
+ }
+ return bgProcess;
+ }
+
+ /**
+ * Wraps the standard {@link BackgroundProcess} to clean up alternate file created above.
+ */
+ private class UploadBackgroundProcess extends BackgroundProcess {
+
+ public UploadBackgroundProcess(String threadName, ActionInvocation invocation, int threadPriority) {
+ super(threadName, invocation, threadPriority);
+ }
+
+ @Override
+ protected void afterInvocation() throws Exception {
+ super.afterInvocation();
+ FileUtils.deleteQuietly(((HasUploadedFile)getAction()).getUploadedFile());
+ }
+ }
+}
Added: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/HasUploadedFile.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/HasUploadedFile.java (rev 0)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/HasUploadedFile.java 2014-10-31 15:14:53 UTC (rev 684)
@@ -0,0 +1,14 @@
+package com.franciaflex.faxtomail.web;
+
+import java.io.File;
+
+/**
+ * @author Kevin Morin (Code Lutin)
+ * @since 1.1
+ */
+public interface HasUploadedFile {
+
+ File getUploadedFile();
+
+ void setUploadedFile(File file);
+}
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportArchiveAction.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportArchiveAction.java 2014-10-28 17:17:15 UTC (rev 683)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportArchiveAction.java 2014-10-31 15:14:53 UTC (rev 684)
@@ -33,6 +33,7 @@
import com.franciaflex.faxtomail.persistence.entities.FaxToMailTopiaPersistenceContext;
import com.franciaflex.faxtomail.services.FaxToMailServiceContext;
import com.franciaflex.faxtomail.services.service.imports.ArchiveImportResult;
+import com.franciaflex.faxtomail.web.HasUploadedFile;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -54,16 +55,18 @@
@InterceptorRef("faxToMailInterceptor"),
@InterceptorRef("loginInterceptor"),
@InterceptorRef("paramsPrepareParamsStack"),
- @InterceptorRef(value="execAndWait",
- params={"excludeMethods", "input,downloadImportErrorFile"})
+ @InterceptorRef(value="faxToMailExecAndWait",
+ params={"excludeMethods", "input,downloadImportErrorFile", "delay", "1000"})
})
-public class ImportArchiveAction extends FaxToMailActionSupport implements Preparable {
+public class ImportArchiveAction extends FaxToMailActionSupport implements Preparable, HasUploadedFile {
private static final Log log = LogFactory.getLog(ImportArchiveAction.class);
protected String attachmentBase;
protected File archiveFile;
+ protected String archiveFileFileName;
+ protected String archiveFileContentType;
protected FaxToMailApplicationContext applicationContext;
@@ -73,14 +76,6 @@
protected String fileName;
protected String contentType;
- public void setArchiveFile(File archiveFile) {
- this.archiveFile = archiveFile;
- }
-
- public void setAttachmentBase(String attachmentBase) {
- this.attachmentBase = attachmentBase;
- }
-
public void setApplicationContext(FaxToMailApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
@@ -131,7 +126,7 @@
importResult = emailService.importArchive(is, file);
if (log.isInfoEnabled()) {
- log.info(importResult.getNbImportedArchives());
+ log.info(importResult.getNbImportedArchives() + " imported archives");
}
} catch (Exception ex) {
@@ -170,13 +165,37 @@
return SUCCESS;
}
+
+ public void setArchiveFile(File archiveFile) {
+ this.archiveFile = archiveFile;
+ }
+
+ public void setAttachmentBase(String attachmentBase) {
+ this.attachmentBase = attachmentBase;
+ }
+
+ public String getArchiveFileFileName() {
+ return archiveFileFileName;
+ }
+
+ public void setArchiveFileFileName(String archiveFileFileName) {
+ this.archiveFileFileName = archiveFileFileName;
+ }
+
+ public String getArchiveFileContentType() {
+ return archiveFileContentType;
+ }
+
+ public void setArchiveFileContentType(String archiveFileContentType) {
+ this.archiveFileContentType = archiveFileContentType;
+ }
+
public ArchiveImportResult getImportResult() {
return importResult;
}
public void setImportResult(ArchiveImportResult importResult) {
this.importResult = importResult;
- log.info(importResult);
}
public InputStream getInputStream() {
@@ -194,4 +213,14 @@
public String getContentType() {
return contentType;
}
+
+ @Override
+ public File getUploadedFile() {
+ return archiveFile;
+ }
+
+ @Override
+ public void setUploadedFile(File file) {
+ archiveFile = file;
+ }
}
Modified: trunk/faxtomail-ui-web/src/main/resources/struts.properties
===================================================================
--- trunk/faxtomail-ui-web/src/main/resources/struts.properties 2014-10-28 17:17:15 UTC (rev 683)
+++ trunk/faxtomail-ui-web/src/main/resources/struts.properties 2014-10-31 15:14:53 UTC (rev 684)
@@ -38,3 +38,6 @@
struts.freemarker.templatesCache=true
struts.convention.package.locators.basePackage=com.franciaflex.faxtomail.web.action
+
+# allow large file upload
+struts.multipart.maxSize=2000000000
\ No newline at end of file
Modified: trunk/faxtomail-ui-web/src/main/resources/struts.xml
===================================================================
--- trunk/faxtomail-ui-web/src/main/resources/struts.xml 2014-10-28 17:17:15 UTC (rev 683)
+++ trunk/faxtomail-ui-web/src/main/resources/struts.xml 2014-10-31 15:14:53 UTC (rev 684)
@@ -42,6 +42,7 @@
<interceptors>
<interceptor name="faxToMailInterceptor" class="com.franciaflex.faxtomail.web.FaxToMailInterceptor"/>
<interceptor name="loginInterceptor" class="com.franciaflex.faxtomail.web.FaxToMailLoginInterceptor" />
+ <interceptor name="faxToMailExecAndWait" class="com.franciaflex.faxtomail.web.FaxToMailExecuteAndWaitInterceptor" />
<interceptor-stack name="faxToMailStack">
<interceptor-ref name="faxToMailInterceptor" />
1
0
28 Oct '14
Author: kmorin
Date: 2014-10-28 18:17:15 +0100 (Tue, 28 Oct 2014)
New Revision: 683
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/683
Log:
fix import archives
Added:
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/SearchAction.java
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/import-archive-wait.jsp
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/search-input.jsp
Removed:
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/ArchiveSearchAction.java
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/archive-search-input.jsp
Modified:
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java
trunk/faxtomail-ui-swing/src/license/THIRD-PARTY.properties
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailInterceptor.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportArchiveAction.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/LdapAction.java
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/import-archive-input.jsp
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators/layout.jsp
Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java 2014-10-20 09:43:51 UTC (rev 682)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java 2014-10-28 17:17:15 UTC (rev 683)
@@ -1685,6 +1685,8 @@
} finally {
IOUtils.closeQuietly(importer);
IOUtils.closeQuietly(inputStream);
+ transaction.rollback();
+ statelessSession.close();
}
if (!notImportedBeans.isEmpty()) {
Modified: trunk/faxtomail-ui-swing/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/faxtomail-ui-swing/src/license/THIRD-PARTY.properties 2014-10-20 09:43:51 UTC (rev 682)
+++ trunk/faxtomail-ui-swing/src/license/THIRD-PARTY.properties 2014-10-28 17:17:15 UTC (rev 683)
@@ -1,24 +1,3 @@
-###
-# #%L
-# FaxToMail :: UI
-# %%
-# Copyright (C) 2014 Mac-Groupe, 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%
-###
# Generated by org.codehaus.mojo.license.AddThirdPartyMojo
#-------------------------------------------------------------------------------
# Already used licenses in project :
@@ -61,7 +40,7 @@
# Please fill the missing licenses for dependencies :
#
#
-#Wed Oct 01 15:25:35 CEST 2014
+#Wed Oct 15 19:01:07 CEST 2014
commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
dom4j--dom4j--1.6.1=BSD License
javax.media.jai--com.springsource.javax.media.jai.codec--1.1.3=Apache License
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailInterceptor.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailInterceptor.java 2014-10-20 09:43:51 UTC (rev 682)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailInterceptor.java 2014-10-28 17:17:15 UTC (rev 683)
@@ -80,6 +80,7 @@
if (CollectionUtils.isNotEmpty(faxToMailSession.getMessages())) {
for (String message : faxToMailSession.getMessages()) {
+ log.info(message);
faxToMailAction.addActionMessage(message);
}
faxToMailSession.getMessages().clear();
@@ -113,6 +114,7 @@
} else if (FaxToMailConfiguration.class.isAssignableFrom(propertyType)) {
toInject = getFaxToMailApplicationContext(invocation).getApplicationConfig();
+
} else if (FaxToMailApplicationContext.class.isAssignableFrom(propertyType)) {
toInject = getFaxToMailApplicationContext(invocation);
}
@@ -126,6 +128,7 @@
}
return invocation.invoke();
+
} finally {
if (serviceContext != null) {
serviceContext.getPersistenceContext().close();
Deleted: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/ArchiveSearchAction.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/ArchiveSearchAction.java 2014-10-20 09:43:51 UTC (rev 682)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/ArchiveSearchAction.java 2014-10-28 17:17:15 UTC (rev 683)
@@ -1,374 +0,0 @@
-package com.franciaflex.faxtomail.web.action;
-
-import com.franciaflex.faxtomail.persistence.entities.Attachment;
-import com.franciaflex.faxtomail.persistence.entities.Client;
-import com.franciaflex.faxtomail.persistence.entities.Email;
-import com.franciaflex.faxtomail.persistence.entities.EmailGroup;
-import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser;
-import com.franciaflex.faxtomail.persistence.entities.HasLabel;
-import com.franciaflex.faxtomail.persistence.entities.MailField;
-import com.franciaflex.faxtomail.persistence.entities.RangeRow;
-import com.franciaflex.faxtomail.persistence.entities.Reply;
-import com.franciaflex.faxtomail.services.DecoratorService;
-import com.franciaflex.faxtomail.services.service.ConfigurationService;
-import com.franciaflex.faxtomail.services.service.EmailService;
-import com.franciaflex.faxtomail.web.FaxToMailActionSupport;
-import com.google.common.base.Function;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Lists;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-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 org.nuiton.decorator.Decorator;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static org.nuiton.i18n.I18n.t;
-
-/**
- * @author Kevin Morin (Code Lutin)
- * @since 1.1
- */
-
-@InterceptorRefs({
- @InterceptorRef("faxToMailInterceptor"),
- @InterceptorRef("paramsPrepareParamsStack")
-})
-public class ArchiveSearchAction extends FaxToMailActionSupport {
-
- private static final Log log = LogFactory.getLog(ArchiveSearchAction.class);
-
- protected EmailService emailService;
- protected ConfigurationService configurationService;
- protected DecoratorService decoratorService;
-
- protected String commandQuotationNb;
- protected String company;
- protected List<Email> results;
- protected String singleResultId;
- protected Map<MailField, String> tableMailFields;
-
- public void setEmailService(EmailService emailService) {
- this.emailService = emailService;
- }
-
- public void setConfigurationService(ConfigurationService configurationService) {
- this.configurationService = configurationService;
- }
-
- public void setDecoratorService(DecoratorService decoratorService) {
- this.decoratorService = decoratorService;
- }
-
- @Override
- @Action("archive-search-input")
- public String input() throws Exception {
- return INPUT;
- }
-
- @Override
- @Action(value = "archive-search",
- results = {
- @Result(name="detail",
- type="redirectAction",
- params = {"actionName", "demand-detail", "id", "%{singleResultId}"})
- })
- public String execute() throws Exception {
- String result = INPUT;
- if (commandQuotationNb != null && company != null) {
- results = new ArrayList<>(emailService.searchArchives(commandQuotationNb, company));
- if (results.size() == 1) {
- singleResultId = results.get(0).getTopiaId();
- result = "detail";
-
- } else {
- List<MailField> mailFields = configurationService.getSearchDisplayColumns();
- if (CollectionUtils.isEmpty(mailFields)) {
- mailFields = Lists.newArrayList(MailField.getTableFields());
- }
- tableMailFields = getEnumAsMap(mailFields.toArray(new MailField[mailFields.size()]));
- }
- }
- return result;
- }
-
- public String getCommandQuotationNb() {
- return commandQuotationNb;
- }
-
- public void setCommandQuotationNb(String commandQuotationNb) {
- this.commandQuotationNb = commandQuotationNb;
- }
-
- public String getCompany() {
- return company;
- }
-
- public void setCompany(String company) {
- this.company = company;
- }
-
- public List<Email> getResults() {
- return results;
- }
-
- public void setResults(List<Email> results) {
- this.results = results;
- }
-
- public String getSingleResultId() {
- return singleResultId;
- }
-
- public Map<MailField, String> getTableMailFields() {
- return tableMailFields;
- }
-
- public String getAttr(MailField field, Email email) {
- Object attrValue = null;
- switch (field) {
- case PRIORITY:
- attrValue = email.getPriority();
- break;
- case DEMAND_TYPE:
- attrValue = email.getDemandType();
- break;
- case OBJECT:
- attrValue = email.getObject();
- break;
- case CLIENT_CODE:
- Client client = email.getClient();
- attrValue = client == null ? null : client.getCode();
- break;
- case CLIENT_BRAND:
- client = email.getClient();
- attrValue = client == null ? null : client.getBrand();
- break;
- case SENDER:
- attrValue = email.getSender();
- break;
- case PROJECT_REFERENCE:
- attrValue = email.getProjectReference();
- break;
- case COMPANY_REFERENCE:
- attrValue = email.getCompanyReference();
- break;
- case REFERENCE:
- attrValue = email.getReference();
- break;
- case RECEPTION_DATE:
- attrValue = email.getReceptionDate();
- break;
- case RECIPIENT:
- attrValue = email.getRecipient();
- break;
- case DEMAND_STATUS:
- attrValue = email.getDemandStatus();
- break;
- case WAITING_STATE:
- attrValue = email.getWaitingState();
- break;
- case PF_NB:
- int intAttrValue = 0;
- for (RangeRow rr : email.getRangeRow()) {
- Integer productQuantity = rr.getProductQuantity();
- if (productQuantity != null) {
- intAttrValue += productQuantity;
- }
- }
- attrValue = intAttrValue;
- break;
- case SAV_NB:
- intAttrValue = 0;
- for (RangeRow rr : email.getRangeRow()) {
- Integer savQuantity = rr.getSavQuantity();
- if (savQuantity != null) {
- intAttrValue += savQuantity;
- }
- }
- attrValue = intAttrValue;
- break;
- case QUOTATION_NB:
- intAttrValue = 0;
- for (RangeRow rr : email.getRangeRow()) {
- Integer quotationQuantity = rr.getQuotationQuantity();
- if (quotationQuantity != null) {
- intAttrValue += quotationQuantity;
- }
- }
- attrValue = intAttrValue;
- break;
- case TAKEN_BY:
- attrValue = email.getTakenBy();
- break;
- case COMMENT:
- attrValue = email.getComment();
- break;
- case EDI_RETURN:
- attrValue = email.getEdiError();
- break;
- case LAST_ATTACHMENT_OPENING_IN_THIS_FOLDER_USER:
- attrValue = email.getLastAttachmentOpener();
- break;
- case REPLIES:
- attrValue = "<span class='fa fa-envelope-o'></span> " + email.sizeReplies();
- break;
- case ATTACHMENT:
- attrValue = "<span class='fa fa-paperclip'></span> " + email.sizeAttachment();
- break;
- case GROUP:
- EmailGroup emailGroup = email.getEmailGroup();
- attrValue = "<span class='fa fa-link'></span> " + (emailGroup == null ? 1 : emailGroup.sizeEmail());
- break;
- }
-
- String result;
- if (attrValue == null || StringUtils.isBlank(attrValue.toString())) {
- result = " ";
-
- } else {
- Decorator decorator = decoratorService.getDecorator(attrValue);
- if (decorator != null) {
- result = decorator.toString(attrValue);
- } else {
- result = attrValue.toString();
- }
- }
- return result;
- }
-
- public String getTooltip(MailField field, Email email) {
- String tooltipText = null;
- switch (field) {
- case PF_NB:
- List<String> ranges = new ArrayList<String>();
- Collection<RangeRow> rangeRows = email.getRangeRow();
- if (rangeRows != null) {
- for (RangeRow rangeRow : rangeRows) {
- Integer qty = rangeRow.getProductQuantity();
- if (qty != null && qty > 0) {
- ranges.add(rangeRow.getRange().getLabel() + " : " + qty);
- }
- }
- }
-
- if (!ranges.isEmpty()) {
- tooltipText = StringUtils.join(ranges, "\n");
- }
- break;
-
- case SAV_NB:
- ranges = new ArrayList<String>();
- rangeRows = email.getRangeRow();
- if (rangeRows != null) {
- for (RangeRow rangeRow : rangeRows) {
- Integer qty = rangeRow.getSavQuantity();
- if (qty != null && qty > 0) {
- ranges.add(rangeRow.getRange().getLabel() + " : " + qty);
- }
- }
- }
-
- if (!ranges.isEmpty()) {
- tooltipText = StringUtils.join(ranges, "\n");
- }
- break;
-
- case QUOTATION_NB:
- ranges = new ArrayList<String>();
- rangeRows = email.getRangeRow();
- if (rangeRows != null) {
- for (RangeRow rangeRow : rangeRows) {
- Integer qty = rangeRow.getQuotationQuantity();
- if (qty != null && qty > 0) {
- ranges.add(rangeRow.getRange().getLabel() + " : " + qty);
- }
- }
- }
-
- if (!ranges.isEmpty()) {
- tooltipText = StringUtils.join(ranges, "\n");
- }
- break;
-
- case REPLIES:
- List<Reply> replies = email.getReplies();
- if (CollectionUtils.isNotEmpty(replies)) {
- final Decorator<Reply> decorator = decoratorService.getDecoratorByType(Reply.class);
-
- List<String> replyNames = Lists.transform(replies, new Function<Reply, String>() {
- @Override
- public String apply(Reply attachment) {
- return decorator.toString(attachment);
- }
- });
- tooltipText = StringUtils.join(replyNames, "\n");
- }
- break;
-
- case ATTACHMENT:
- List<Attachment> attachments = email.getAttachment();
- if (CollectionUtils.isNotEmpty(attachments)) {
- final Decorator<Attachment> decorator = decoratorService.getDecoratorByType(Attachment.class);
-
- List<String> attachmentNames = Lists.transform(attachments, new Function<Attachment, String>() {
- @Override
- public String apply(Attachment attachment) {
- String name = decorator.toString(attachment);
- if (attachment.getEditedFileName() != null) {
- name += " (+ édité)";
- }
- return name;
- }
- });
- tooltipText = StringUtils.join(attachmentNames, "\n");
- }
- break;
-
- case GROUP:
-
- EmailGroup emailGroup = email.getEmailGroup();
- Collection<Email> emails = new ArrayList<>();
- if (emailGroup != null) {
- Collection<Email> groupEmails = emailGroup.getEmail();
- if (CollectionUtils.isNotEmpty(groupEmails)) {
- emails.addAll(groupEmails);
- }
- }
- if (emails.isEmpty()) {
- emails.add(email);
- }
- Collection<String> emailTitles = Collections2.transform(emails, new Function<Email, String>() {
- @Override
- public String apply(Email email) {
- String result = email.getObject();
- String ref = email.getReference();
- if (!ref.isEmpty()) {
- result = ref + " - " + result;
- }
- return result;
- }
- });
- tooltipText = StringUtils.join(emailTitles, "\n");
- break;
-
- default:
- tooltipText = getAttr(field, email);
- }
-
- if (tooltipText == null) {
- tooltipText = " ";
- }
-
- return tooltipText;
- }
-}
Copied: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/SearchAction.java (from rev 682, trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/ArchiveSearchAction.java)
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/SearchAction.java (rev 0)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/SearchAction.java 2014-10-28 17:17:15 UTC (rev 683)
@@ -0,0 +1,369 @@
+package com.franciaflex.faxtomail.web.action;
+
+import com.franciaflex.faxtomail.persistence.entities.Attachment;
+import com.franciaflex.faxtomail.persistence.entities.Client;
+import com.franciaflex.faxtomail.persistence.entities.Email;
+import com.franciaflex.faxtomail.persistence.entities.EmailGroup;
+import com.franciaflex.faxtomail.persistence.entities.MailField;
+import com.franciaflex.faxtomail.persistence.entities.RangeRow;
+import com.franciaflex.faxtomail.persistence.entities.Reply;
+import com.franciaflex.faxtomail.services.DecoratorService;
+import com.franciaflex.faxtomail.services.service.ConfigurationService;
+import com.franciaflex.faxtomail.services.service.EmailService;
+import com.franciaflex.faxtomail.web.FaxToMailActionSupport;
+import com.google.common.base.Function;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+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 org.nuiton.decorator.Decorator;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Kevin Morin (Code Lutin)
+ * @since 1.1
+ */
+
+@InterceptorRefs({
+ @InterceptorRef("faxToMailInterceptor"),
+ @InterceptorRef("paramsPrepareParamsStack")
+})
+public class SearchAction extends FaxToMailActionSupport {
+
+ private static final Log log = LogFactory.getLog(SearchAction.class);
+
+ protected EmailService emailService;
+ protected ConfigurationService configurationService;
+ protected DecoratorService decoratorService;
+
+ protected String element;
+ protected String company;
+ protected List<Email> results;
+ protected String singleResultId;
+ protected Map<MailField, String> tableMailFields;
+
+ public void setEmailService(EmailService emailService) {
+ this.emailService = emailService;
+ }
+
+ public void setConfigurationService(ConfigurationService configurationService) {
+ this.configurationService = configurationService;
+ }
+
+ public void setDecoratorService(DecoratorService decoratorService) {
+ this.decoratorService = decoratorService;
+ }
+
+ @Override
+ @Action("search-input")
+ public String input() throws Exception {
+ return INPUT;
+ }
+
+ @Override
+ @Action(value = "search",
+ results = {
+ @Result(name="detail",
+ type="redirectAction",
+ params = {"actionName", "demand-detail", "id", "%{singleResultId}"})
+ })
+ public String execute() throws Exception {
+ String result = INPUT;
+ if (element != null && company != null) {
+ results = new ArrayList<>(emailService.searchArchives(element, company));
+ if (results.size() == 1) {
+ singleResultId = results.get(0).getTopiaId();
+ result = "detail";
+
+ } else {
+ List<MailField> mailFields = configurationService.getSearchDisplayColumns();
+ if (CollectionUtils.isEmpty(mailFields)) {
+ mailFields = Lists.newArrayList(MailField.getTableFields());
+ }
+ tableMailFields = getEnumAsMap(mailFields.toArray(new MailField[mailFields.size()]));
+ }
+ }
+ return result;
+ }
+
+ public String getElement() {
+ return element;
+ }
+
+ public void setElement(String element) {
+ this.element = element;
+ }
+
+ public String getCompany() {
+ return company;
+ }
+
+ public void setCompany(String company) {
+ this.company = company;
+ }
+
+ public List<Email> getResults() {
+ return results;
+ }
+
+ public void setResults(List<Email> results) {
+ this.results = results;
+ }
+
+ public String getSingleResultId() {
+ return singleResultId;
+ }
+
+ public Map<MailField, String> getTableMailFields() {
+ return tableMailFields;
+ }
+
+ public String getAttr(MailField field, Email email) {
+ Object attrValue = null;
+ switch (field) {
+ case PRIORITY:
+ attrValue = email.getPriority();
+ break;
+ case DEMAND_TYPE:
+ attrValue = email.getDemandType();
+ break;
+ case OBJECT:
+ attrValue = email.getObject();
+ break;
+ case CLIENT_CODE:
+ Client client = email.getClient();
+ attrValue = client == null ? null : client.getCode();
+ break;
+ case CLIENT_BRAND:
+ client = email.getClient();
+ attrValue = client == null ? null : client.getBrand();
+ break;
+ case SENDER:
+ attrValue = email.getSender();
+ break;
+ case PROJECT_REFERENCE:
+ attrValue = email.getProjectReference();
+ break;
+ case COMPANY_REFERENCE:
+ attrValue = email.getCompanyReference();
+ break;
+ case REFERENCE:
+ attrValue = email.getReference();
+ break;
+ case RECEPTION_DATE:
+ attrValue = email.getReceptionDate();
+ break;
+ case RECIPIENT:
+ attrValue = email.getRecipient();
+ break;
+ case DEMAND_STATUS:
+ attrValue = email.getDemandStatus();
+ break;
+ case WAITING_STATE:
+ attrValue = email.getWaitingState();
+ break;
+ case PF_NB:
+ int intAttrValue = 0;
+ for (RangeRow rr : email.getRangeRow()) {
+ Integer productQuantity = rr.getProductQuantity();
+ if (productQuantity != null) {
+ intAttrValue += productQuantity;
+ }
+ }
+ attrValue = intAttrValue;
+ break;
+ case SAV_NB:
+ intAttrValue = 0;
+ for (RangeRow rr : email.getRangeRow()) {
+ Integer savQuantity = rr.getSavQuantity();
+ if (savQuantity != null) {
+ intAttrValue += savQuantity;
+ }
+ }
+ attrValue = intAttrValue;
+ break;
+ case QUOTATION_NB:
+ intAttrValue = 0;
+ for (RangeRow rr : email.getRangeRow()) {
+ Integer quotationQuantity = rr.getQuotationQuantity();
+ if (quotationQuantity != null) {
+ intAttrValue += quotationQuantity;
+ }
+ }
+ attrValue = intAttrValue;
+ break;
+ case TAKEN_BY:
+ attrValue = email.getTakenBy();
+ break;
+ case COMMENT:
+ attrValue = email.getComment();
+ break;
+ case EDI_RETURN:
+ attrValue = email.getEdiError();
+ break;
+ case LAST_ATTACHMENT_OPENING_IN_THIS_FOLDER_USER:
+ attrValue = email.getLastAttachmentOpener();
+ break;
+ case REPLIES:
+ attrValue = "<span class='fa fa-envelope-o'></span> " + email.sizeReplies();
+ break;
+ case ATTACHMENT:
+ attrValue = "<span class='fa fa-paperclip'></span> " + email.sizeAttachment();
+ break;
+ case GROUP:
+ EmailGroup emailGroup = email.getEmailGroup();
+ attrValue = "<span class='fa fa-link'></span> " + (emailGroup == null ? 1 : emailGroup.sizeEmail());
+ break;
+ }
+
+ String result;
+ if (attrValue == null || StringUtils.isBlank(attrValue.toString())) {
+ result = " ";
+
+ } else {
+ Decorator decorator = decoratorService.getDecorator(attrValue);
+ if (decorator != null) {
+ result = decorator.toString(attrValue);
+ } else {
+ result = attrValue.toString();
+ }
+ }
+ return result;
+ }
+
+ public String getTooltip(MailField field, Email email) {
+ String tooltipText = null;
+ switch (field) {
+ case PF_NB:
+ List<String> ranges = new ArrayList<String>();
+ Collection<RangeRow> rangeRows = email.getRangeRow();
+ if (rangeRows != null) {
+ for (RangeRow rangeRow : rangeRows) {
+ Integer qty = rangeRow.getProductQuantity();
+ if (qty != null && qty > 0) {
+ ranges.add(rangeRow.getRange().getLabel() + " : " + qty);
+ }
+ }
+ }
+
+ if (!ranges.isEmpty()) {
+ tooltipText = StringUtils.join(ranges, "\n");
+ }
+ break;
+
+ case SAV_NB:
+ ranges = new ArrayList<String>();
+ rangeRows = email.getRangeRow();
+ if (rangeRows != null) {
+ for (RangeRow rangeRow : rangeRows) {
+ Integer qty = rangeRow.getSavQuantity();
+ if (qty != null && qty > 0) {
+ ranges.add(rangeRow.getRange().getLabel() + " : " + qty);
+ }
+ }
+ }
+
+ if (!ranges.isEmpty()) {
+ tooltipText = StringUtils.join(ranges, "\n");
+ }
+ break;
+
+ case QUOTATION_NB:
+ ranges = new ArrayList<String>();
+ rangeRows = email.getRangeRow();
+ if (rangeRows != null) {
+ for (RangeRow rangeRow : rangeRows) {
+ Integer qty = rangeRow.getQuotationQuantity();
+ if (qty != null && qty > 0) {
+ ranges.add(rangeRow.getRange().getLabel() + " : " + qty);
+ }
+ }
+ }
+
+ if (!ranges.isEmpty()) {
+ tooltipText = StringUtils.join(ranges, "\n");
+ }
+ break;
+
+ case REPLIES:
+ List<Reply> replies = email.getReplies();
+ if (CollectionUtils.isNotEmpty(replies)) {
+ final Decorator<Reply> decorator = decoratorService.getDecoratorByType(Reply.class);
+
+ List<String> replyNames = Lists.transform(replies, new Function<Reply, String>() {
+ @Override
+ public String apply(Reply attachment) {
+ return decorator.toString(attachment);
+ }
+ });
+ tooltipText = StringUtils.join(replyNames, "\n");
+ }
+ break;
+
+ case ATTACHMENT:
+ List<Attachment> attachments = email.getAttachment();
+ if (CollectionUtils.isNotEmpty(attachments)) {
+ final Decorator<Attachment> decorator = decoratorService.getDecoratorByType(Attachment.class);
+
+ List<String> attachmentNames = Lists.transform(attachments, new Function<Attachment, String>() {
+ @Override
+ public String apply(Attachment attachment) {
+ String name = decorator.toString(attachment);
+ if (attachment.getEditedFileName() != null) {
+ name += " (+ édité)";
+ }
+ return name;
+ }
+ });
+ tooltipText = StringUtils.join(attachmentNames, "\n");
+ }
+ break;
+
+ case GROUP:
+
+ EmailGroup emailGroup = email.getEmailGroup();
+ Collection<Email> emails = new ArrayList<>();
+ if (emailGroup != null) {
+ Collection<Email> groupEmails = emailGroup.getEmail();
+ if (CollectionUtils.isNotEmpty(groupEmails)) {
+ emails.addAll(groupEmails);
+ }
+ }
+ if (emails.isEmpty()) {
+ emails.add(email);
+ }
+ Collection<String> emailTitles = Collections2.transform(emails, new Function<Email, String>() {
+ @Override
+ public String apply(Email email) {
+ String result = email.getObject();
+ String ref = email.getReference();
+ if (!ref.isEmpty()) {
+ result = ref + " - " + result;
+ }
+ return result;
+ }
+ });
+ tooltipText = StringUtils.join(emailTitles, "\n");
+ break;
+
+ default:
+ tooltipText = getAttr(field, email);
+ }
+
+ if (tooltipText == null) {
+ tooltipText = " ";
+ }
+
+ return tooltipText;
+ }
+}
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportArchiveAction.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportArchiveAction.java 2014-10-20 09:43:51 UTC (rev 682)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportArchiveAction.java 2014-10-28 17:17:15 UTC (rev 683)
@@ -29,6 +29,9 @@
import java.io.InputStream;
import java.nio.file.Files;
+import com.franciaflex.faxtomail.FaxToMailApplicationContext;
+import com.franciaflex.faxtomail.persistence.entities.FaxToMailTopiaPersistenceContext;
+import com.franciaflex.faxtomail.services.FaxToMailServiceContext;
import com.franciaflex.faxtomail.services.service.imports.ArchiveImportResult;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
@@ -50,7 +53,9 @@
@InterceptorRefs({
@InterceptorRef("faxToMailInterceptor"),
@InterceptorRef("loginInterceptor"),
- @InterceptorRef("paramsPrepareParamsStack")
+ @InterceptorRef("paramsPrepareParamsStack"),
+ @InterceptorRef(value="execAndWait",
+ params={"excludeMethods", "input,downloadImportErrorFile"})
})
public class ImportArchiveAction extends FaxToMailActionSupport implements Preparable {
@@ -60,7 +65,7 @@
protected File archiveFile;
- protected EmailService emailService;
+ protected FaxToMailApplicationContext applicationContext;
protected ArchiveImportResult importResult;
@@ -68,10 +73,6 @@
protected String fileName;
protected String contentType;
- public void setEmailService(EmailService emailService) {
- this.emailService = emailService;
- }
-
public void setArchiveFile(File archiveFile) {
this.archiveFile = archiveFile;
}
@@ -80,6 +81,10 @@
this.attachmentBase = attachmentBase;
}
+ public void setApplicationContext(FaxToMailApplicationContext applicationContext) {
+ this.applicationContext = applicationContext;
+ }
+
@Override
public void prepare() throws Exception {
// check authorization
@@ -95,30 +100,51 @@
}
@Override
- public void validate() {
+ @Action(results = {
+ @Result(name="wait", location="/WEB-INF/content/admin/import-archive-wait.jsp"),
+ @Result(name="*", type = "chain", params = {"actionName", "import-archive-input"})})
+ public String execute() throws Exception {
+ String result = SUCCESS;
+
if (StringUtils.isBlank(fileName)) {
if (StringUtils.isNotBlank(attachmentBase) && !new File(attachmentBase).isDirectory()) {
- addActionError("Le répertoire de base des pièces jointes n'est pas un répertoire lisible !");
+ getSession().addErrorMessages("Le répertoire de base des pièces jointes n'est pas un répertoire lisible !");
+ return ERROR;
}
if (archiveFile == null) {
- addActionError("Le fichier d'archive est obligatoire !");
+ getSession().addErrorMessages("Le fichier d'archive est obligatoire !");
+ return ERROR;
}
}
- }
- @Override
- @Action("import-archive")
- public String execute() throws Exception {
- String result = INPUT;
- try (InputStream is = new FileInputStream(archiveFile)) {
- File file = StringUtils.isNotBlank(attachmentBase) ? new File(attachmentBase) : null;
- importResult = emailService.importArchive(is, file);
+ // cette methode doit ouvrir sa propre connexion sinon l'interceptor va la fermer
+ // and cause du execAndWait
+ FaxToMailTopiaPersistenceContext persistenceContext = applicationContext.newPersistenceContext();
- } catch (Exception ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't import archive file", ex);
+ try {
+ persistenceContext = applicationContext.newPersistenceContext();
+ FaxToMailServiceContext serviceContext = applicationContext.newServiceContext(persistenceContext);
+ EmailService emailService = serviceContext.getEmailService();
+
+ try (InputStream is = new FileInputStream(archiveFile)) {
+ File file = StringUtils.isNotBlank(attachmentBase) ? new File(attachmentBase) : null;
+
+ importResult = emailService.importArchive(is, file);
+ if (log.isInfoEnabled()) {
+ log.info(importResult.getNbImportedArchives());
+ }
+
+ } catch (Exception ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't import archive file", ex);
+ }
+ getSession().addErrorMessages("Erreur lors de l'import : " + ex.getMessage());
+
+ result = ERROR;
}
- addActionError("Erreur lors de l'import : " + ex.getMessage());
+
+ } finally {
+ persistenceContext.close();
}
return result;
@@ -136,7 +162,9 @@
})
public String downloadImportErrorFile() throws Exception {
File file = new File(getApplicationConfig().getDataDirectory(), fileName);
- log.info(fileName + " exists : " + file.exists());
+ if (log.isDebugEnabled()) {
+ log.debug(fileName + " exists : " + file.exists());
+ }
contentType = Files.probeContentType(file.toPath());
inputStream = new FileInputStream(file);
return SUCCESS;
@@ -146,6 +174,11 @@
return importResult;
}
+ public void setImportResult(ArchiveImportResult importResult) {
+ this.importResult = importResult;
+ log.info(importResult);
+ }
+
public InputStream getInputStream() {
return inputStream;
}
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/LdapAction.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/LdapAction.java 2014-10-20 09:43:51 UTC (rev 682)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/LdapAction.java 2014-10-28 17:17:15 UTC (rev 683)
@@ -98,7 +98,7 @@
try {
persistenceContext = applicationContext.newPersistenceContext();
FaxToMailServiceContext serviceContext = applicationContext.newServiceContext(persistenceContext);
- LdapService ldapService2 = serviceContext.newService(LdapService.class);
+ LdapService ldapService2 = serviceContext.getLdapService();
ldapService2.updateLdapData();
} finally {
persistenceContext.close();
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/import-archive-input.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/import-archive-input.jsp 2014-10-20 09:43:51 UTC (rev 682)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/import-archive-input.jsp 2014-10-28 17:17:15 UTC (rev 683)
@@ -63,7 +63,7 @@
<div class="form-group">
<label for="archiveFile" class="control-label">Fichier d'archive :</label>
- <input type="file" id="archiveFile" name="archiveFile" class="form-control">
+ <input type="file" id="archiveFile" name="archiveFile" class="form-control" required>
<p class="help-block">Format du fichier csv : <code>receptionDate;projectReference;sender;fax;recipient;object;archiveDate;companyReference;originalEmail;comment;etatAttente;demandType;priority;mailFolder;client-code;client-brand;attachments</code><br />
Encodage du fichier csv : <code>${applicationConfig.importFileEncoding}</code></p>
</div>
Added: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/import-archive-wait.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/import-archive-wait.jsp (rev 0)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/import-archive-wait.jsp 2014-10-28 17:17:15 UTC (rev 683)
@@ -0,0 +1,21 @@
+<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
+<!DOCTYPE html>
+<%@taglib uri="/struts-tags" prefix="s" %>
+
+<html>
+ <head>
+ <title>Reprise des archives</title>
+ <meta http-equiv="refresh" content="5;url=<s:url />"/>
+ </head>
+
+ <body>
+
+ <div id="main-container" class="container">
+
+ <h1 class="page-header">Reprise des archives</h1>
+
+ <em>L'import des archives est en cours, merci de patienter...</em>
+
+ </div>
+ </body>
+</html>
Deleted: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/archive-search-input.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/archive-search-input.jsp 2014-10-20 09:43:51 UTC (rev 682)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/archive-search-input.jsp 2014-10-28 17:17:15 UTC (rev 683)
@@ -1,70 +0,0 @@
-<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
-<!DOCTYPE html>
-<%@taglib uri="/struts-tags" prefix="s" %>
-
-<html>
- <head>
- <title>Recherche d'archives</title>
- <link rel="stylesheet" type="text/css" href="<s:url value='/nuiton-js/faxtomail-archive-search.css' />" />
- </head>
-
- <body>
-
- <div id="main-container" class="container">
-
- <h1 class="page-header">Recherche d'archives</h1>
-
- <s:form id="main_form" action="archive-search" method="get" theme="simple">
- <s:actionmessage/>
- <s:actionerror/>
-
- <label for="commandQuotationNbField" class="control-label">Numéro de commande / devis :</label>
- <s:textfield type="text" id="commandQuotationNbField" name="commandQuotationNb" required="true" class="form-control"/>
- <label for="companyField" class="control-label">Société :</label>
- <s:textfield type="text" id="companyField" name="company" required="true" class="form-control"/>
- <s:submit cssClass="btn btn-primary" value="Valider"/>
-
- </s:form>
-
- <s:if test="results != null">
-
- <div style="overflow-x: auto; margin-top: 20px">
-
- <s:if test="results.isEmpty()">
- <em>Aucun résultat pour cette recherche.</em>
- </s:if>
- <s:else>
- <table class="table table-bordered">
- <thead>
- <tr>
- <th></th>
- <s:iterator value="tableMailFields">
- <th><s:property value="value"/></th>
- </s:iterator>
- </tr>
- </thead>
- <tbody>
- <s:iterator value="results" var="result">
- <tr>
- <td>
- <s:url id="detailUrlId" value="demand-detail.action">
- <s:param name="id" value="%{topiaId}" />
- </s:url>
- <s:a href="%{detailUrlId}"><span class="fa fa-eye"></span></s:a>
- </td>
- <s:iterator value="tableMailFields">
- <td class="cut-eol" title="<s:text name="%{getTooltip(key, #result)}"/>"><s:text name="%{getAttr(key, #result)}"/></td>
- </s:iterator>
- </tr>
- </s:iterator>
- </tbody>
- </table>
- </s:else>
-
- </div>
-
- </s:if>
-
- </div>
- </body>
-</html>
\ No newline at end of file
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp 2014-10-20 09:43:51 UTC (rev 682)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp 2014-10-28 17:17:15 UTC (rev 683)
@@ -232,7 +232,7 @@
<dt>Contenu de l'email</dt>
<dd class="well well-sm"><s:property value="emailUIModel.content" escapeHtml="false"/></dd>
<dt>Message</dt>
- <dd><s:text name="%{decorate(demand.comment)}" />
+ <dd class="well well-sm"><s:text name="%{decorate(demand.comment)}" />
</dl>
</div>
</div>
Copied: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/search-input.jsp (from rev 682, trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/archive-search-input.jsp)
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/search-input.jsp (rev 0)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/search-input.jsp 2014-10-28 17:17:15 UTC (rev 683)
@@ -0,0 +1,70 @@
+<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
+<!DOCTYPE html>
+<%@taglib uri="/struts-tags" prefix="s" %>
+
+<html>
+ <head>
+ <title>Recherche d'archives</title>
+ <link rel="stylesheet" type="text/css" href="<s:url value='/nuiton-js/faxtomail-archive-search.css' />" />
+ </head>
+
+ <body>
+
+ <div id="main-container" class="container">
+
+ <h1 class="page-header">Recherche d'archives</h1>
+
+ <s:form id="main_form" action="search" method="get" theme="simple">
+ <s:actionmessage/>
+ <s:actionerror/>
+
+ <label for="elementField" class="control-label">Numéro de commande / devis :</label>
+ <s:textfield type="text" id="elementField" name="element" required="true" class="form-control"/>
+ <label for="companyField" class="control-label">Société :</label>
+ <s:textfield type="text" id="companyField" name="company" required="true" class="form-control"/>
+ <s:submit cssClass="btn btn-primary" value="Valider"/>
+
+ </s:form>
+
+ <s:if test="results != null">
+
+ <div style="overflow-x: auto; margin-top: 20px">
+
+ <s:if test="results.isEmpty()">
+ <em>Aucun résultat pour cette recherche.</em>
+ </s:if>
+ <s:else>
+ <table class="table table-bordered">
+ <thead>
+ <tr>
+ <th></th>
+ <s:iterator value="tableMailFields">
+ <th><s:property value="value"/></th>
+ </s:iterator>
+ </tr>
+ </thead>
+ <tbody>
+ <s:iterator value="results" var="result">
+ <tr>
+ <td>
+ <s:url id="detailUrlId" value="demand-detail.action">
+ <s:param name="id" value="%{topiaId}" />
+ </s:url>
+ <s:a href="%{detailUrlId}"><span class="fa fa-eye"></span></s:a>
+ </td>
+ <s:iterator value="tableMailFields">
+ <td class="cut-eol" title="<s:text name="%{getTooltip(key, #result)}"/>"><s:text name="%{getAttr(key, #result)}"/></td>
+ </s:iterator>
+ </tr>
+ </s:iterator>
+ </tbody>
+ </table>
+ </s:else>
+
+ </div>
+
+ </s:if>
+
+ </div>
+ </body>
+</html>
\ No newline at end of file
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-10-20 09:43:51 UTC (rev 682)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators/layout.jsp 2014-10-28 17:17:15 UTC (rev 683)
@@ -78,7 +78,7 @@
</s:if>
- <li><a href="<s:url action='archive-search-input' />">
+ <li><a href="<s:url action='search-input' namespace="/" />">
<span class="fa fa-search"></span> Recherche archive</a></li>
</ul>
@@ -90,10 +90,6 @@
<li><a href="<s:url action='logout' namespace="/" />">
<span class="fa fa-power-off"></span> Déconnexion</a></li>
</s:if>
- <s:else>
- <li><a href="<s:url action='login-input' namespace="/" />">
- <span class="fa fa-power-off"></span> Connexion</a></li>
- </s:else>
</ul>
</nav>
</div>
1
0
r682 - trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content
by kmorin@users.forge.codelutin.com 20 Oct '14
by kmorin@users.forge.codelutin.com 20 Oct '14
20 Oct '14
Author: kmorin
Date: 2014-10-20 11:43:51 +0200 (Mon, 20 Oct 2014)
New Revision: 682
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/682
Log:
wording
Modified:
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp 2014-10-20 09:37:05 UTC (rev 681)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp 2014-10-20 09:43:51 UTC (rev 682)
@@ -229,7 +229,7 @@
<dd><s:property value="emailUIModel.ccRecipients" /></dd>
<dt>Sujet</dt>
<dd><s:property value="emailUIModel.subject" /></dd>
- <dt>Contenu de l'email reçu</dt>
+ <dt>Contenu de l'email</dt>
<dd class="well well-sm"><s:property value="emailUIModel.content" escapeHtml="false"/></dd>
<dt>Message</dt>
<dd><s:text name="%{decorate(demand.comment)}" />
1
0
r681 - in trunk/faxtomail-ui-web/src/main/webapp: WEB-INF/content css
by kmorin@users.forge.codelutin.com 20 Oct '14
by kmorin@users.forge.codelutin.com 20 Oct '14
20 Oct '14
Author: kmorin
Date: 2014-10-20 11:37:05 +0200 (Mon, 20 Oct 2014)
New Revision: 681
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/681
Log:
style
Modified:
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp
trunk/faxtomail-ui-web/src/main/webapp/css/demand-detail.css
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp 2014-10-20 09:16:45 UTC (rev 680)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp 2014-10-20 09:37:05 UTC (rev 681)
@@ -222,7 +222,7 @@
</div>
<div class="col-md-6 col-lg-6">
- <dl class="dl-horizontal large-dl">
+ <dl class="dl-horizontal">
<dt>À</dt>
<dd><s:property value="emailUIModel.toRecipients" /></dd>
<dt>Copie à</dt>
Modified: trunk/faxtomail-ui-web/src/main/webapp/css/demand-detail.css
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/css/demand-detail.css 2014-10-20 09:16:45 UTC (rev 680)
+++ trunk/faxtomail-ui-web/src/main/webapp/css/demand-detail.css 2014-10-20 09:37:05 UTC (rev 681)
@@ -19,11 +19,11 @@
}
.large-dl dt {
- width: 235px;
+ width: 245px;
}
.large-dl dd {
- margin-left: 255px;
+ margin-left: 260px;
}
.dropdown-menu > li > span {
1
0
r680 - in trunk/faxtomail-ui-web/src/main: java/com/franciaflex/faxtomail/web/action webapp/WEB-INF/content webapp/WEB-INF/decorators webapp/css
by kmorin@users.forge.codelutin.com 20 Oct '14
by kmorin@users.forge.codelutin.com 20 Oct '14
20 Oct '14
Author: kmorin
Date: 2014-10-20 11:16:45 +0200 (Mon, 20 Oct 2014)
New Revision: 680
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/680
Log:
- refs #5939 Page web de recherche des ?\195?\169l?\195?\169ments archiv?\195?\169s
- refs #5940 Page web de d?\195?\169tail d'un ?\195?\169l?\195?\169ment archiv?\195?\169
Modified:
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/ArchiveSearchAction.java
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/archive-search-input.jsp
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators/layout.jsp
trunk/faxtomail-ui-web/src/main/webapp/css/demand-detail.css
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/ArchiveSearchAction.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/ArchiveSearchAction.java 2014-10-17 13:20:48 UTC (rev 679)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/ArchiveSearchAction.java 2014-10-20 09:16:45 UTC (rev 680)
@@ -54,6 +54,7 @@
protected String commandQuotationNb;
protected String company;
protected List<Email> results;
+ protected String singleResultId;
protected Map<MailField, String> tableMailFields;
public void setEmailService(EmailService emailService) {
@@ -75,17 +76,29 @@
}
@Override
- @Action("archive-search")
+ @Action(value = "archive-search",
+ results = {
+ @Result(name="detail",
+ type="redirectAction",
+ params = {"actionName", "demand-detail", "id", "%{singleResultId}"})
+ })
public String execute() throws Exception {
+ String result = INPUT;
if (commandQuotationNb != null && company != null) {
results = new ArrayList<>(emailService.searchArchives(commandQuotationNb, company));
- List<MailField> mailFields = configurationService.getSearchDisplayColumns();
- if (CollectionUtils.isEmpty(mailFields)) {
- mailFields = Lists.newArrayList(MailField.getTableFields());
+ if (results.size() == 1) {
+ singleResultId = results.get(0).getTopiaId();
+ result = "detail";
+
+ } else {
+ List<MailField> mailFields = configurationService.getSearchDisplayColumns();
+ if (CollectionUtils.isEmpty(mailFields)) {
+ mailFields = Lists.newArrayList(MailField.getTableFields());
+ }
+ tableMailFields = getEnumAsMap(mailFields.toArray(new MailField[mailFields.size()]));
}
- tableMailFields = getEnumAsMap(mailFields.toArray(new MailField[mailFields.size()]));
}
- return INPUT;
+ return result;
}
public String getCommandQuotationNb() {
@@ -112,6 +125,10 @@
this.results = results;
}
+ public String getSingleResultId() {
+ return singleResultId;
+ }
+
public Map<MailField, String> getTableMailFields() {
return tableMailFields;
}
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/archive-search-input.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/archive-search-input.jsp 2014-10-17 13:20:48 UTC (rev 679)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/archive-search-input.jsp 2014-10-20 09:16:45 UTC (rev 680)
@@ -14,7 +14,7 @@
<h1 class="page-header">Recherche d'archives</h1>
- <s:form id="main_form" action="archive-search" method="post" theme="simple">
+ <s:form id="main_form" action="archive-search" method="get" theme="simple">
<s:actionmessage/>
<s:actionerror/>
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp 2014-10-17 13:20:48 UTC (rev 679)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp 2014-10-20 09:16:45 UTC (rev 680)
@@ -16,7 +16,7 @@
<body>
- <div id="main-container" class="container" ng-app="DemandDetailModule" ng-controller="DemandDetailController">
+ <div id="main-container" class="container-fluid" ng-app="DemandDetailModule" ng-controller="DemandDetailController">
<s:if test="demand != null">
<!-- groupe | réponses | historique | pj -->
<nav class="navbar navbar-default" role="navigation">
@@ -143,134 +143,143 @@
</div><!-- /.container-fluid -->
</nav>
- <dl class="dl-horizontal large-dl">
- <dt>Reçu le</dt>
- <dd><s:property value="demand.receptionDate" /></dd>
- <dt>Émetteur</dt>
- <dd><s:property value="demand.sender" /></dd>
- <dt>Objet</dt>
- <dd><s:property value="demand.object" /></dd>
- <dt>Client (marque)</dt>
- <dd><s:if test="demand.client != null"><s:property value="demand.client.code" /> (<s:property value="demand.client.brand" />)</s:if></dd>
- <dt>Type</dt>
- <dd><s:text name="%{decorate(demand.demandType)}" /></dd>
- <dt>Priorité</dt>
- <dd><s:text name="%{decorate(demand.priority)}" /></dd>
- <dt>Référence chantier</dt>
- <dd><s:property value="demand.projectReference" /></dd>
- <dt>Notre référence</dt>
- <dd><s:property value="demand.companyReference" /></dd>
- <dt>État d'attente</dt>
- <dd><s:text name="%{decorate(demand.waitingState)}" /></dd>
- </dl>
+ <div class="container-fluid">
+ <div class="row">
+ <div class="col-md-6 col-lg-6">
+ <dl class="dl-horizontal large-dl">
+ <dt>Reçu le</dt>
+ <dd><s:text name="%{decorate(demand.receptionDate)}" /></dd>
+ <dt>Émetteur</dt>
+ <dd><s:property value="demand.sender" /></dd>
+ <dt>Objet</dt>
+ <dd><s:property value="demand.object" /></dd>
+ <dt>Client (marque)</dt>
+ <dd><s:if test="demand.client != null"><s:property value="demand.client.code" /> (<s:property value="demand.client.brand" />)</s:if></dd>
+ <dt>Type</dt>
+ <dd><s:text name="%{decorate(demand.demandType)}" /></dd>
+ <dt>Priorité</dt>
+ <dd><s:text name="%{decorate(demand.priority)}" /></dd>
+ <dt>Référence chantier</dt>
+ <dd><s:property value="demand.projectReference" /></dd>
+ <dt>Notre référence</dt>
+ <dd><s:property value="demand.companyReference" /></dd>
+ <dt>État d'attente</dt>
+ <dd><s:text name="%{decorate(demand.waitingState)}" /></dd>
+ <dt>Status</dt>
+ <dd><s:text name="%{decorate(demand.demandStatus)}" /></dd>
+ <dt>Pris par</dt>
+ <dd><s:text name="%{decorate(demand.takenBy)}" /></dd>
+ </dl>
- <dl class="dl-horizontal large-dl">
- <s:if test="demand.firstOpeningDate != null">
- <dt>Première ouverture</dt>
- <dd>par <s:text name="%{decorateUser(demand.firstOpeningUser)}" /> le <s:text name="%{decorate(demand.firstOpeningDate)}" /></dd>
- </s:if>
- <s:if test="demand.lastModificationDate != null">
- <dt>Dernière modification</dt>
- <dd>par <s:text name="%{decorateUser(demand.lastModificationUser)}" /> le <s:text name="%{decorate(demand.lastModificationDate)}" /></dd>
- </s:if>
- <s:if test="demand.lastAttachmentOpeningInFolderDate != null">
- <dt>Dernière ouverture de pièce jointe</dt>
- <dd>par <s:text name="%{decorateUser(demand.lastAttachmentOpeningInFolderUser)}" /> le <s:text name="%{decorate(demand.lastAttachmentOpeningInFolderDate)}" /></dd>
- </s:if>
- </dl>
+ <dl class="dl-horizontal large-dl">
+ <s:if test="demand.firstOpeningDate != null">
+ <dt>Première ouverture</dt>
+ <dd>par <s:text name="%{decorateUser(demand.firstOpeningUser)}" /> le <s:text name="%{decorate(demand.firstOpeningDate)}" /></dd>
+ </s:if>
+ <s:if test="demand.lastModificationDate != null">
+ <dt>Dernière modification</dt>
+ <dd>par <s:text name="%{decorateUser(demand.lastModificationUser)}" /> le <s:text name="%{decorate(demand.lastModificationDate)}" /></dd>
+ </s:if>
+ <s:if test="demand.lastAttachmentOpeningInFolderDate != null">
+ <dt>Dernière ouverture de pièce jointe</dt>
+ <dd>par <s:text name="%{decorateUser(demand.lastAttachmentOpeningInFolderUser)}" /> le <s:text name="%{decorate(demand.lastAttachmentOpeningInFolderDate)}" /></dd>
+ </s:if>
+ </dl>
- <s:if test="demand.sizeRangeRow() > 0">
- <table class="table table-bordered">
- <thead>
- <tr>
- <th title="Gamme">Gamme</th>
- <th title="N° commande / devis">N° commande / devis</th>
- <th title="Quantité de devis">Qté devis</th>
- <th title="Quantité de produits">Qté produits</th>
- <th title="Quantité de SAV">Qté SAV</th>
- </tr>
- </thead>
- <tbody>
- <s:iterator value="demand.rangeRow" var="row">
- <tr>
- <td title="<s:text name="%{decorate(#row.range)}" />"><s:text name="%{decorate(#row.range)}" /></td>
- <td title="<s:property value="#row.commandNumber"/>"><s:property value="#row.commandNumber"/></td>
- <td title="<s:property value="#row.quotationQuantity"/>"><s:property value="#row.quotationQuantity"/></td>
- <td title="<s:property value="#row.productQuantity"/>"><s:property value="#row.productQuantity"/></td>
- <td title="<s:property value="#row.savQuantity"/>"><s:property value="#row.savQuantity"/></td>
- </tr>
- </s:iterator>
- </tbody>
- <tfoot>
- <tr>
- <th>Total</th>
- <th></th>
- <th><s:property value="quotationTotal"/></th>
- <th><s:property value="productTotal"/></th>
- <th><s:property value="savTotal"/></th>
- </tr>
- </tfoot>
- </table>
- </s:if>
+ <s:if test="demand.sizeRangeRow() > 0">
+ <table class="table table-bordered">
+ <thead>
+ <tr>
+ <th title="Gamme">Gamme</th>
+ <th title="N° commande / devis">N° commande / devis</th>
+ <th title="Quantité de devis">Qté devis</th>
+ <th title="Quantité de produits">Qté produits</th>
+ <th title="Quantité de SAV">Qté SAV</th>
+ </tr>
+ </thead>
+ <tbody>
+ <s:iterator value="demand.rangeRow" var="row">
+ <tr>
+ <td title="<s:text name="%{decorate(#row.range)}" />"><s:text name="%{decorate(#row.range)}" /></td>
+ <td title="<s:property value="#row.commandNumber"/>"><s:property value="#row.commandNumber"/></td>
+ <td title="<s:property value="#row.quotationQuantity"/>"><s:property value="#row.quotationQuantity"/></td>
+ <td title="<s:property value="#row.productQuantity"/>"><s:property value="#row.productQuantity"/></td>
+ <td title="<s:property value="#row.savQuantity"/>"><s:property value="#row.savQuantity"/></td>
+ </tr>
+ </s:iterator>
+ </tbody>
+ <tfoot>
+ <tr>
+ <th>Total</th>
+ <th></th>
+ <th><s:property value="quotationTotal"/></th>
+ <th><s:property value="productTotal"/></th>
+ <th><s:property value="savTotal"/></th>
+ </tr>
+ </tfoot>
+ </table>
+ </s:if>
+ </div>
- <dl class="dl-horizontal large-dl">
- <dt>À</dt>
- <dd><s:property value="emailUIModel.toRecipients" /></dd>
- <dt>Copie à</dt>
- <dd><s:property value="emailUIModel.ccRecipients" /></dd>
- <dt>Sujet</dt>
- <dd><s:property value="emailUIModel.subject" /></dd>
- <dt>Contenu de l'email reçu</dt>
- <dd class="well well-sm"><s:property value="emailUIModel.content" escapeHtml="false"/></dd>
- <dt>Message</dt>
- <dd><s:text name="%{decorate(demand.comment)}" />
- </dl>
-
- </s:if>
-
-
- <div class="modal fade" id="replyModal"
- tabindex="-1" role="dialog"
- aria-labelledby="replyModalLabel" aria-hidden="true">
-
- <div class="modal-dialog modal-lg">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal">
- <span aria-hidden="true">×</span><span class="sr-only">Close</span>
- </button>
- <h4 class="modal-title" id="replyModalLabel">{{currentReply.subject}}</h4>
- </div>
- <div class="modal-body">
- <dl class="dl-horizontal">
- <dt>De</dt>
- <dd>{{currentReply.sender}}</dd>
+ <div class="col-md-6 col-lg-6">
+ <dl class="dl-horizontal large-dl">
<dt>À</dt>
- <dd>{{currentReply.toRecipients}}</dd>
+ <dd><s:property value="emailUIModel.toRecipients" /></dd>
<dt>Copie à</dt>
- <dd>{{currentReply.ccRecipients}}</dd>
- <dt>Copie cachée à</dt>
- <dd>{{currentReply.bccRecipients}}</dd>
+ <dd><s:property value="emailUIModel.ccRecipients" /></dd>
<dt>Sujet</dt>
- <dd>{{currentReply.subject}}</dd>
+ <dd><s:property value="emailUIModel.subject" /></dd>
+ <dt>Contenu de l'email reçu</dt>
+ <dd class="well well-sm"><s:property value="emailUIModel.content" escapeHtml="false"/></dd>
+ <dt>Message</dt>
+ <dd><s:text name="%{decorate(demand.comment)}" />
</dl>
- <p class="well" ng-bind-html="currentReply.content"></p>
- <div>
- Pièces jointes
- <ul>
- <li ng-repeat="attachment in currentReply.attachments">
- <a href="reply-attachment-download.action?id={{currentReply.id}}&index={{$index}}" title="Ouvrir la pive jointe">{{attachment.filename}}</a>
- </li>
- </ul>
+ </div>
+ </div>
+ </div>
+
+ <div class="modal fade" id="replyModal"
+ tabindex="-1" role="dialog"
+ aria-labelledby="replyModalLabel" aria-hidden="true">
+
+ <div class="modal-dialog modal-lg">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal">
+ <span aria-hidden="true">×</span><span class="sr-only">Close</span>
+ </button>
+ <h4 class="modal-title" id="replyModalLabel">{{currentReply.subject}}</h4>
</div>
+ <div class="modal-body">
+ <dl class="dl-horizontal">
+ <dt>De</dt>
+ <dd>{{currentReply.sender}}</dd>
+ <dt>À</dt>
+ <dd>{{currentReply.toRecipients}}</dd>
+ <dt>Copie à</dt>
+ <dd>{{currentReply.ccRecipients}}</dd>
+ <dt>Copie cachée à</dt>
+ <dd>{{currentReply.bccRecipients}}</dd>
+ <dt>Sujet</dt>
+ <dd>{{currentReply.subject}}</dd>
+ </dl>
+ <p class="well" ng-bind-html="currentReply.content"></p>
+ <div>
+ Pièces jointes
+ <ul>
+ <li ng-repeat="attachment in currentReply.attachments">
+ <a href="reply-attachment-download.action?id={{currentReply.id}}&index={{$index}}" title="Ouvrir la pive jointe">{{attachment.filename}}</a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-default" data-dismiss="modal">Fermer</button>
+ </div>
</div>
- <div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal">Fermer</button>
- </div>
</div>
</div>
- </div>
-
+ </s:if>
</div>
</body>
</html>
\ No newline at end of file
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-10-17 13:20:48 UTC (rev 679)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators/layout.jsp 2014-10-20 09:16:45 UTC (rev 680)
@@ -48,7 +48,7 @@
<!-- navbar -->
<header class="navbar navbar-inverse navbar-static-top" role="banner">
- <div class="container">
+ <div class="container-fluid">
<div class="navbar-header">
<a href="<s:url value='/' />" class="navbar-brand">FaxToMail</a>
</div>
Modified: trunk/faxtomail-ui-web/src/main/webapp/css/demand-detail.css
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/css/demand-detail.css 2014-10-17 13:20:48 UTC (rev 679)
+++ trunk/faxtomail-ui-web/src/main/webapp/css/demand-detail.css 2014-10-20 09:16:45 UTC (rev 680)
@@ -14,6 +14,10 @@
margin-right: 10px;
}
+.dl-horizontal dt {
+ text-align: left;
+}
+
.large-dl dt {
width: 235px;
}
1
0
r679 - trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities
by kmorin@users.forge.codelutin.com 17 Oct '14
by kmorin@users.forge.codelutin.com 17 Oct '14
17 Oct '14
Author: kmorin
Date: 2014-10-17 15:20:48 +0200 (Fri, 17 Oct 2014)
New Revision: 679
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/679
Log:
refs #5939 Page web de recherche des ?\195?\169l?\195?\169ments archiv?\195?\169s
Modified:
trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailTopiaDao.java
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-10-17 12:29:12 UTC (rev 678)
+++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailTopiaDao.java 2014-10-17 13:20:48 UTC (rev 679)
@@ -484,8 +484,8 @@
query.append(newFromClause("E") + " WHERE E." + Email.PROPERTY_MAIL_FOLDER + " in (:folders)");
args.put("folders", folders);
-// query.append(" AND E." + Email.PROPERTY_DEMAND_STATUS + " = :archiveStatus");
-// args.put("archiveStatus", DemandStatus.ARCHIVED);
+ query.append(" AND E." + Email.PROPERTY_DEMAND_STATUS + " = :archiveStatus");
+ args.put("archiveStatus", DemandStatus.ARCHIVED);
query.append(" AND (EXISTS (FROM " + RangeRow.class.getName() + " RR WHERE RR in elements(E." + Email.PROPERTY_RANGE_ROW + ")");
query.append(" AND lower(RR." + RangeRow.PROPERTY_COMMAND_NUMBER + ") LIKE lower(:" + SearchFilter.PROPERTY_COMMAND_NB + "))");
1
0
17 Oct '14
Author: kmorin
Date: 2014-10-17 14:29:12 +0200 (Fri, 17 Oct 2014)
New Revision: 678
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/678
Log:
fixes #5963 Prise en compte des dossier d'archive lors de l'import des archives
fixes #5974 Erreur lors de l'import d'un grand nombre d'archives
Added:
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportExportBean.java
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportExportModel.java
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportResult.java
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/InvalidArchiveImportBeanException.java
Removed:
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportBean.java
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportModel.java
Modified:
trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfiguration.java
trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfigurationOption.java
trunk/faxtomail-persistence/src/main/resources/faxToMail.properties
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceUtils.java
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java
trunk/faxtomail-service/src/main/resources/i18n/faxtomail-service_fr_FR.properties
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailApplicationListener.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportArchiveAction.java
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/import-archive-input.jsp
Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfiguration.java
===================================================================
--- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfiguration.java 2014-10-15 13:09:19 UTC (rev 677)
+++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfiguration.java 2014-10-17 12:29:12 UTC (rev 678)
@@ -281,6 +281,10 @@
return applicationConfig.getOption(FaxToMailConfigurationOption.JOB_CLIENT_EXPRESSION.getKey());
}
+ public int getArchiveImportCommitTreshold() {
+ return applicationConfig.getOptionAsInt(FaxToMailConfigurationOption.ARCHIVE_IMPORT_COMMIT_TRESHOLD.getKey());
+ }
+
public String getInstanceUrl() {
return applicationConfig.getOption(FaxToMailConfigurationOption.INSTANCE_URL.getKey());
}
Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfigurationOption.java
===================================================================
--- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfigurationOption.java 2014-10-15 13:09:19 UTC (rev 677)
+++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/FaxToMailConfigurationOption.java 2014-10-17 12:29:12 UTC (rev 678)
@@ -143,6 +143,10 @@
"faxtomail.job.client.expression",
"Expression cron de lancement du job Client", "0 */15 * * * ?", String.class),
+ ARCHIVE_IMPORT_COMMIT_TRESHOLD(
+ "faxtomail.archiveImport.commitTreshold.expression",
+ "Nombre d'archives à importer avant de commiter", "100", Integer.class),
+
// TRANSIENT CONFIG
VERSION(
"faxtomail.version",
Modified: trunk/faxtomail-persistence/src/main/resources/faxToMail.properties
===================================================================
--- trunk/faxtomail-persistence/src/main/resources/faxToMail.properties 2014-10-15 13:09:19 UTC (rev 677)
+++ trunk/faxtomail-persistence/src/main/resources/faxToMail.properties 2014-10-17 12:29:12 UTC (rev 678)
@@ -24,7 +24,8 @@
hibernate.dialect=org.hibernate.dialect.H2Dialect
hibernate.connection.driver_class=org.h2.Driver
-hibernate.connection.url=jdbc:h2:file:/tmp/faxtomail/h2data;MODE=MSSQLServer;AUTO_SERVER=TRUE
+#hibernate.connection.url=jdbc:h2:file:/tmp/faxtomail/h2data;MODE=MSSQLServer;AUTO_SERVER=TRUE
+hibernate.connection.url=jdbc:h2:file:/home/kmorin/faxtomail/h2data;MODE=MSSQLServer;AUTO_SERVER=TRUE;CACHE_SIZE=8192
hibernate.connection.username=sa
hibernate.connection.password=
@@ -37,6 +38,8 @@
#hibernate.hbm2ddl.auto=validate
hibernate.hbm2ddl.auto=
+hibernate.jdbc.batch_size=20
+
hibernate.c3p0.min_size=5
hibernate.c3p0.max_size=20
hibernate.c3p0.timeout=1800
Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceUtils.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceUtils.java 2014-10-15 13:09:19 UTC (rev 677)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceUtils.java 2014-10-17 12:29:12 UTC (rev 678)
@@ -74,4 +74,21 @@
}
return result;
}
+
+ /**
+ * Compute mail folder path (separated by /) from root to current.
+ *
+ * @param folder folder to get path
+ * @return full mail folder path
+ */
+ public static String getFullMailFolderPath(MailFolder folder) {
+ StringBuilder sb = new StringBuilder(folder.getName());
+ MailFolder loopFolder = folder.getParent();
+ while (loopFolder != null) {
+ sb.insert(0, "/");
+ sb.insert(0, loopFolder.getName());
+ loopFolder = loopFolder.getParent();
+ }
+ return sb.toString();
+ }
}
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-10-15 13:09:19 UTC (rev 677)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java 2014-10-17 12:29:12 UTC (rev 678)
@@ -37,6 +37,7 @@
import com.franciaflex.faxtomail.persistence.entities.EmailFilter;
import com.franciaflex.faxtomail.persistence.entities.SearchFilter;
+import com.franciaflex.faxtomail.services.service.imports.ArchiveImportResult;
import org.apache.commons.mail.EmailException;
import org.nuiton.util.pagination.PaginationParameter;
import org.nuiton.util.pagination.PaginationResult;
@@ -136,7 +137,6 @@
*
* @param is input stream of csv file
* @param attachmentBase base folder containing attachment listed in csv file
- * @return the number of imported archives
*/
- int importArchive(InputStream is, File attachmentBase);
+ ArchiveImportResult importArchive(InputStream is, File attachmentBase);
}
Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java 2014-10-15 13:09:19 UTC (rev 677)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java 2014-10-17 12:29:12 UTC (rev 678)
@@ -35,6 +35,7 @@
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.sql.Connection;
@@ -49,16 +50,24 @@
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
+import java.util.UUID;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.mail.MessagingException;
+import com.franciaflex.faxtomail.services.service.imports.ArchiveImportExportBean;
+import com.franciaflex.faxtomail.services.service.imports.ArchiveImportExportModel;
+import com.franciaflex.faxtomail.services.service.imports.ArchiveImportResult;
+import com.franciaflex.faxtomail.services.service.imports.InvalidArchiveImportBeanException;
+import com.google.common.base.Optional;
+import com.google.common.collect.Iterables;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.Predicate;
import org.apache.commons.io.FileUtils;
@@ -73,11 +82,18 @@
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.MultiPartEmail;
import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.StatelessSession;
+import org.hibernate.Transaction;
+import org.hibernate.TransactionException;
+import org.nuiton.csv.Export;
import org.nuiton.csv.Import;
-import org.nuiton.csv.ImportRuntimeException;
import org.nuiton.decorator.Decorator;
import org.nuiton.jaxx.application.ApplicationTechnicalException;
import org.nuiton.topia.persistence.TopiaEntities;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.TopiaQueryException;
+import org.nuiton.topia.persistence.support.TopiaHibernateSupport;
import org.nuiton.topia.persistence.support.TopiaSqlSupport;
import org.nuiton.topia.persistence.support.TopiaSqlWork;
import org.nuiton.util.beans.Binder;
@@ -92,8 +108,6 @@
import com.franciaflex.faxtomail.services.service.exceptions.AlreadyLockedMailException;
import com.franciaflex.faxtomail.services.service.exceptions.FolderNotReadableException;
import com.franciaflex.faxtomail.services.service.exceptions.InvalidClientException;
-import com.franciaflex.faxtomail.services.service.imports.ArchiveImportBean;
-import com.franciaflex.faxtomail.services.service.imports.ArchiveImportModel;
import com.github.mustachejava.DefaultMustacheFactory;
import com.github.mustachejava.Mustache;
import com.github.mustachejava.MustacheFactory;
@@ -1432,35 +1446,30 @@
return writer.toString();
}
- /**
- * Compute mail folder path (separated by /) from root to current.
- *
- * @param folder folder to get path
- * @return full mail folder path
- */
- protected String getFullMailFolderPath(MailFolder folder) {
- StringBuilder sb = new StringBuilder(folder.getName());
- MailFolder loopFolder = folder.getParent();
- while (loopFolder != null) {
- sb.insert(0, "/");
- sb.insert(0, loopFolder.getName());
- loopFolder = loopFolder.getParent();
- }
- return sb.toString();
- }
-
@Override
- public int importArchive(InputStream inputStream, File attachmentBase) {
+ public ArchiveImportResult importArchive(InputStream inputStream, File attachmentBase) {
- // all doas involved
- EmailTopiaDao emailDao = getPersistenceContext().getEmailDao();
- DemandTypeTopiaDao demandTypedao = getPersistenceContext().getDemandTypeDao();
- PriorityTopiaDao priorityDao = getPersistenceContext().getPriorityDao();
- WaitingStateTopiaDao waitingStateDao = getPersistenceContext().getWaitingStateDao();
- MailFolderTopiaDao mailFolderDao = getPersistenceContext().getMailFolderDao();
- AttachmentTopiaDao attachmentDao = getPersistenceContext().getAttachmentDao();
- AttachmentFileTopiaDao attachmentFileDao = getPersistenceContext().getAttachmentFileDao();
+ // all daos involved
+ FaxToMailTopiaPersistenceContext persistenceContext = getPersistenceContext();
+ TopiaHibernateSupport hibernateSupport = persistenceContext.getHibernateSupport();
+// Session hibernateSession = hibernateSupport.getHibernateSession();
+ StatelessSession statelessSession = hibernateSupport.getHibernateFactory().openStatelessSession();
+ Transaction transaction = statelessSession.beginTransaction();
+ EmailTopiaDao emailDao = persistenceContext.getEmailDao();
+ DemandTypeTopiaDao demandTypedao = persistenceContext.getDemandTypeDao();
+ PriorityTopiaDao priorityDao = persistenceContext.getPriorityDao();
+ WaitingStateTopiaDao waitingStateDao = persistenceContext.getWaitingStateDao();
+ MailFolderTopiaDao mailFolderDao = persistenceContext.getMailFolderDao();
+ AttachmentTopiaDao attachmentDao = persistenceContext.getAttachmentDao();
+ AttachmentFileTopiaDao attachmentFileDao = persistenceContext.getAttachmentFileDao();
+ HistoryTopiaDao historyDao = persistenceContext.getHistoryDao();
+
+ int commitThreshold = getApplicationConfig().getArchiveImportCommitTreshold();
+ if (log.isInfoEnabled()) {
+ log.info("commit every " + commitThreshold + " archives imported");
+ }
+
// get referentiel map
Map<String, DemandType> allDemandTypes = Maps.uniqueIndex(demandTypedao, new Function<DemandType, String>() {
@Override
@@ -1485,69 +1494,186 @@
Map<String, MailFolder> mailFolderMap = Maps.uniqueIndex(mailFolderDao, new Function<MailFolder, String>() {
@Override
public String apply(MailFolder input) {
- return getFullMailFolderPath(input);
+ return FaxToMailServiceUtils.getFullMailFolderPath(input);
}
});
// run import
- ArchiveImportModel archiveImportModel = new ArchiveImportModel(';', allWaitingStates, allDemandTypes, allPriority, mailFolderMap);
- Binder<ArchiveImportBean, Email> emailBinder = BinderFactory.newBinder(ArchiveImportBean.class, Email.class);
- Import<ArchiveImportBean> importer = null;
+ ArchiveImportExportModel archiveImportExportModel = new ArchiveImportExportModel(';', allWaitingStates, allDemandTypes, allPriority);
+ Binder<ArchiveImportExportBean, Email> emailBinder = BinderFactory.newBinder(ArchiveImportExportBean.class, Email.class);
+ Import<ArchiveImportExportBean> importer = null;
- int result = 0;
+ // cache of archive folders
+ Map<MailFolder, MailFolder> archiveFoldersByFolder = new HashMap<>();
+ Map<MailFolder, String> companyByFolder = new HashMap<>();
+ ArchiveImportResult result = new ArchiveImportResult();
+
+ Set<ArchiveImportExportBean> notImportedBeans = new HashSet<>();
+ Set<ArchiveImportExportBean> toCommitBeans = new HashSet<>();
+
try {
- importer = Import.newImport(archiveImportModel, new InputStreamReader(inputStream, getApplicationConfig().getImportFileEncoding()));
- for (ArchiveImportBean archiveBean : importer) {
+ importer = Import.newImport(archiveImportExportModel, new InputStreamReader(inputStream, getApplicationConfig().getImportFileEncoding()));
+ Iterator<ArchiveImportExportBean> iterator = importer.iterator();
+ int index = 0;
- if (archiveBean.getProjectReference() == null) {
- log.error("null project ref for " + archiveBean.getReceptionDate());
- }
- if (archiveBean.getMailFolder() == null) {
- log.error("null mail folder for " + archiveBean.getReceptionDate());
- }
- // create new email to persist
- //TODO add modified properties
- Email email = emailDao.newInstance();
- emailBinder.copy(archiveBean, email);
- email.setDemandStatus(DemandStatus.ARCHIVED);
+ while (iterator.hasNext()) {
+ try {
+ ArchiveImportExportBean archiveBean = iterator.next();
+ toCommitBeans.add(archiveBean);
+ index++;
+ if (archiveBean.getProjectReference() == null) {
+ log.error("null project ref for " + archiveBean.getReceptionDate());
+ }
- // persist it
- email = emailDao.create(email);
+ String mailFolderPath = archiveBean.getMailFolderPath();
+ MailFolder folder = mailFolderMap.get(mailFolderPath);
+ archiveBean.setMailFolder(folder);
- // manage attachments
- if (archiveBean.getAttachmentPaths() != null) {
- Iterable<String> itAttachmentPaths = Splitter.on(',').omitEmptyStrings().trimResults().split(archiveBean.getAttachmentPaths());
- for (String attachmentPath : itAttachmentPaths) {
- File attFile;
- if (attachmentBase != null) {
- attFile = new File(attachmentBase, attachmentPath);
- } else {
- attFile = new File(attachmentPath);
+ if (archiveBean.getMailFolder() == null) {
+ log.error("null mail folder for " + archiveBean.getReceptionDate());
+ String errorMessage = t("faxtomail.archives.import.error.invalidFolder", mailFolderPath);
+ throw new InvalidArchiveImportBeanException(errorMessage, archiveBean);
+ }
+ // create new email to persist
+ Email email = emailDao.newInstance();
+ emailBinder.copy(archiveBean, email);
+
+ email.setDemandStatus(DemandStatus.ARCHIVED);
+
+ MailFolder archiveChild = null;
+ String company = null;
+ boolean companyFound = false;
+
+ if (!archiveFoldersByFolder.containsKey(folder)) {
+ do {
+ if (archiveChild == null && folder.getChildren() != null) {
+ Optional<MailFolder> optArchiveChild = Iterables.tryFind(folder.getChildren(), new com.google.common.base.Predicate<MailFolder>() {
+ @Override
+ public boolean apply(MailFolder mailFolder) {
+ return mailFolder.isArchiveFolder();
+ }
+ });
+ if (optArchiveChild.isPresent()) {
+ archiveChild = optArchiveChild.get();
+ }
+ }
+ if (!companyFound && folder.isUseCurrentLevelCompany()) {
+ companyFound = true;
+ company = folder.getCompany();
+ }
+ folder = folder.getParent();
+
+ } while ((archiveChild == null || !companyFound) && folder != null);
+
+ archiveFoldersByFolder.put(folder, archiveChild);
+ companyByFolder.put(folder, company);
+
+ } else {
+ archiveChild = archiveFoldersByFolder.get(folder);
+ company = companyByFolder.get(folder);
+ }
+
+ // le dossier d'archive peut ne pas exister. Dans ce cas on laisse le mail dans le dossier
+ // d'origine
+ if (archiveChild != null) {
+ email.setMailFolder(archiveChild);
+ }
+
+ Client client = getClientService().getClientForCode(archiveBean.getClientCode(), company);
+ email.setClient(client);
+
+ History history = historyDao.newInstance();
+ history.setType(HistoryType.ARCHIVED);
+ history.setModificationDate(new Date());
+ history.setTopiaId(getTopiaId(History.class, history));
+ statelessSession.insert(history);
+
+ email.addHistory(history);
+ // persist it
+ email.setTopiaId(getTopiaId(Email.class, email));
+ statelessSession.insert(email);
+
+ // manage attachments
+ if (archiveBean.getAttachmentPaths() != null) {
+ Iterable<String> itAttachmentPaths = Splitter.on(',').omitEmptyStrings().trimResults().split(archiveBean.getAttachmentPaths());
+ for (String attachmentPath : itAttachmentPaths) {
+ File attFile;
+ if (attachmentBase != null) {
+ attFile = new File(attachmentBase, attachmentPath);
+ } else {
+ attFile = new File(attachmentPath);
+ }
+ if (!attFile.isFile()) {
+ String errorMessage = t("faxtomail.archives.import.error.invalidAttachmentPath", attachmentPath);
+ throw new InvalidArchiveImportBeanException(errorMessage, archiveBean);
+ }
+
+ Attachment attachment = attachmentDao.newInstance();
+ AttachmentFile attachmentFile = attachmentFileDao.newInstance();
+ attachmentFile.setFilename(attFile.getName());
+
+ try {
+ attachmentFile.setContent(FileUtils.readFileToByteArray(attFile));
+ } catch (IOException e) {
+ String errorMessage = t("faxtomail.archives.import.error.readingAttachmentFile", attachmentPath);
+ throw new InvalidArchiveImportBeanException(errorMessage, archiveBean);
+ }
+ attachmentFile.setTopiaId(getTopiaId(AttachmentFile.class, attachmentFile));
+ statelessSession.insert(attachmentFile);
+
+ attachment.setOriginalFile(attachmentFile);
+
+ attachment.setTopiaId(getTopiaId(Attachment.class, attachment));
+ statelessSession.insert(attachment);
+
+ email.addAttachment(attachment);
}
- if (!attFile.isFile()) {
- throw new RuntimeException("Missing file " + attFile.getAbsolutePath());
+
+ statelessSession.update(email);
+ if (log.isDebugEnabled()) {
+ log.debug("add archive " + index);
}
- Attachment attachment = new AttachmentImpl();
- AttachmentFile attachmentFile = new AttachmentFileImpl();
- attachmentFile.setFilename(attFile.getName());
- attachmentFile.setContent(FileUtils.readFileToByteArray(attFile));
- attachmentFile = attachmentFileDao.create(attachmentFile);
- attachment.setOriginalFile(attachmentFile);
+ }
- attachment = attachmentDao.create(attachment);
- email.addAttachment(attachment);
+ if (index % commitThreshold == 0 || !iterator.hasNext()) {
+ transaction.commit();
+ transaction = statelessSession.beginTransaction();
+
+ result.addNbImportedArchives(toCommitBeans.size());
+ toCommitBeans.clear();
}
-
- emailDao.update(email);
- result++;
+
+ } catch (InvalidArchiveImportBeanException e) {
+ log.error(e.getMessage(), e);
+ notImportedBeans.add(e.getBean());
+
+ } catch (HibernateException | TopiaQueryException e) {
+ String message;
+ if (e.getCause() != null) {
+ message = e.getCause().getMessage();
+ } else {
+ message = e.getMessage();
+ }
+ log.error(message, e);
+
+ String errorMessage = t("faxtomail.archives.import.error.persistence");
+ for (ArchiveImportExportBean bean : toCommitBeans) {
+ bean.setError(errorMessage);
+ notImportedBeans.add(bean);
+ }
+ toCommitBeans.clear();
+
+ while (iterator.hasNext()) {
+ ArchiveImportExportBean next = iterator.next();
+ next.setError(errorMessage);
+ notImportedBeans.add(next);
+ }
}
}
- getPersistenceContext().commit();
-
- } catch (ImportRuntimeException|IOException e) {
+ } catch (UnsupportedEncodingException e) {
String message;
if (e.getCause() != null) {
message = e.getCause().getMessage();
@@ -1555,14 +1681,34 @@
message = e.getMessage();
}
throw new ApplicationTechnicalException(message, e);
+
} finally {
IOUtils.closeQuietly(importer);
IOUtils.closeQuietly(inputStream);
}
+ if (!notImportedBeans.isEmpty()) {
+ try {
+ result.addNbImportErrors(notImportedBeans.size());
+ Export<ArchiveImportExportBean> exporter = Export.newExport(archiveImportExportModel, notImportedBeans);
+
+ String fileName = DateFormatUtils.format(new Date(), "yyyyMMddhhmmss") + "-" + UUID.randomUUID() + ".csv";
+ File errorFile = new File(getApplicationConfig().getDataDirectory(), fileName);
+ exporter.write(errorFile);
+ result.setErrorFile(errorFile);
+
+ } catch (Exception e) {
+ log.error(e);
+ }
+ }
+
return result;
}
+ protected String getTopiaId(Class clazz, TopiaEntity entity) {
+ return getPersistenceContext().getTopiaIdFactory().newTopiaId(clazz, entity);
+ }
+
@Override
public long getArchivedMailCount() {
EmailTopiaDao emailDao = getPersistenceContext().getEmailDao();
Deleted: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportBean.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportBean.java 2014-10-15 13:09:19 UTC (rev 677)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportBean.java 2014-10-17 12:29:12 UTC (rev 678)
@@ -1,73 +0,0 @@
-package com.franciaflex.faxtomail.services.service.imports;
-
-/*
- * #%L
- * FaxToMail :: Service
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2014 Mac-Groupe, 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 com.franciaflex.faxtomail.persistence.entities.EmailImpl;
-
-/**
- * Bean model d'import des archives. (très proche de l'entité
- * {@link com.franciaflex.faxtomail.persistence.entities.Email}).
- *
- * @author Eric Chatellier
- */
-public class ArchiveImportBean extends EmailImpl {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 1498046445018851410L;
-
- protected static final String PROPERTY_ATTACHMENT_PATHS = "attachmentPaths";
- protected static final String PROPERTY_CLIENT_CODE = "clientCode";
- protected static final String PROPERTY_CLIENT_BRAND = "clientBrand";
-
- protected String attachmentPaths;
-
- protected String clientCode;
-
- protected String clientBrand;
-
- public String getAttachmentPaths() {
- return attachmentPaths;
- }
-
- public void setAttachmentPaths(String attachmentPaths) {
- this.attachmentPaths = attachmentPaths;
- }
-
- public String getClientCode() {
- return clientCode;
- }
-
- public void setClientCode(String clientCode) {
- this.clientCode = clientCode;
- }
-
- public String getClientBrand() {
- return clientBrand;
- }
-
- public void setClientBrand(String clientBrand) {
- this.clientBrand = clientBrand;
- }
-}
Copied: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportExportBean.java (from rev 677, trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportBean.java)
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportExportBean.java (rev 0)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportExportBean.java 2014-10-17 12:29:12 UTC (rev 678)
@@ -0,0 +1,95 @@
+package com.franciaflex.faxtomail.services.service.imports;
+
+/*
+ * #%L
+ * FaxToMail :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2014 Mac-Groupe, 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 com.franciaflex.faxtomail.persistence.entities.EmailImpl;
+
+/**
+ * Bean model d'import des archives. (très proche de l'entité
+ * {@link com.franciaflex.faxtomail.persistence.entities.Email}).
+ *
+ * @author Eric Chatellier
+ */
+public class ArchiveImportExportBean extends EmailImpl {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 1498046445018851410L;
+
+ protected static final String PROPERTY_MAIL_FOLDER_PATHS = "mailFolderPath";
+ protected static final String PROPERTY_ATTACHMENT_PATHS = "attachmentPaths";
+ protected static final String PROPERTY_CLIENT_CODE = "clientCode";
+ protected static final String PROPERTY_CLIENT_BRAND = "clientBrand";
+ protected static final String PROPERTY_ERROR = "error";
+
+ protected String mailFolderPath;
+
+ protected String attachmentPaths;
+
+ protected String clientCode;
+
+ protected String clientBrand;
+
+ protected String error;
+
+ public String getMailFolderPath() {
+ return mailFolderPath;
+ }
+
+ public void setMailFolderPath(String mailFolderPath) {
+ this.mailFolderPath = mailFolderPath;
+ }
+
+ public String getAttachmentPaths() {
+ return attachmentPaths;
+ }
+
+ public void setAttachmentPaths(String attachmentPaths) {
+ this.attachmentPaths = attachmentPaths;
+ }
+
+ public String getClientCode() {
+ return clientCode;
+ }
+
+ public void setClientCode(String clientCode) {
+ this.clientCode = clientCode;
+ }
+
+ public String getClientBrand() {
+ return clientBrand;
+ }
+
+ public void setClientBrand(String clientBrand) {
+ this.clientBrand = clientBrand;
+ }
+
+ public String getError() {
+ return error;
+ }
+
+ public void setError(String error) {
+ this.error = error;
+ }
+}
Property changes on: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportExportBean.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportExportModel.java (from rev 677, trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportModel.java)
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportExportModel.java (rev 0)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportExportModel.java 2014-10-17 12:29:12 UTC (rev 678)
@@ -0,0 +1,149 @@
+package com.franciaflex.faxtomail.services.service.imports;
+
+/*
+ * #%L
+ * FaxToMail :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2014 Mac-Groupe, 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.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Map;
+
+import com.franciaflex.faxtomail.persistence.entities.HasLabel;
+import com.franciaflex.faxtomail.services.FaxToMailServiceUtils;
+import org.nuiton.csv.Common;
+import org.nuiton.csv.ValueParserFormatter;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+
+import com.franciaflex.faxtomail.persistence.entities.DemandType;
+import com.franciaflex.faxtomail.persistence.entities.WaitingState;
+import com.franciaflex.faxtomail.persistence.entities.MailFolder;
+import com.franciaflex.faxtomail.persistence.entities.Priority;
+
+/**
+ * Modele d'import des archives, défini comme suit:
+ *
+ * receptionDate;projectReference;sender;fax;recipient;object;archiveDate;companyReference;
+ * originalEmail;comment;etatAttente;demandType;priority;mailFolder;client-code;client-brand;attachments
+ *
+ * @author Eric Chatellier
+ */
+public class ArchiveImportExportModel extends AbstractImportExportModel<ArchiveImportExportBean> {
+
+ /**
+ * Parse date pattern : dd/MM/yyyy hh:mm:ss.
+ */
+ protected ValueParserFormatter<Date> dateValueParserFormatter = new ValueParserFormatter<Date>() {
+ protected DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
+ @Override
+ public Date parse(String value) throws ParseException {
+ return dateFormat.parse(value);
+ }
+
+ @Override
+ public String format(Date value) {
+ return dateFormat.format(value);
+ }
+ };
+
+ public ArchiveImportExportModel(char separator,
+ final Map<String, WaitingState> waitingStates,
+ final Map<String, DemandType> demandTypes,
+ final Map<String, Priority> priorities) {
+ super(separator);
+
+ newColumnForImportExport("receptionDate", ArchiveImportExportBean.PROPERTY_RECEPTION_DATE, dateValueParserFormatter);
+ newColumnForImportExport("projectReference", ArchiveImportExportBean.PROPERTY_PROJECT_REFERENCE);
+ newColumnForImportExport("sender", ArchiveImportExportBean.PROPERTY_SENDER, new ValueParserFormatter<Object>() {
+ @Override
+ public Object parse(String value) throws ParseException {
+ value = value.replaceFirst("^.*<(.*)>$", "$1");
+ value = value.toLowerCase();
+ return value;
+ }
+
+ @Override
+ public String format(Object value) {
+ return value != null ? value.toString() : "";
+ }
+ });
+ newColumnForImportExport("fax", ArchiveImportExportBean.PROPERTY_FAX, Common.PRIMITIVE_BOOLEAN);
+ newColumnForImportExport("recipient", ArchiveImportExportBean.PROPERTY_RECIPIENT);
+ newColumnForImportExport("object", ArchiveImportExportBean.PROPERTY_OBJECT);
+ newColumnForImportExport("archiveDate", ArchiveImportExportBean.PROPERTY_ARCHIVE_DATE, dateValueParserFormatter);
+ newColumnForImportExport("companyReference", ArchiveImportExportBean.PROPERTY_COMPANY_REFERENCE);
+ newColumnForImportExport("originalEmail", ArchiveImportExportBean.PROPERTY_ORIGINAL_EMAIL);
+ newColumnForImportExport("comment", ArchiveImportExportBean.PROPERTY_COMMENT);
+ newColumnForImportExport("etatAttente", ArchiveImportExportBean.PROPERTY_WAITING_STATE, new HasLabelValueParserFormatter<WaitingState>() {
+ @Override
+ public WaitingState parse(String value) throws ParseException {
+ return waitingStates.get(value);
+ }
+ });
+ newColumnForImportExport("demandType", ArchiveImportExportBean.PROPERTY_DEMAND_TYPE, new HasLabelValueParserFormatter<DemandType>() {
+ @Override
+ public DemandType parse(String value) throws ParseException {
+ return demandTypes.get(value);
+ }
+ });
+ newColumnForImportExport("priority", ArchiveImportExportBean.PROPERTY_PRIORITY, new HasLabelValueParserFormatter<Priority>() {
+ @Override
+ public Priority parse(String value) throws ParseException {
+ return priorities.get(value);
+ }
+ });
+// newMandatoryColumn("mailFolder", ArchiveImportExportBean.PROPERTY_MAIL_FOLDER, new ValueParserFormatter<MailFolder>() {
+// @Override
+// public MailFolder parse(String value) throws ParseException {
+// return mailFolderMap.get(value);
+// }
+//
+// @Override
+// public String format(MailFolder value) {
+// return value != null ? FaxToMailServiceUtils.getFullMailFolderPath(value) : "";
+// }
+// });
+ newColumnForImportExport("mailFolder", ArchiveImportExportBean.PROPERTY_MAIL_FOLDER_PATHS);
+ newColumnForImportExport("client-code", ArchiveImportExportBean.PROPERTY_CLIENT_CODE);
+ newOptionalColumn("client-brand", ArchiveImportExportBean.PROPERTY_CLIENT_BRAND);
+ newColumnForExport("client-brand", ArchiveImportExportBean.PROPERTY_CLIENT_BRAND);
+ newColumnForImportExport("attachments", ArchiveImportExportBean.PROPERTY_ATTACHMENT_PATHS);
+
+ newOptionalColumn("error", ArchiveImportExportBean.PROPERTY_ERROR);
+ newColumnForExport("error", ArchiveImportExportBean.PROPERTY_ERROR);
+ }
+
+ @Override
+ public ArchiveImportExportBean newEmptyInstance() {
+ return new ArchiveImportExportBean();
+ }
+
+ protected abstract class HasLabelValueParserFormatter<E extends HasLabel> implements ValueParserFormatter<E> {
+
+ @Override
+ public String format(E value) {
+ return value != null ? value.getLabel() : "";
+ }
+ }
+}
Property changes on: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportExportModel.java
___________________________________________________________________
Added: svn:eol-style
+ native
Added: svn:keywords
+ Author Date Id Revision HeadURL
Deleted: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportModel.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportModel.java 2014-10-15 13:09:19 UTC (rev 677)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportModel.java 2014-10-17 12:29:12 UTC (rev 678)
@@ -1,129 +0,0 @@
-package com.franciaflex.faxtomail.services.service.imports;
-
-/*
- * #%L
- * FaxToMail :: Service
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2014 Mac-Groupe, 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.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Map;
-
-import org.nuiton.csv.Common;
-import org.nuiton.csv.ValueParser;
-import org.nuiton.csv.ext.AbstractImportModel;
-
-import com.franciaflex.faxtomail.persistence.entities.DemandType;
-import com.franciaflex.faxtomail.persistence.entities.Email;
-import com.franciaflex.faxtomail.persistence.entities.WaitingState;
-import com.franciaflex.faxtomail.persistence.entities.MailFolder;
-import com.franciaflex.faxtomail.persistence.entities.Priority;
-
-/**
- * Modele d'import des archives, défini comme suit:
- *
- * receptionDate;projectReference;sender;fax;recipient;object;archiveDate;companyReference;
- * originalEmail;comment;etatAttente;demandType;priority;mailFolder;client-code;client-brand;attachments
- *
- * @author Eric Chatellier
- */
-public class ArchiveImportModel extends AbstractImportModel<ArchiveImportBean> {
-
- /**
- * Parse date pattern : dd/MM/yyyy hh:mm:ss.
- */
- protected ValueParser<Date> dateValueParser = new ValueParser<Date>() {
- protected DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
- @Override
- public Date parse(String value) throws ParseException {
- return dateFormat.parse(value);
- }
- };
-
- /**
- * Parser for boolean fields.
- */
- protected ValueParser<Boolean> yesNoParser = new ValueParser<Boolean>() {
- @Override
- public Boolean parse(String value) throws ParseException {
- return "oui".equalsIgnoreCase(value);
- }
- };
-
- public ArchiveImportModel(char separator,
- final Map<String, WaitingState> waitingStates, final Map<String, DemandType> demandTypes,
- final Map<String, Priority> priorities, final Map<String, MailFolder> mailFolderMap) {
- super(separator);
-
- newMandatoryColumn("receptionDate", Email.PROPERTY_RECEPTION_DATE, dateValueParser);
- newMandatoryColumn("projectReference", Email.PROPERTY_PROJECT_REFERENCE);
- newMandatoryColumn("sender", Email.PROPERTY_SENDER, new ValueParser<Object>() {
- @Override
- public Object parse(String value) throws ParseException {
- value = value.replaceFirst("^.*<(.*)>$", "$1");
- value = value.toLowerCase();
- return value;
- }
- });
- newMandatoryColumn("fax", Email.PROPERTY_FAX, Common.PRIMITIVE_BOOLEAN);
- newMandatoryColumn("recipient", Email.PROPERTY_RECIPIENT);
- newMandatoryColumn("object", Email.PROPERTY_OBJECT);
- newMandatoryColumn("archiveDate", Email.PROPERTY_ARCHIVE_DATE, dateValueParser);
- newMandatoryColumn("companyReference", Email.PROPERTY_COMPANY_REFERENCE);
- newMandatoryColumn("originalEmail", Email.PROPERTY_ORIGINAL_EMAIL);
- newMandatoryColumn("comment", Email.PROPERTY_COMMENT);
- newMandatoryColumn("etatAttente", Email.PROPERTY_WAITING_STATE, new ValueParser<WaitingState>() {
- @Override
- public WaitingState parse(String value) throws ParseException {
- return waitingStates.get(value);
- }
- });
- newMandatoryColumn("demandType", Email.PROPERTY_DEMAND_TYPE, new ValueParser<DemandType>() {
- @Override
- public DemandType parse(String value) throws ParseException {
- return demandTypes.get(value);
- }
- });
- newMandatoryColumn("priority", Email.PROPERTY_PRIORITY, new ValueParser<Priority>() {
- @Override
- public Priority parse(String value) throws ParseException {
- return priorities.get(value);
- }
- });
- newMandatoryColumn("mailFolder", Email.PROPERTY_MAIL_FOLDER, new ValueParser<MailFolder>() {
- @Override
- public MailFolder parse(String value) throws ParseException {
- return mailFolderMap.get(value);
- }
- });
- newMandatoryColumn("client-code", ArchiveImportBean.PROPERTY_CLIENT_CODE);
- newMandatoryColumn("client-brand", ArchiveImportBean.PROPERTY_CLIENT_BRAND);
- newMandatoryColumn("attachments", ArchiveImportBean.PROPERTY_ATTACHMENT_PATHS);
- }
-
- @Override
- public ArchiveImportBean newEmptyInstance() {
- return new ArchiveImportBean();
- }
-}
Added: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportResult.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportResult.java (rev 0)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/ArchiveImportResult.java 2014-10-17 12:29:12 UTC (rev 678)
@@ -0,0 +1,38 @@
+package com.franciaflex.faxtomail.services.service.imports;
+
+import java.io.File;
+
+/**
+ * @author Kevin Morin (Code Lutin)
+ * @since 1.1
+ */
+public class ArchiveImportResult {
+
+ protected int nbImportedArchives = 0;
+ protected int nbImportErrors = 0;
+ protected File errorFile;
+
+ public int getNbImportedArchives() {
+ return nbImportedArchives;
+ }
+
+ public void addNbImportedArchives(int nbImportedArchives) {
+ this.nbImportedArchives += nbImportedArchives;
+ }
+
+ public int getNbImportErrors() {
+ return nbImportErrors;
+ }
+
+ public void addNbImportErrors(int nbImportErrors) {
+ this.nbImportErrors += nbImportErrors;
+ }
+
+ public File getErrorFile() {
+ return errorFile;
+ }
+
+ public void setErrorFile(File errorFile) {
+ this.errorFile = errorFile;
+ }
+}
Added: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/InvalidArchiveImportBeanException.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/InvalidArchiveImportBeanException.java (rev 0)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/imports/InvalidArchiveImportBeanException.java 2014-10-17 12:29:12 UTC (rev 678)
@@ -0,0 +1,20 @@
+package com.franciaflex.faxtomail.services.service.imports;
+
+/**
+ * @author Kevin Morin (Code Lutin)
+ * @since 1.1
+ */
+public class InvalidArchiveImportBeanException extends RuntimeException {
+
+ protected ArchiveImportExportBean bean;
+
+ public InvalidArchiveImportBeanException(String message, ArchiveImportExportBean bean) {
+ super(message);
+ this.bean = bean;
+ this.bean.setError(message);
+ }
+
+ public ArchiveImportExportBean getBean() {
+ return bean;
+ }
+}
Modified: trunk/faxtomail-service/src/main/resources/i18n/faxtomail-service_fr_FR.properties
===================================================================
--- trunk/faxtomail-service/src/main/resources/i18n/faxtomail-service_fr_FR.properties 2014-10-15 13:09:19 UTC (rev 677)
+++ trunk/faxtomail-service/src/main/resources/i18n/faxtomail-service_fr_FR.properties 2014-10-17 12:29:12 UTC (rev 678)
@@ -1,3 +1,7 @@
+faxtomail.archives.import.error.invalidAttachmentPath=%s n'est pas un fichier
+faxtomail.archives.import.error.invalidFolder=Dossier %s non valide
+faxtomail.archives.import.error.persistence=Erreur technique de persistence
+faxtomail.archives.import.error.readingAttachmentFile=Erreur lors de la lecture de la PJ %s
faxtomail.attachment.demand.filename=Détail de la demande
faxtomail.email.projectReference.default=Votre demande du %s
faxtomail.service.email.save.clientCode.error=Impossible de trouver le client %s \!
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java 2014-10-15 13:09:19 UTC (rev 677)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/GenerateAnnotatedAttachmentAction.java 2014-10-17 12:29:12 UTC (rev 678)
@@ -240,11 +240,6 @@
pdfStamper.close();
pdfReader.close();
- Document document = new Document();
- PdfWriter writer = PdfWriter.getInstance(document, fos);
- PdfAction action = new PdfAction(PdfAction.PRINTDIALOG);
- writer.setOpenAction(action);
-
// convert content to blob
InputStream is = new BufferedInputStream(new FileInputStream(target));
FaxToMailServiceContext serviceContext = getContext().newServiceContext();
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java 2014-10-15 13:09:19 UTC (rev 677)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java 2014-10-17 12:29:12 UTC (rev 678)
@@ -68,6 +68,7 @@
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
+import com.sun.pdfview.PDFPrintPage;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.JAXXUtil;
@@ -114,7 +115,7 @@
import com.sun.media.jai.codec.ImageDecoder;
import com.sun.media.jai.codec.SeekableStream;
import com.sun.pdfview.PDFFile;
-import com.sun.pdfview.PDFPrintPage;
+//import com.sun.pdfview.PDFPrintPage;
/**
* @author kmorin - morin(a)codelutin.com
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailApplicationListener.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailApplicationListener.java 2014-10-15 13:09:19 UTC (rev 677)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailApplicationListener.java 2014-10-17 12:29:12 UTC (rev 678)
@@ -141,7 +141,7 @@
log.info("Stopping quartz sheduler");
}
}
-
+
try {
// wait for thread to complete
scheduler.shutdown();
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportArchiveAction.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportArchiveAction.java 2014-10-15 13:09:19 UTC (rev 677)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportArchiveAction.java 2014-10-17 12:29:12 UTC (rev 678)
@@ -27,7 +27,9 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
+import java.nio.file.Files;
+import com.franciaflex.faxtomail.services.service.imports.ArchiveImportResult;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -60,6 +62,12 @@
protected EmailService emailService;
+ protected ArchiveImportResult importResult;
+
+ protected InputStream inputStream;
+ protected String fileName;
+ protected String contentType;
+
public void setEmailService(EmailService emailService) {
this.emailService = emailService;
}
@@ -88,27 +96,24 @@
@Override
public void validate() {
- if (StringUtils.isNotBlank(attachmentBase) && !new File(attachmentBase).isDirectory()) {
- addActionError("Le répertoire de base des pièces jointes n'est pas un répertoire lisible !");
+ if (StringUtils.isBlank(fileName)) {
+ if (StringUtils.isNotBlank(attachmentBase) && !new File(attachmentBase).isDirectory()) {
+ addActionError("Le répertoire de base des pièces jointes n'est pas un répertoire lisible !");
+ }
+ if (archiveFile == null) {
+ addActionError("Le fichier d'archive est obligatoire !");
+ }
}
- if (archiveFile == null) {
- addActionError("Le fichier d'archive est obligatoire !");
- }
}
@Override
- @Action(results = {@Result(type = "redirectAction", params = {"actionName", "import-archive-input"})})
+ @Action("import-archive")
public String execute() throws Exception {
String result = INPUT;
try (InputStream is = new FileInputStream(archiveFile)) {
File file = StringUtils.isNotBlank(attachmentBase) ? new File(attachmentBase) : null;
- int imported = emailService.importArchive(is, file);
+ importResult = emailService.importArchive(is, file);
- log.info(imported + " imported elements");
- addActionMessage(imported + " éléments ont été importés.");
-
- result = SUCCESS;
-
} catch (Exception ex) {
if (log.isErrorEnabled()) {
log.error("Can't import archive file", ex);
@@ -118,4 +123,42 @@
return result;
}
+
+ @Action(value = "download-import-archive-errorfile",
+ results = {@Result(name = "success",
+ type = "stream",
+ params = {
+ "contentType", "${contentType}",
+ "inputName", "inputStream",
+ "contentDisposition", "attachment;filename=\"${fileName}\"",
+ "bufferSize", "1024"
+ })
+ })
+ public String downloadImportErrorFile() throws Exception {
+ File file = new File(getApplicationConfig().getDataDirectory(), fileName);
+ log.info(fileName + " exists : " + file.exists());
+ contentType = Files.probeContentType(file.toPath());
+ inputStream = new FileInputStream(file);
+ return SUCCESS;
+ }
+
+ public ArchiveImportResult getImportResult() {
+ return importResult;
+ }
+
+ public InputStream getInputStream() {
+ return inputStream;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public String getContentType() {
+ return contentType;
+ }
}
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/import-archive-input.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/import-archive-input.jsp 2014-10-15 13:09:19 UTC (rev 677)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/import-archive-input.jsp 2014-10-17 12:29:12 UTC (rev 678)
@@ -39,6 +39,26 @@
<s:form id="main_form" action="import-archive" method="post" enctype="multipart/form-data">
<s:actionmessage/>
+
+ <s:if test="importResult != null">
+ <div class="alert alert-success">
+ <s:property value="importResult.nbImportedArchives"/> archives ont été importées.
+ </div>
+
+ <s:if test="importResult.getNbImportErrors() > 0">
+ <s:url id="downloadErrorFile" value="download-import-archive-errorfile.action">
+ <s:param name="fileName" value="%{importResult.errorFile.name}" />
+ </s:url>
+ <div class="alert alert-danger">
+ <s:property value="importResult.nbImportErrors"/> archives n'ont pas pu été importées.
+ Pour télécharger le fichier contenant les archives non importées,
+ <s:a href="%{downloadErrorFile}" title="Télécharger le fichier contenant les archives non importées">
+ cliquez ici
+ </s:a>.
+ </div>
+ </s:if>
+ </s:if>
+
<s:actionerror/>
<div class="form-group">
1
0
r677 - in trunk: faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service faxtomail-ui-swing faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util faxtomail-ui-web faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin
by kmorin@users.forge.codelutin.com 15 Oct '14
by kmorin@users.forge.codelutin.com 15 Oct '14
15 Oct '14
Author: kmorin
Date: 2014-10-15 15:09:19 +0200 (Wed, 15 Oct 2014)
New Revision: 677
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/677
Log:
fixes #5964 Probl?\195?\168mes de police sur l'?\195?\169diteur de pdf et l'impression
Modified:
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailServiceImpl.java
trunk/faxtomail-ui-swing/pom.xml
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java
trunk/faxtomail-ui-web/pom.xml
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailInterceptor.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportArchiveAction.java
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/import-archive-input.jsp
Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailServiceImpl.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailServiceImpl.java 2014-10-10 15:19:24 UTC (rev 676)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/InitFaxToMailServiceImpl.java 2014-10-15 13:09:19 UTC (rev 677)
@@ -217,10 +217,14 @@
// root folders (~companies)
MailFolder franciaflex = folderDao.create(MailFolder.PROPERTY_NAME, "Franciaflex",
+ MailFolder.PROPERTY_USE_CURRENT_LEVEL_COMPANY, true,
+ MailFolder.PROPERTY_COMPANY, "FX",
MailFolder.PROPERTY_USE_CURRENT_LEVEL_REJECT_RESPONSE_MAIL_ADDRESS, true,
MailFolder.PROPERTY_USE_CURRENT_LEVEL_REJECT_RESPONSE_MESSAGE, true);
MailFolder faber = folderDao.create(MailFolder.PROPERTY_NAME, "Faber");
- MailFolder franceFermeture = folderDao.create(MailFolder.PROPERTY_NAME, "France-fermeture");
+ MailFolder franceFermeture = folderDao.create(MailFolder.PROPERTY_NAME, "France Fermetures",
+ MailFolder.PROPERTY_USE_CURRENT_LEVEL_COMPANY, true,
+ MailFolder.PROPERTY_COMPANY, "FF");
// categories
MailFolder chargesClientelle = folderDao.create(MailFolder.PROPERTY_NAME, "Chargés de clientèle",
Modified: trunk/faxtomail-ui-swing/pom.xml
===================================================================
--- trunk/faxtomail-ui-swing/pom.xml 2014-10-10 15:19:24 UTC (rev 676)
+++ trunk/faxtomail-ui-swing/pom.xml 2014-10-15 13:09:19 UTC (rev 677)
@@ -226,11 +226,6 @@
</dependency>
<dependency>
- <groupId>org.apache.pdfbox</groupId>
- <artifactId>pdfbox</artifactId>
- </dependency>
-
- <dependency>
<groupId>org.swinglabs</groupId>
<artifactId>pdf-renderer</artifactId>
</dependency>
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java 2014-10-10 15:19:24 UTC (rev 676)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java 2014-10-15 13:09:19 UTC (rev 677)
@@ -52,15 +52,10 @@
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
-import java.util.Locale;
import java.util.Map;
import java.util.regex.Pattern;
import javax.media.jai.PlanarImage;
-import javax.print.PrintService;
-import javax.print.attribute.HashPrintRequestAttributeSet;
-import javax.print.attribute.PrintRequestAttributeSet;
-import javax.print.attribute.standard.JobName;
import javax.swing.Icon;
import javax.swing.JTextPane;
import javax.swing.JTree;
@@ -73,7 +68,6 @@
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
-import com.itextpdf.text.RectangleReadOnly;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.JAXXUtil;
@@ -86,7 +80,6 @@
import org.apache.commons.lang3.SystemUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.pdmodel.PDDocument;
import org.nuiton.jaxx.application.ApplicationTechnicalException;
import org.nuiton.jaxx.application.swing.util.ApplicationUIUtil;
import org.nuiton.util.FileUtil;
@@ -120,6 +113,8 @@
import com.sun.media.jai.codec.ImageCodec;
import com.sun.media.jai.codec.ImageDecoder;
import com.sun.media.jai.codec.SeekableStream;
+import com.sun.pdfview.PDFFile;
+import com.sun.pdfview.PDFPrintPage;
/**
* @author kmorin - morin(a)codelutin.com
@@ -501,28 +496,40 @@
protected static boolean printWithPdfRenderer(String printName, FileInputStream fis, boolean defaultPrinter) {
boolean result = false;
- PDDocument document = null;
try {
+ // Create a PDFFile from a File reference
+ FileChannel fc = fis.getChannel();
+ ByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
+ PDFFile pdfFile = new PDFFile(bb); // Create PDF Print Page
+ PDFPrintPage pages = new PDFPrintPage(pdfFile);
+ // fix fit to page
+ // see http://lynema.org/2010/12/29/printing-a-pdf-in-java-with-pdfrenderer
PrinterJob pjob = PrinterJob.getPrinterJob();
+ PageFormat pf = pjob.defaultPage();
+
+ Paper paper = new Paper();
+ paper.setImageableArea(0, 0, paper.getWidth() * 2, paper.getHeight());
+ pf.setPaper(paper);
+
+ // Create Print Job
pjob.setJobName(printName);
+ Book book = new Book();
+ book.append(pages, pf, pdfFile.getNumPages());
+ pjob.setPageable(book);
- document = PDDocument.load(fis);
- if (defaultPrinter) {
- document.silentPrint(pjob);
- } else {
- document.print(pjob);
+ // Send print job to default printer
+ result = defaultPrinter || pjob.printDialog();
+ if (result) {
+ pjob.print();
}
- result = true;
- } catch (PrinterException | IOException e) {
+ } catch (PrinterException | IOException ex) {
if (log.isErrorEnabled()) {
- log.error("can't print", e);
+ log.error("can't print", ex);
}
+ }
- } finally {
- IOUtils.closeQuietly(document);
- }
return result;
}
Modified: trunk/faxtomail-ui-web/pom.xml
===================================================================
--- trunk/faxtomail-ui-web/pom.xml 2014-10-10 15:19:24 UTC (rev 676)
+++ trunk/faxtomail-ui-web/pom.xml 2014-10-15 13:09:19 UTC (rev 677)
@@ -312,6 +312,7 @@
</dependencies>
<build>
+
<finalName>faxtomail-${project.version}</finalName>
<resources>
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailInterceptor.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailInterceptor.java 2014-10-10 15:19:24 UTC (rev 676)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailInterceptor.java 2014-10-15 13:09:19 UTC (rev 677)
@@ -87,6 +87,7 @@
if (CollectionUtils.isNotEmpty(faxToMailSession.getErrorMessages())) {
for (String message : faxToMailSession.getErrorMessages()) {
+ log.info(message);
faxToMailAction.addActionError(message);
}
faxToMailSession.getErrorMessages().clear();
@@ -204,8 +205,7 @@
FaxToMailApplicationContext extranetEncAhiApplicationContext = getFaxToMailApplicationContext(invocation);
FaxToMailTopiaPersistenceContext persistenceContext = extranetEncAhiApplicationContext.newPersistenceContext();
- FaxToMailServiceContext serviceContext =
- extranetEncAhiApplicationContext.newServiceContext(persistenceContext);
+ FaxToMailServiceContext serviceContext = extranetEncAhiApplicationContext.newServiceContext(persistenceContext);
return serviceContext;
}
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportArchiveAction.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportArchiveAction.java 2014-10-10 15:19:24 UTC (rev 676)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportArchiveAction.java 2014-10-15 13:09:19 UTC (rev 677)
@@ -60,8 +60,6 @@
protected EmailService emailService;
- protected boolean disabledImport;
-
public void setEmailService(EmailService emailService) {
this.emailService = emailService;
}
@@ -74,10 +72,6 @@
this.attachmentBase = attachmentBase;
}
- public boolean isDisabledImport() {
- return disabledImport;
- }
-
@Override
public void prepare() throws Exception {
// check authorization
@@ -89,49 +83,39 @@
@Override
@Action("import-archive-input")
public String input() throws Exception {
- checkDisabled();
return super.input();
}
- protected boolean checkDisabled() {
-
- // pour eviter les erreurs, on considere que si 1000 mails archivés sont présents, il
- // proviennent de la reprise des archives
- if (emailService.getArchivedMailCount() > 1000) {
- disabledImport = true;
- }
- return disabledImport;
- }
-
@Override
public void validate() {
- if (StringUtils.isNotEmpty(attachmentBase) && !new File(attachmentBase).isDirectory()) {
+ if (StringUtils.isNotBlank(attachmentBase) && !new File(attachmentBase).isDirectory()) {
addActionError("Le répertoire de base des pièces jointes n'est pas un répertoire lisible !");
}
if (archiveFile == null) {
addActionError("Le fichier d'archive est obligatoire !");
}
-
- checkDisabled();
}
@Override
@Action(results = {@Result(type = "redirectAction", params = {"actionName", "import-archive-input"})})
public String execute() throws Exception {
String result = INPUT;
-
- if (!checkDisabled()) {
- try (InputStream is = new FileInputStream(archiveFile)) {
- File file = new File(attachmentBase);
- emailService.importArchive(is, file);
- result = SUCCESS;
- } catch (Exception ex) {
- if (log.isErrorEnabled()) {
- log.error("Can't import archive file", ex);
- }
- addActionError("Can't import archive " + ex.getMessage());
+ try (InputStream is = new FileInputStream(archiveFile)) {
+ File file = StringUtils.isNotBlank(attachmentBase) ? new File(attachmentBase) : null;
+ int imported = emailService.importArchive(is, file);
+
+ log.info(imported + " imported elements");
+ addActionMessage(imported + " éléments ont été importés.");
+
+ result = SUCCESS;
+
+ } catch (Exception ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't import archive file", ex);
}
+ addActionError("Erreur lors de l'import : " + ex.getMessage());
}
+
return result;
}
}
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/import-archive-input.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/import-archive-input.jsp 2014-10-10 15:19:24 UTC (rev 676)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/import-archive-input.jsp 2014-10-15 13:09:19 UTC (rev 677)
@@ -36,31 +36,26 @@
<h1 class="page-header">Reprise des archives</h1>
- <s:if test="disabledImport">
- <em>L'import des archives a déjà été effectué, il n'est plus disponible</em>
- </s:if>
- <s:else>
- <s:form id="main_form" action="import-archive" method="post" enctype="multipart/form-data">
-
- <s:actionmessage/>
- <s:actionerror/>
-
- <div class="form-group">
- <label for="archiveFile" class="control-label">Fichier d'archive :</label>
- <input type="file" id="archiveFile" name="archiveFile" class="form-control">
- <p class="help-block">Format du fichier csv : <code>receptionDate;projectReference;sender;fax;recipient;object;archiveDate;companyReference;originalEmail;comment;etatAttente;demandType;priority;mailFolder;client-code;client-brand;attachments</code><br />
- Encodage du fichier csv : <code>${applicationConfig.importFileEncoding}</code></p>
- </div>
- <div class="form-group">
- <label for="attachmentBase" class="control-label">Répertoire de base des pièces jointes :</label>
- <input type="text" id="attachmentBase" name="attachmentBase" class="form-control">
- <p class="help-block">Dossier contenant les pièces jointes référencées dans le fichier d'archive</p>
- </div>
- <button type="submit" class="btn btn-primary navbar-btn">Valider</button>
- <hr />
-
- </s:form>
- </s:else>
+ <s:form id="main_form" action="import-archive" method="post" enctype="multipart/form-data">
+
+ <s:actionmessage/>
+ <s:actionerror/>
+
+ <div class="form-group">
+ <label for="archiveFile" class="control-label">Fichier d'archive :</label>
+ <input type="file" id="archiveFile" name="archiveFile" class="form-control">
+ <p class="help-block">Format du fichier csv : <code>receptionDate;projectReference;sender;fax;recipient;object;archiveDate;companyReference;originalEmail;comment;etatAttente;demandType;priority;mailFolder;client-code;client-brand;attachments</code><br />
+ Encodage du fichier csv : <code>${applicationConfig.importFileEncoding}</code></p>
+ </div>
+ <div class="form-group">
+ <label for="attachmentBase" class="control-label">Répertoire de base des pièces jointes :</label>
+ <input type="text" id="attachmentBase" name="attachmentBase" class="form-control">
+ <p class="help-block">Dossier contenant les pièces jointes référencées dans le fichier d'archive</p>
+ </div>
+ <button type="submit" class="btn btn-primary navbar-btn">Valider</button>
+ <hr />
+
+ </s:form>
</div>
</body>
</html>
1
0
r676 - in trunk: . faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor faxtomail-ui-web faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action faxtomail-ui-web/src/main/webapp/WEB-INF/content
by kmorin@users.forge.codelutin.com 10 Oct '14
by kmorin@users.forge.codelutin.com 10 Oct '14
10 Oct '14
Author: kmorin
Date: 2014-10-10 17:19:24 +0200 (Fri, 10 Oct 2014)
New Revision: 676
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/676
Log:
- refs #5940 Page web de d?\195?\169tail d'un ?\195?\169l?\195?\169ment archiv?\195?\169
Modified:
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIHandler.java
trunk/faxtomail-ui-web/pom.xml
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/DemandDetailAction.java
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp
trunk/pom.xml
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIHandler.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIHandler.java 2014-10-10 09:40:02 UTC (rev 675)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIHandler.java 2014-10-10 15:19:24 UTC (rev 676)
@@ -26,16 +26,12 @@
import static org.nuiton.i18n.I18n.t;
-import java.awt.Component;
-import java.awt.Cursor;
-import java.awt.Dimension;
-import java.awt.Image;
-import java.awt.Insets;
-import java.awt.Rectangle;
+import java.awt.*;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.awt.event.MouseEvent;
import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -53,6 +49,7 @@
import java.util.Date;
import java.util.List;
+import javax.imageio.ImageIO;
import javax.media.jai.PlanarImage;
import javax.swing.JComponent;
import javax.swing.JPanel;
@@ -377,10 +374,10 @@
int width = (int) (zoom * rect.width);
int height = (int) (zoom * rect.height);
Image image = page.getImage(width, height, // width & height
- rect, // clip rect
- null, // null for the ImageObserver
- true, // fill background with white
- true // block until drawing is done
+ rect, // clip rect
+ null, // null for the ImageObserver
+ true, // fill background with white
+ true // block until drawing is done
);
JPanel container = getUI().getContainer();
Modified: trunk/faxtomail-ui-web/pom.xml
===================================================================
--- trunk/faxtomail-ui-web/pom.xml 2014-10-10 09:40:02 UTC (rev 675)
+++ trunk/faxtomail-ui-web/pom.xml 2014-10-10 15:19:24 UTC (rev 676)
@@ -303,6 +303,12 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.jsoup</groupId>
+ <artifactId>jsoup</artifactId>
+ </dependency>
+
</dependencies>
<build>
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/DemandDetailAction.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/DemandDetailAction.java 2014-10-10 09:40:02 UTC (rev 675)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/DemandDetailAction.java 2014-10-10 15:19:24 UTC (rev 676)
@@ -21,6 +21,7 @@
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
@@ -30,6 +31,9 @@
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.InterceptorRefs;
import org.apache.struts2.convention.annotation.Result;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
import org.nuiton.decorator.Decorator;
import org.nuiton.topia.persistence.TopiaNoResultException;
@@ -47,6 +51,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
@@ -76,6 +81,7 @@
protected String id;
protected boolean original;
+ protected int index;
protected Email demand;
@@ -132,6 +138,36 @@
return SUCCESS;
}
+ @Action(value = "reply-attachment-download",
+ results = {@Result(name = "success",
+ type = "stream",
+ params = {
+ "contentType", "${contentType}",
+ "inputName", "attachmentFileInputStream",
+ "contentDisposition", "attachment;filename=\"${fileName}\"",
+ "bufferSize", "1024"
+ })
+ })
+ public String dlReplyAttachment() throws Exception {
+ ReplyContent replyContent = emailService.getReplyContent(id);
+
+ Message message = new MimeMessage(null, new ByteArrayInputStream(replyContent.getSource()));
+ EmailUIModel replyModel = new EmailUIModel();
+ if (message.isMimeType("multipart/*")) {
+ decomposeMultipartEmail(message, replyModel);
+ } else {
+ String content = IOUtils.toString(message.getInputStream());
+ replyModel.setPlainContent(content);
+ }
+
+ AttachmentFile attachmentFile = replyModel.getAttachments().get(index);
+ File file = attachmentFile.getFile();
+ fileName = attachmentFile.getFilename();
+ contentType = Files.probeContentType(file.toPath());
+ attachmentFileInputStream = new FileInputStream(file);
+ return SUCCESS;
+ }
+
public String getId() {
return id;
}
@@ -144,6 +180,10 @@
this.original = original;
}
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
public Email getDemand() {
return demand;
}
@@ -184,6 +224,7 @@
Message message = new MimeMessage(null, new ByteArrayInputStream(replyContent.getSource()));
EmailUIModel replyModel = new EmailUIModel();
+ replyModel.setId(reply.getTopiaId());
replyModel.setSubject(message.getSubject());
String toRecipient = message.getRecipients(MimeMessage.RecipientType.TO)[0].toString();
@@ -357,6 +398,7 @@
public static class EmailUIModel {
+ protected String id;
protected String subject;
protected String sender;
protected String toRecipients;
@@ -365,6 +407,14 @@
protected String content;
protected List<AttachmentFile> attachments = new ArrayList<>();
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
public String getSubject() {
return subject;
}
@@ -412,13 +462,20 @@
}
public void setHtmlContent(String htmlContent) {
- this.content = htmlContent;
+ Document document = Jsoup.parse(htmlContent);
+ Element body = document.body();
+ Element head = document.head();
+ this.content = head.html() + body.outerHtml().replaceAll("<body", "<div").replaceAll("</body>", "</div>");
}
public String getContent() {
return content;
}
+ public List<AttachmentFile> getAttachments() {
+ return attachments;
+ }
+
public void addAttachmentFile(AttachmentFile attachmentFile) {
attachments.add(attachmentFile);
}
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp 2014-10-10 09:40:02 UTC (rev 675)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp 2014-10-10 15:19:24 UTC (rev 676)
@@ -134,7 +134,7 @@
<s:else>
<li><span>
<span class="fa fa-eye float-right" title="Élément courant"></span>
- <span class="margin-right-1-icon"><s:property value="#email.title"/></span>
+ <span class="margin-right-1-icon"><s:property value="demand.title"/></span>
</span></li>
</s:else>
</ul>
@@ -221,7 +221,7 @@
<dt>Sujet</dt>
<dd><s:property value="emailUIModel.subject" /></dd>
<dt>Contenu de l'email reçu</dt>
- <dd><s:property value="emailUIModel.content" escapeHtml="false"/></dd>
+ <dd class="well well-sm"><s:property value="emailUIModel.content" escapeHtml="false"/></dd>
<dt>Message</dt>
<dd><s:text name="%{decorate(demand.comment)}" />
</dl>
@@ -254,15 +254,15 @@
<dt>Sujet</dt>
<dd>{{currentReply.subject}}</dd>
</dl>
- <hr/>
- <p ng-bind-html="currentReply.content"></p>
- <hr/>
- Pièces jointes
- <ul>
- <li ng-repeat="attachment in currentReply.attachments">
- {{attachment.filename}}
- </li>
- </ul>
+ <p class="well" ng-bind-html="currentReply.content"></p>
+ <div>
+ Pièces jointes
+ <ul>
+ <li ng-repeat="attachment in currentReply.attachments">
+ <a href="reply-attachment-download.action?id={{currentReply.id}}&index={{$index}}" title="Ouvrir la pive jointe">{{attachment.filename}}</a>
+ </li>
+ </ul>
+ </div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Fermer</button>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-10-10 09:40:02 UTC (rev 675)
+++ trunk/pom.xml 2014-10-10 15:19:24 UTC (rev 676)
@@ -635,6 +635,13 @@
<artifactId>flying-saucer-pdf-itext5</artifactId>
<version>9.0.6</version>
</dependency>
+
+ <dependency>
+ <groupId>org.jsoup</groupId>
+ <artifactId>jsoup</artifactId>
+ <version>1.8.1</version>
+ </dependency>
+
</dependencies>
</dependencyManagement>
1
0
10 Oct '14
Author: kmorin
Date: 2014-10-10 11:40:02 +0200 (Fri, 10 Oct 2014)
New Revision: 675
Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/675
Log:
- refs #5940 Page web de d?\195?\169tail d'un ?\195?\169l?\195?\169ment archiv?\195?\169
- correction affichage des pdf (pdfbox fonctionne mal avec les polices embarqu?\195?\169es, reprise du code avec pdf-renderer)
Added:
trunk/faxtomail-ui-web/src/main/webapp/css/demand-detail.css
trunk/faxtomail-ui-web/src/main/webapp/js/demand-detail.js
Modified:
trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailImpl.java
trunk/faxtomail-persistence/src/main/xmi/faxtomail.zargo
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java
trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java
trunk/faxtomail-ui-swing/pom.xml
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUI.css
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIHandler.java
trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIModel.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/ArchiveSearchAction.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/DemandDetailAction.java
trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportArchiveAction.java
trunk/faxtomail-ui-web/src/main/resources/i18n/faxtomail-ui-web_fr_FR.properties
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/lock-input.jsp
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/archive-search-input.jsp
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators/layout.jsp
trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/wro.xml
trunk/faxtomail-ui-web/src/main/webapp/js/faxtomail.js
trunk/pom.xml
Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailImpl.java
===================================================================
--- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailImpl.java 2014-10-07 16:13:01 UTC (rev 674)
+++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailImpl.java 2014-10-10 09:40:02 UTC (rev 675)
@@ -26,6 +26,7 @@
import com.google.common.base.Function;
import com.google.common.base.Predicate;
+import com.google.common.base.Strings;
import com.google.common.collect.Collections2;
import org.apache.commons.lang3.StringUtils;
@@ -198,4 +199,14 @@
}
return StringUtils.join(reference, ", ");
}
+
+ @Override
+ public String getTitle() {
+ String result = getObject();
+ String ref = getReference();
+ if (!ref.isEmpty()) {
+ result = ref + " - " + result;
+ }
+ return Strings.nullToEmpty(result);
+ }
}
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-10-07 16:13:01 UTC (rev 674)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailService.java 2014-10-10 09:40:02 UTC (rev 675)
@@ -136,6 +136,7 @@
*
* @param is input stream of csv file
* @param attachmentBase base folder containing attachment listed in csv file
+ * @return the number of imported archives
*/
- void importArchive(InputStream is, File attachmentBase);
+ int importArchive(InputStream is, File attachmentBase);
}
Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java
===================================================================
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java 2014-10-07 16:13:01 UTC (rev 674)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java 2014-10-10 09:40:02 UTC (rev 675)
@@ -1388,13 +1388,7 @@
Map<String, Object> scopes = new HashMap<String, Object>();
- String result = email.getObject();
- String ref = email.getReference();
- if (!ref.isEmpty()) {
- result = ref + " - " + result;
- }
-
- scopes.put("title", result);
+ scopes.put("title", email.getTitle());
scopes.put("receivedDate", DateFormatUtils.format(email.getReceptionDate(), "dd/MM/yyyy HH:mm"));
scopes.put("sender", email.getSender());
scopes.put("object", email.getObject());
@@ -1456,7 +1450,7 @@
}
@Override
- public void importArchive(InputStream inputStream, File attachmentBase) {
+ public int importArchive(InputStream inputStream, File attachmentBase) {
// all doas involved
EmailTopiaDao emailDao = getPersistenceContext().getEmailDao();
@@ -1499,15 +1493,25 @@
ArchiveImportModel archiveImportModel = new ArchiveImportModel(';', allWaitingStates, allDemandTypes, allPriority, mailFolderMap);
Binder<ArchiveImportBean, Email> emailBinder = BinderFactory.newBinder(ArchiveImportBean.class, Email.class);
Import<ArchiveImportBean> importer = null;
+
+ int result = 0;
try {
importer = Import.newImport(archiveImportModel, new InputStreamReader(inputStream, getApplicationConfig().getImportFileEncoding()));
for (ArchiveImportBean archiveBean : importer) {
+ if (archiveBean.getProjectReference() == null) {
+ log.error("null project ref for " + archiveBean.getReceptionDate());
+ }
+ if (archiveBean.getMailFolder() == null) {
+ log.error("null mail folder for " + archiveBean.getReceptionDate());
+ }
// create new email to persist
+ //TODO add modified properties
Email email = emailDao.newInstance();
emailBinder.copy(archiveBean, email);
email.setDemandStatus(DemandStatus.ARCHIVED);
+
// persist it
email = emailDao.create(email);
@@ -1537,6 +1541,7 @@
}
emailDao.update(email);
+ result++;
}
}
@@ -1554,6 +1559,8 @@
IOUtils.closeQuietly(importer);
IOUtils.closeQuietly(inputStream);
}
+
+ return result;
}
@Override
Modified: trunk/faxtomail-ui-swing/pom.xml
===================================================================
--- trunk/faxtomail-ui-swing/pom.xml 2014-10-07 16:13:01 UTC (rev 674)
+++ trunk/faxtomail-ui-swing/pom.xml 2014-10-10 09:40:02 UTC (rev 675)
@@ -231,6 +231,11 @@
</dependency>
<dependency>
+ <groupId>org.swinglabs</groupId>
+ <artifactId>pdf-renderer</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>javax.media.jai</groupId>
<artifactId>com.springsource.javax.media.jai.core</artifactId>
<version>1.1.3</version>
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java 2014-10-07 16:13:01 UTC (rev 674)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java 2014-10-10 09:40:02 UTC (rev 675)
@@ -945,12 +945,7 @@
@Override
public String getTitle() {
- String result = getObject();
- String ref = getReference();
- if (!ref.isEmpty()) {
- result = ref + " - " + result;
- }
- return Strings.nullToEmpty(result);
+ return editObject.getTitle();
}
@Override
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUI.css
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUI.css 2014-10-07 16:13:01 UTC (rev 674)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUI.css 2014-10-10 09:40:02 UTC (rev 675)
@@ -59,14 +59,14 @@
#prevPageButton {
actionIcon: left;
- enabled: { getModel().getCurrentPageIndex() > 0 };
+ enabled: { getModel().getCurrentPageIndex() > 1 };
toolTipText: "faxtomail.pdfEditor.button.previousPage";
}
#pageNumber {
bean: { model };
property: "currentPageIndex";
- modelText: { String.valueOf(model.getCurrentPageIndex() + 1) };
+ modelText: { String.valueOf(model.getCurrentPageIndex()) };
useFloat: false;
useSign: false;
autoPopup: false;
@@ -81,7 +81,7 @@
#nextPageButton {
actionIcon: right;
- enabled: { getModel().getCurrentPageIndex() < getModel().getPages().length - 1 };
+ enabled: { getModel().getCurrentPageIndex() < getModel().getPages().length };
toolTipText: "faxtomail.pdfEditor.button.nextPage";
}
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIHandler.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIHandler.java 2014-10-07 16:13:01 UTC (rev 674)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIHandler.java 2014-10-10 09:40:02 UTC (rev 675)
@@ -26,12 +26,16 @@
import static org.nuiton.i18n.I18n.t;
-import java.awt.*;
+import java.awt.Component;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.Rectangle;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.awt.event.MouseEvent;
import java.awt.geom.Rectangle2D;
-import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -53,6 +57,8 @@
import javax.swing.JComponent;
import javax.swing.JPanel;
+import com.sun.pdfview.PDFFile;
+import com.sun.pdfview.PDFPage;
import jaxx.runtime.swing.ComponentMover;
import jaxx.runtime.swing.ComponentResizer;
import jaxx.runtime.swing.JAXXButtonGroup;
@@ -61,10 +67,6 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.io.RandomAccess;
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.PDPage;
-import org.apache.pdfbox.pdmodel.common.PDRectangle;
import org.nuiton.jaxx.application.swing.util.Cancelable;
import org.nuiton.jaxx.application.swing.util.CloseableUI;
@@ -91,7 +93,7 @@
protected ComponentMover cm = new ComponentMover();
protected ComponentResizer cr = new ComponentResizer();
- protected PDDocument pdf;
+ protected PDFFile pdf;
@Override
public void afterInit(PDFEditorUI pdfEditorUI) {
@@ -192,21 +194,27 @@
}
}
if (FaxToMailUIUtil.isFileAPDF(attachmentFile)) {
+ RandomAccessFile raf = null;
try {
- pdf = PDDocument.load(file);
+ raf = new RandomAccessFile(file, "r");
+ FileChannel channel = raf.getChannel();
+ ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
+ pdf = new PDFFile(buf);
- model.setPageNumber(pdf.getNumberOfPages());
- model.setCurrentPageIndex(0);
-
+ model.setPageNumber(pdf.getNumPages());
+ model.setCurrentPageIndex(1);
+ raf.close();
} catch (IOException e) {
if (log.isErrorEnabled()) {
log.error("", e);
}
getContext().getErrorHelper().showErrorDialog(t("faxtomail.pdfEditor.readPdf.error"));
+ } finally {
+ IOUtils.closeQuietly(raf);
}
}
getUI().setCursor(Cursor.getDefaultCursor());
- model.firePropertyChanged(PDFEditorUIModel.PROPERTY_CURRENT_PAGE_INDEX, null, 0);
+ model.firePropertyChanged(PDFEditorUIModel.PROPERTY_CURRENT_PAGE_INDEX, null, 1);
}
}
}
@@ -343,6 +351,12 @@
for (JPanel panel : p.getCrosses()) {
panel.setVisible(false);
}
+ for (JPanel panel : p.getLines()) {
+ panel.setVisible(false);
+ }
+ for (JPanel panel : p.getHighlighters()) {
+ panel.setVisible(false);
+ }
}
displayPage(pageNb, getModel().getZoom(), getModel().getRotation());
@@ -351,10 +365,9 @@
}
protected void displayPage(int pageNb, float previousZoom, int previousRotation) {
- List<PDPage> pages = pdf.getDocumentCatalog().getAllPages();
- PDPage page = pages.get(pageNb);
+ PDFPage page = pdf.getPage(pageNb);
// create the image
- PDRectangle bBox = page.findCropBox();
+ Rectangle2D bBox = page.getBBox();
Rectangle rect = new Rectangle(0, 0, (int) bBox.getWidth(),
(int) bBox.getHeight());
@@ -363,165 +376,157 @@
int width = (int) (zoom * rect.width);
int height = (int) (zoom * rect.height);
- try {
- Image image = page.convertToImage(BufferedImage.TYPE_INT_RGB, 72);
- // page.getImage(width, height, // width & height
- // rect, // clip rect
- // null, // null for the ImageObserver
- // true, // fill background with white
- // true // block until drawing is done
- // );
+ Image image = page.getImage(width, height, // width & height
+ rect, // clip rect
+ null, // null for the ImageObserver
+ true, // fill background with white
+ true // block until drawing is done
+ );
- JPanel container = getUI().getContainer();
- Dimension containerSize = new Dimension(rotation % 180 == 0 ? width : height,
- rotation % 180 == 0 ? height : width);
- container.setPreferredSize(containerSize);
- container.setMinimumSize(containerSize);
- container.setMaximumSize(containerSize);
- container.setSize(containerSize);
+ JPanel container = getUI().getContainer();
+ Dimension containerSize = new Dimension(rotation % 180 == 0 ? width : height,
+ rotation % 180 == 0 ? height : width);
+ container.setPreferredSize(containerSize);
+ container.setMinimumSize(containerSize);
+ container.setMaximumSize(containerSize);
+ container.setSize(containerSize);
- JImagePanel documentPanel = ui.getDocumentPanel();
- documentPanel.setRotation(rotation);
- documentPanel.setImage(image);
+ JImagePanel documentPanel = ui.getDocumentPanel();
+ documentPanel.setRotation(rotation);
+ documentPanel.setImage(image);
- Insets insets = container.getInsets();
- rect = container.getBounds();
+ Insets insets = container.getInsets();
+ rect = container.getBounds();
- float zoomRatio = zoom / previousZoom;
- int rotationDiff = rotation - previousRotation;
+ float zoomRatio = zoom / previousZoom;
+ int rotationDiff = rotation - previousRotation;
- PDFEditorUIModel.Page p = getModel().getPage(pageNb);
+ PDFEditorUIModel.Page p = getModel().getPage(pageNb);
- for (PDFEditorNoteUI panel : p.getNotes()) {
- panel.setVisible(true);
+ for (PDFEditorNoteUI panel : p.getNotes()) {
+ panel.setVisible(true);
- panel.setZoom(zoom);
- Rectangle bounds = panel.getBounds();
- int x, y;
+ panel.setZoom(zoom);
+ Rectangle bounds = panel.getBounds();
+ int x, y;
- if (rotationDiff == 0) {
- x = bounds.x;
- y = bounds.y;
+ if (rotationDiff == 0) {
+ x = bounds.x;
+ y = bounds.y;
- } else if (rotationDiff == 90 || rotationDiff == -270) {
- x = rect.width - bounds.height / 2 - bounds.width / 2 - bounds.y;
- y = bounds.x + bounds.width / 2 - bounds.height / 2;
+ } else if (rotationDiff == 90 || rotationDiff == -270) {
+ x = rect.width - bounds.height / 2 - bounds.width / 2 - bounds.y;
+ y = bounds.x + bounds.width / 2 - bounds.height / 2;
- } else {
- x = bounds.y + bounds.height / 2 - bounds.width / 2;
- y = rect.height - bounds.height / 2 - bounds.width / 2 - bounds.x;
- }
-
- panel.setBounds((int) (zoomRatio * x) + insets.left,
- (int) (zoomRatio * y) + insets.top,
- (int) (zoomRatio * bounds.width), (int) (zoomRatio * bounds.height));
-
+ } else {
+ x = bounds.y + bounds.height / 2 - bounds.width / 2;
+ y = rect.height - bounds.height / 2 - bounds.width / 2 - bounds.x;
}
- boolean orientation180 = Math.abs(rotationDiff) % 180 == 0;
+ panel.setBounds((int)(zoomRatio * x) + insets.left,
+ (int)(zoomRatio * y) + insets.top,
+ (int)(zoomRatio * bounds.width), (int)(zoomRatio * bounds.height));
- for (PDFEditorCrossUI panel : p.getCrosses()) {
- panel.setVisible(true);
+ }
- Rectangle bounds = panel.getBounds();
+ boolean orientation180 = Math.abs(rotationDiff) % 180 == 0;
- int newWidth = orientation180 ? bounds.width : bounds.height;
- int newHeight = orientation180 ? bounds.height : bounds.width;
+ for (PDFEditorCrossUI panel : p.getCrosses()) {
+ panel.setVisible(true);
- int x, y;
+ Rectangle bounds = panel.getBounds();
- if (rotationDiff == 0) {
- x = bounds.x;
- y = bounds.y;
+ int newWidth = orientation180 ? bounds.width : bounds.height;
+ int newHeight = orientation180 ? bounds.height : bounds.width;
- } else if (rotationDiff == 90 || rotationDiff == -270) {
- x = rect.width - newWidth - bounds.y;
- y = bounds.x;
+ int x, y;
- } else {
- x = bounds.y;
- y = rect.height - newHeight - bounds.x;
- }
+ if (rotationDiff == 0) {
+ x = bounds.x;
+ y = bounds.y;
- panel.setBounds((int) (zoomRatio * x) + insets.left,
- (int) (zoomRatio * y) + insets.top,
- (int) (zoomRatio * newWidth), (int) (zoomRatio * newHeight));
+ } else if (rotationDiff == 90 || rotationDiff == -270) {
+ x = rect.width - newWidth - bounds.y;
+ y = bounds.x;
+ } else {
+ x = bounds.y;
+ y = rect.height - newHeight - bounds.x;
}
- List<PDFEditorLineUI> lines = p.getLines();
- cr.deregisterComponent(lines.toArray(new PDFEditorLineUI[lines.size()]));
+ panel.setBounds((int) (zoomRatio * x) + insets.left,
+ (int) (zoomRatio * y) + insets.top,
+ (int) (zoomRatio * newWidth), (int) (zoomRatio * newHeight));
- for (PDFEditorLineUI panel : lines) {
- panel.setVisible(true);
+ }
- Rectangle bounds = panel.getBounds();
+ List<PDFEditorLineUI> lines = p.getLines();
+ cr.deregisterComponent(lines.toArray(new PDFEditorLineUI[lines.size()]));
- boolean horizontal = panel.isHorizontal();
- panel.setHorizontal(orientation180 ? horizontal : !horizontal);
+ for (PDFEditorLineUI panel : lines) {
+ panel.setVisible(true);
- int newWidth = orientation180 ? bounds.width : bounds.height;
- int newHeight = orientation180 ? bounds.height : bounds.width;
+ Rectangle bounds = panel.getBounds();
- int x, y;
+ boolean horizontal = panel.isHorizontal();
+ panel.setHorizontal(orientation180 ? horizontal : ! horizontal);
- if (rotationDiff == 0) {
- x = bounds.x;
- y = bounds.y;
+ int newWidth = orientation180 ? bounds.width : bounds.height;
+ int newHeight = orientation180 ? bounds.height : bounds.width;
- } else if (rotationDiff == 90 || rotationDiff == -270) {
- x = rect.width - newWidth - bounds.y;
- y = bounds.x;
+ int x, y;
- } else {
- x = bounds.y;
- y = rect.height - newHeight - bounds.x;
- }
+ if (rotationDiff == 0) {
+ x = bounds.x;
+ y = bounds.y;
- panel.setBounds((int) (zoomRatio * x) + insets.left,
- (int) (zoomRatio * y) + insets.top,
- (int) (zoomRatio * newWidth), (int) (zoomRatio * newHeight));
+ } else if (rotationDiff == 90 || rotationDiff == -270) {
+ x = rect.width - newWidth - bounds.y;
+ y = bounds.x;
- cr.registerComponent(panel.isHorizontal() ? ComponentResizer.DIRECTION_HORIZONTAL : ComponentResizer.DIRECTION_VERTICAL,
- panel);
+ } else {
+ x = bounds.y;
+ y = rect.height - newHeight - bounds.x;
}
- for (PDFEditorHighlighterUI panel : p.getHighlighters()) {
- panel.setVisible(true);
+ panel.setBounds((int) (zoomRatio * x) + insets.left,
+ (int) (zoomRatio * y) + insets.top,
+ (int) (zoomRatio * newWidth), (int) (zoomRatio * newHeight));
- Rectangle bounds = panel.getBounds();
+ cr.registerComponent(panel.isHorizontal() ? ComponentResizer.DIRECTION_HORIZONTAL : ComponentResizer.DIRECTION_VERTICAL,
+ panel);
+ }
- int newWidth = orientation180 ? bounds.width : bounds.height;
- int newHeight = orientation180 ? bounds.height : bounds.width;
+ for (PDFEditorHighlighterUI panel : p.getHighlighters()) {
+ panel.setVisible(true);
- int x, y;
+ Rectangle bounds = panel.getBounds();
- if (rotationDiff == 0) {
- x = bounds.x;
- y = bounds.y;
+ int newWidth = orientation180 ? bounds.width : bounds.height;
+ int newHeight = orientation180 ? bounds.height : bounds.width;
- } else if (rotationDiff == 90 || rotationDiff == -270) {
- x = rect.width - newWidth - bounds.y;
- y = bounds.x;
+ int x, y;
- } else {
- x = bounds.y;
- y = rect.height - newHeight - bounds.x;
- }
+ if (rotationDiff == 0) {
+ x = bounds.x;
+ y = bounds.y;
- panel.setBounds((int) (zoomRatio * x) + insets.left,
- (int) (zoomRatio * y) + insets.top,
- (int) (zoomRatio * newWidth), (int) (zoomRatio * newHeight));
+ } else if (rotationDiff == 90 || rotationDiff == -270) {
+ x = rect.width - newWidth - bounds.y;
+ y = bounds.x;
+ } else {
+ x = bounds.y;
+ y = rect.height - newHeight - bounds.x;
}
- container.updateUI();
+ panel.setBounds((int) (zoomRatio * x) + insets.left,
+ (int) (zoomRatio * y) + insets.top,
+ (int) (zoomRatio * newWidth), (int) (zoomRatio * newHeight));
- } catch (IOException e) {
- if (log.isErrorEnabled()) {
- log.error("Cannot convert page into image", e);
- }
}
+
+ container.updateUI();
}
public File convertFileToPdf(AttachmentFile attachmentFile) throws IOException, DocumentException {
Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIModel.java
===================================================================
--- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIModel.java 2014-10-07 16:13:01 UTC (rev 674)
+++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/pdfeditor/PDFEditorUIModel.java 2014-10-10 09:40:02 UTC (rev 675)
@@ -124,6 +124,7 @@
protected Page[] pages;
+ // first page is 1 not 0
protected int currentPageIndex = -1;
protected float zoom = 1.0f;
@@ -193,17 +194,17 @@
}
public Page getCurrentPage() {
- if (pages == null || currentPageIndex < 0 || currentPageIndex >= pages.length) {
+ if (pages == null || currentPageIndex < 1 || currentPageIndex > pages.length) {
return null;
}
- return pages[currentPageIndex];
+ return pages[currentPageIndex - 1];
}
public Page getPage(int i) {
- if (pages == null || i < 0 || i >= pages.length) {
+ if (pages == null || i < 1 || i > pages.length) {
return null;
}
- return pages[i];
+ return pages[i - 1];
}
public int getCurrentPageIndex() {
@@ -212,9 +213,9 @@
public void setCurrentPageIndex(int currentPageIndex) {
Object oldValue = getCurrentPageIndex();
- currentPageIndex = Math.max(0, currentPageIndex);
+ currentPageIndex = Math.max(1, currentPageIndex);
if (pages != null) {
- currentPageIndex = Math.min(pages.length - 1, currentPageIndex);
+ currentPageIndex = Math.min(pages.length, currentPageIndex);
}
this.currentPageIndex = currentPageIndex;
firePropertyChange(PROPERTY_CURRENT_PAGE_INDEX, oldValue, currentPageIndex);
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/ArchiveSearchAction.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/ArchiveSearchAction.java 2014-10-07 16:13:01 UTC (rev 674)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/ArchiveSearchAction.java 2014-10-10 09:40:02 UTC (rev 675)
@@ -77,12 +77,14 @@
@Override
@Action("archive-search")
public String execute() throws Exception {
- results = new ArrayList<>(emailService.searchArchives(commandQuotationNb, company));
- List<MailField> mailFields = configurationService.getSearchDisplayColumns();
- if (CollectionUtils.isEmpty(mailFields)) {
- mailFields = Lists.newArrayList(MailField.getTableFields());
+ if (commandQuotationNb != null && company != null) {
+ results = new ArrayList<>(emailService.searchArchives(commandQuotationNb, company));
+ List<MailField> mailFields = configurationService.getSearchDisplayColumns();
+ if (CollectionUtils.isEmpty(mailFields)) {
+ mailFields = Lists.newArrayList(MailField.getTableFields());
+ }
+ tableMailFields = getEnumAsMap(mailFields.toArray(new MailField[mailFields.size()]));
}
- tableMailFields = getEnumAsMap(mailFields.toArray(new MailField[mailFields.size()]));
return INPUT;
}
@@ -201,19 +203,19 @@
attrValue = email.getLastAttachmentOpener();
break;
case REPLIES:
- attrValue = "<i class='fa fa-envelope-o'></i> " + email.sizeReplies();
+ attrValue = "<span class='fa fa-envelope-o'></span> " + email.sizeReplies();
break;
case ATTACHMENT:
- attrValue = "<i class='fa fa-paperclip'></i> " + email.sizeAttachment();
+ attrValue = "<span class='fa fa-paperclip'></span> " + email.sizeAttachment();
break;
case GROUP:
EmailGroup emailGroup = email.getEmailGroup();
- attrValue = "<i class='fa fa-link'></i> " + (emailGroup == null ? 1 : emailGroup.sizeEmail());
+ attrValue = "<span class='fa fa-link'></span> " + (emailGroup == null ? 1 : emailGroup.sizeEmail());
break;
}
String result;
- if (attrValue == null) {
+ if (attrValue == null || StringUtils.isBlank(attrValue.toString())) {
result = " ";
} else {
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/DemandDetailAction.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/DemandDetailAction.java 2014-10-07 16:13:01 UTC (rev 674)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/DemandDetailAction.java 2014-10-10 09:40:02 UTC (rev 675)
@@ -1,13 +1,19 @@
package com.franciaflex.faxtomail.web.action;
import com.franciaflex.faxtomail.persistence.entities.Attachment;
+import com.franciaflex.faxtomail.persistence.entities.AttachmentFile;
+import com.franciaflex.faxtomail.persistence.entities.AttachmentFileImpl;
+import com.franciaflex.faxtomail.persistence.entities.AttachmentImpl;
import com.franciaflex.faxtomail.persistence.entities.Client;
import com.franciaflex.faxtomail.persistence.entities.Email;
import com.franciaflex.faxtomail.persistence.entities.EmailGroup;
+import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser;
import com.franciaflex.faxtomail.persistence.entities.MailField;
import com.franciaflex.faxtomail.persistence.entities.RangeRow;
import com.franciaflex.faxtomail.persistence.entities.Reply;
+import com.franciaflex.faxtomail.persistence.entities.ReplyContent;
import com.franciaflex.faxtomail.services.DecoratorService;
+import com.franciaflex.faxtomail.services.FaxToMailServiceUtils;
import com.franciaflex.faxtomail.services.service.ConfigurationService;
import com.franciaflex.faxtomail.services.service.EmailService;
import com.franciaflex.faxtomail.web.FaxToMailActionSupport;
@@ -15,19 +21,43 @@
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
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 org.nuiton.decorator.Decorator;
+import org.nuiton.topia.persistence.TopiaNoResultException;
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.mail.Address;
+import javax.mail.BodyPart;
+import javax.mail.Message;
+import javax.mail.Part;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+import java.awt.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
+import static org.nuiton.i18n.I18n.t;
+
/**
* @author Kevin Morin (Code Lutin)
* @since 1.1
@@ -45,8 +75,20 @@
protected DecoratorService decoratorService;
protected String id;
+ protected boolean original;
+
protected Email demand;
+ protected int quotationTotal;
+ protected int productTotal;
+ protected int savTotal;
+
+ protected EmailUIModel emailUIModel;
+
+ protected InputStream attachmentFileInputStream;
+ protected String fileName;
+ protected String contentType;
+
public void setEmailService(EmailService emailService) {
this.emailService = emailService;
}
@@ -58,7 +100,35 @@
@Override
@Action("demand-detail")
public String execute() throws Exception {
- demand = emailService.getEmailById(id);
+ String result = SUCCESS;
+ try {
+ demand = emailService.getEmailById(id);
+ computeTotals();
+ decomposeEmail();
+
+ } catch (TopiaNoResultException e) {
+ result = ERROR;
+ addActionError(t("faxtomail.demandDetail.noDemandForId", id));
+ }
+ return result;
+ }
+
+ @Action(value = "attachment-download",
+ results = {@Result(name = "success",
+ type = "stream",
+ params = {
+ "contentType", "${contentType}",
+ "inputName", "attachmentFileInputStream",
+ "contentDisposition", "attachment;filename=\"${fileName}\"",
+ "bufferSize", "1024"
+ })
+ })
+ public String dlAttachment() throws Exception {
+ AttachmentFile attachmentFile = emailService.getAttachmentFile(id, original);
+ File file = attachmentFile.getFile();
+ fileName = attachmentFile.getFilename();
+ contentType = Files.probeContentType(file.toPath());
+ attachmentFileInputStream = new FileInputStream(file);
return SUCCESS;
}
@@ -70,7 +140,287 @@
this.id = id;
}
+ public void setOriginal(boolean original) {
+ this.original = original;
+ }
+
public Email getDemand() {
return demand;
}
-}
+
+ public int getQuotationTotal() {
+ return quotationTotal;
+ }
+
+ public int getProductTotal() {
+ return productTotal;
+ }
+
+ public int getSavTotal() {
+ return savTotal;
+ }
+
+ public EmailUIModel getEmailUIModel() {
+ return emailUIModel;
+ }
+
+ public InputStream getAttachmentFileInputStream() {
+ return attachmentFileInputStream;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public String getContentType() {
+ return contentType;
+ }
+
+ public List<EmailUIModel> getReplies() throws Exception {
+ List<EmailUIModel> result = new ArrayList<>();
+
+ for (Reply reply : demand.getReplies()) {
+ ReplyContent replyContent = reply.getReplyContent();
+ Message message = new MimeMessage(null, new ByteArrayInputStream(replyContent.getSource()));
+
+ EmailUIModel replyModel = new EmailUIModel();
+ replyModel.setSubject(message.getSubject());
+
+ String toRecipient = message.getRecipients(MimeMessage.RecipientType.TO)[0].toString();
+ replyModel.setToRecipients(Lists.newArrayList(toRecipient));
+
+ replyModel.setSender(message.getFrom()[0].toString());
+
+ if (ArrayUtils.isNotEmpty(message.getRecipients(MimeMessage.RecipientType.CC))) {
+ String ccRecipient = message.getRecipients(MimeMessage.RecipientType.CC)[0].toString();
+ replyModel.setCcRecipients(Lists.newArrayList(ccRecipient));
+ }
+ if (ArrayUtils.isNotEmpty(message.getRecipients(MimeMessage.RecipientType.BCC))) {
+ String bccRecipient = message.getRecipients(MimeMessage.RecipientType.BCC)[0].toString();
+ replyModel.setBccRecipients(Lists.newArrayList(bccRecipient));
+ }
+
+ if (message.isMimeType("multipart/*")) {
+ decomposeMultipartEmail(message, replyModel);
+
+ } else {
+ String content = IOUtils.toString(message.getInputStream());
+ replyModel.setPlainContent(content);
+ }
+ result.add(replyModel);
+ }
+
+ return result;
+ }
+
+ public String decorate(Object o) {
+ return decorate(o, " ");
+ }
+
+ public String decorateUser(FaxToMailUser user) {
+ return decorate(user, t("faxtomail.systemUser"));
+ }
+
+ protected String decorate(Object o, String defaultValue) {
+ String result = null;
+ if (o != null) {
+ Decorator decorator = decoratorService.getDecoratorByType(o.getClass());
+ if (decorator != null) {
+ result = decorator.toString(o);
+ } else {
+ result = o.toString();
+ }
+ }
+ if (StringUtils.isBlank(result)) {
+ result = defaultValue;
+ } else {
+ result = result.replaceAll("(\r\n|\n)", "<br />");
+ }
+ return result;
+ }
+
+ protected void computeTotals() {
+ quotationTotal = 0;
+ productTotal = 0;
+ savTotal = 0;
+
+ if (demand != null && demand.getRangeRow() != null) {
+ for (RangeRow row : demand.getRangeRow()) {
+ if (row.getQuotationQuantity() != null) {
+ quotationTotal += row.getQuotationQuantity();
+ }
+ if (row.getProductQuantity() != null) {
+ productTotal += row.getProductQuantity();
+ }
+ if (row.getSavQuantity() != null) {
+ savTotal += row.getSavQuantity();
+ }
+ }
+ }
+ }
+
+ protected void decomposeEmail() {
+ emailUIModel = new EmailUIModel();
+ try {
+ // ce code peut provoquer une NPE avec les données de test
+ Message message = new MimeMessage(null, new ByteArrayInputStream(demand.getOriginalEmail().getBytes(StandardCharsets.UTF_8)));
+ emailUIModel.setSubject(message.getSubject());
+
+ List<String> toRecipients = new ArrayList<>();
+ List<String> ccRecipients = new ArrayList<>();
+ Address[] recipients = message.getRecipients(Message.RecipientType.TO);
+ if (recipients != null) {
+ for (Address address : recipients) {
+ toRecipients.add(address.toString());
+ }
+ }
+ emailUIModel.setToRecipients(toRecipients);
+
+ recipients = message.getRecipients(Message.RecipientType.CC);
+ if (recipients != null) {
+ for (Address address : recipients) {
+ ccRecipients.add(address.toString());
+ }
+ }
+ emailUIModel.setCcRecipients(ccRecipients);
+
+ if (message.isMimeType("multipart/*")) {
+ decomposeMultipartEmail(message, emailUIModel);
+
+ } else {
+ String content = IOUtils.toString(message.getInputStream());
+ emailUIModel.setPlainContent(content);
+ }
+
+ } catch (Exception e) {
+ //TODO kmorin 20140516 do something when we use the real data
+ if (log.isErrorEnabled()) {
+ log.error("", e);
+ }
+ }
+ }
+
+ /**
+ * Decompose a multipart part.
+ * - sets the email content if the part contains a text bodypart
+ * - adds attachments to the email
+ *
+ * @param part the part to decompose
+ * @throws Exception
+ */
+ protected void decomposeMultipartEmail(Part part, EmailUIModel emailUIModel) throws Exception {
+ DataSource dataSource = part.getDataHandler().getDataSource();
+ MimeMultipart mimeMultipart = new MimeMultipart(dataSource);
+ int multiPartCount = mimeMultipart.getCount();
+
+ for (int j = 0; j < multiPartCount; j++) {
+ BodyPart bp = mimeMultipart.getBodyPart(j);
+
+ // if it is a text part, the,n this is the email content
+ String disposition = bp.getDisposition();
+ if (bp.isMimeType("text/*") && !Part.ATTACHMENT.equals(disposition)) {
+ Charset charset = FaxToMailServiceUtils.getCharset(bp);
+ String content = IOUtils.toString(bp.getInputStream(), charset);
+ if (bp.isMimeType("text/plain")) {
+ emailUIModel.setPlainContent(content);
+ } else {
+ emailUIModel.setHtmlContent(content);
+ }
+
+ // if it is multipart part, decompose it
+ } else if (bp.isMimeType("multipart/*")) {
+ decomposeMultipartEmail(bp, emailUIModel);
+
+ // else, this is an attachment
+ } else {
+ String fileName = bp.getFileName();
+ if (fileName == null) {
+ fileName = bp.getHeader("Content-ID")[0];
+ // remove the guillemets between the id
+ fileName = fileName.replaceFirst("^<(.*)>$", "$1");
+ }
+
+ ByteArrayOutputStream fos = new ByteArrayOutputStream();
+
+ DataHandler dh = bp.getDataHandler();
+ dh.writeTo(fos);
+
+ // copy content into an empty attachment
+ AttachmentFile attachmentFile = new AttachmentFileImpl();
+ attachmentFile.setContent(fos.toByteArray());
+ attachmentFile.setFilename(fileName);
+
+ emailUIModel.addAttachmentFile(attachmentFile);
+ }
+ }
+ }
+
+ public static class EmailUIModel {
+
+ protected String subject;
+ protected String sender;
+ protected String toRecipients;
+ protected String ccRecipients;
+ protected String bccRecipients;
+ protected String content;
+ protected List<AttachmentFile> attachments = new ArrayList<>();
+
+ public String getSubject() {
+ return subject;
+ }
+
+ public void setSubject(String subject) {
+ this.subject = subject;
+ }
+
+ public String getSender() {
+ return sender;
+ }
+
+ public void setSender(String sender) {
+ this.sender = sender;
+ }
+
+ public String getToRecipients() {
+ return toRecipients;
+ }
+
+ public void setToRecipients(List<String> toRecipients) {
+ this.toRecipients = StringUtils.join(toRecipients, ", ");
+ }
+
+ public String getCcRecipients() {
+ return ccRecipients;
+ }
+
+ public void setCcRecipients(List<String> ccRecipients) {
+ this.ccRecipients = StringUtils.join(ccRecipients, ", ");
+ }
+
+ public String getBccRecipients() {
+ return bccRecipients;
+ }
+
+ public void setBccRecipients(List<String> bccRecipients) {
+ this.bccRecipients = StringUtils.join(bccRecipients, ", ");
+ }
+
+ public void setPlainContent(String plainContent) {
+ if (content == null) {
+ this.content = plainContent == null ? null : plainContent.replaceAll("(\r\n|\n)", "<br />");
+ }
+ }
+
+ public void setHtmlContent(String htmlContent) {
+ this.content = htmlContent;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public void addAttachmentFile(AttachmentFile attachmentFile) {
+ attachments.add(attachmentFile);
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportArchiveAction.java
===================================================================
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportArchiveAction.java 2014-10-07 16:13:01 UTC (rev 674)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportArchiveAction.java 2014-10-10 09:40:02 UTC (rev 675)
@@ -115,8 +115,8 @@
checkDisabled();
}
+ @Override
@Action(results = {@Result(type = "redirectAction", params = {"actionName", "import-archive-input"})})
- @Override
public String execute() throws Exception {
String result = INPUT;
Modified: trunk/faxtomail-ui-web/src/main/resources/i18n/faxtomail-ui-web_fr_FR.properties
===================================================================
--- trunk/faxtomail-ui-web/src/main/resources/i18n/faxtomail-ui-web_fr_FR.properties 2014-10-07 16:13:01 UTC (rev 674)
+++ trunk/faxtomail-ui-web/src/main/resources/i18n/faxtomail-ui-web_fr_FR.properties 2014-10-10 09:40:02 UTC (rev 675)
@@ -35,8 +35,13 @@
com.franciaflex.faxtomail.persistence.entities.MailField.SENDER=Émetteur
com.franciaflex.faxtomail.persistence.entities.MailField.TAKEN_BY=Pris par
com.franciaflex.faxtomail.persistence.entities.MailField.WAITING_STATE=État d'attente
+faxtomail.demandDetail.noAttachmentForId=Aucune pièce jointe ne correspond à l'identifiant %s.
+faxtomail.demandDetail.noDemandForId=Aucun élément ne correspond à l'identifiant %s.
faxtomail.email.content.attachment.htmlfileName=contenu html du mail
faxtomail.email.content.attachment.plainfileName=contenu texte du mail
faxtomail.email.object.noClient=Client non trouvé
faxtomail.email.projectReference.default=Votre demande du %s
faxtomail.email.subject.re=Re \: %s
+faxtomail.reply.forwardsubject=
+faxtomail.reply.message=
+faxtomail.systemUser=Système
Modified: 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 2014-10-07 16:13:01 UTC (rev 674)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/lock-input.jsp 2014-10-10 09:40:02 UTC (rev 675)
@@ -54,7 +54,7 @@
<tr>
<td><input type="checkbox" name="mailLockIds" value="<s:property value="topiaId" />" />
<td><s:property value="lockOn.object" /></td>
- <td><s:property value="lockOn.companyReference" /></td>
+ <td><s:property value="lockOn.reference" /></td>
<td><s:property value="lockOn.sender" /></td>
<td>
<s:property value="lockBy.firstName" /> <s:property value="lockBy.lastName" />
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/archive-search-input.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/archive-search-input.jsp 2014-10-07 16:13:01 UTC (rev 674)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/archive-search-input.jsp 2014-10-10 09:40:02 UTC (rev 675)
@@ -28,7 +28,7 @@
<s:if test="results != null">
- <div style="overflow-x: scroll; margin-top: 20px">
+ <div style="overflow-x: auto; margin-top: 20px">
<s:if test="results.isEmpty()">
<em>Aucun résultat pour cette recherche.</em>
@@ -50,7 +50,7 @@
<s:url id="detailUrlId" value="demand-detail.action">
<s:param name="id" value="%{topiaId}" />
</s:url>
- <s:a href="%{detailUrlId}"><i class="fa fa-eye"></i></s:a>
+ <s:a href="%{detailUrlId}"><span class="fa fa-eye"></span></s:a>
</td>
<s:iterator value="tableMailFields">
<td class="cut-eol" title="<s:text name="%{getTooltip(key, #result)}"/>"><s:text name="%{getAttr(key, #result)}"/></td>
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp 2014-10-07 16:13:01 UTC (rev 674)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/demand-detail.jsp 2014-10-10 09:40:02 UTC (rev 675)
@@ -4,16 +4,273 @@
<html>
<head>
- <title>Détail de l'élément</title>
+ <title>Détail de l'élément <s:property value="demand.title"/></title>
+ <link rel="stylesheet" type="text/css" href="<s:url value='/nuiton-js/faxtomail-detail-demand.css' />" />
+ <script type="text/javascript" src="<s:url value='/nuiton-js/faxtomail-detail-demand.js' />"></script>
+ <script type="text/javascript">
+ DemandDetailModule.value('DemandDetailData', {
+ 'replies': <s:property value="toJson(replies)" escapeHtml="false"/>
+ });
+ </script>
</head>
<body>
- <div id="main-container" class="container">
+ <div id="main-container" class="container" ng-app="DemandDetailModule" ng-controller="DemandDetailController">
+ <s:if test="demand != null">
+ <!-- groupe | réponses | historique | pj -->
+ <nav class="navbar navbar-default" role="navigation">
+ <div class="container-fluid">
+ <div class="navbar-header">
+ <span class="navbar-brand"><s:property value="demand.title"/></span>
+ </div>
+ <ul class="nav navbar-nav navbar-right">
- <h1 class="page-header">Détail de l'élément <s:property value="demand.object"/></h1>
+ <!-- replies -->
+ <li class="dropdown">
+ <a href="#" class="dropdown-toggle" title="Réponses envoyées depuis l'application">
+ <span class="fa fa-envelope-o"></span> (<s:property value="demand.sizeReplies()"/>)
+ <s:if test="demand.sizeReplies() > 0">
+ <span class="caret"></span>
+ </s:if>
+ </a>
+ <s:if test="demand.sizeReplies() > 0">
+ <ul class="dropdown-menu" role="menu">
+ <s:iterator value="demand.replies" var="reply" status="status">
+ <li><span>
+ <a ng-click='showReplyModal(<s:property value="#status.index"/>)'
+ class="fa fa-eye float-right" title="Voir la réponse"></a>
+ <span class="margin-right-1-icon"><s:text name="%{decorate(#reply)}" /></span>
+ </span></li>
+ </s:iterator>
+ </ul>
+ </s:if>
+ </li>
+ <!-- history -->
+ <li class="dropdown">
+ <a href="#" class="dropdown-toggle" title="Historique de l'élément">
+ <span class="fa fa-calendar-o"></span> (<s:property value="demand.sizeHistory()"/>)
+ <s:if test="demand.sizeHistory() > 0">
+ <span class="caret"></span>
+ </s:if>
+ </a>
+ <s:if test="demand.sizeHistory() > 0">
+ <ul class="dropdown-menu" role="menu">
+ <s:iterator value="demand.history" var="history">
+ <li><span>
+ <div>
+ le <s:text name="%{decorate(#history.modificationDate)}"/>
+ <s:text name="%{decorate(#history.type)}"/>
+ par <s:text name="%{decorateUser(#history.faxToMailUser)}"/>
+ </div>
+ </span></li>
+ </s:iterator>
+ </ul>
+ </s:if>
+ </li>
+ <!-- attachments -->
+ <li class="dropdown">
+ <a href="#" class="dropdown-toggle" title="Pièces jointes de l'élément">
+ <span class="fa fa-paperclip"></span> (<s:property value="demand.sizeAttachment()"/>)
+ <s:if test="demand.sizeAttachment() > 0">
+ <span class="caret"></span>
+ </s:if>
+ </a>
+ <s:if test="demand.sizeAttachment() > 0">
+ <ul class="dropdown-menu" role="menu">
+ <s:iterator value="demand.attachment" var="attachment">
+ <li><span>
+ <s:if test="#attachment.editedFileName != null">
+ <!-- edited attachment -->
+ <s:url id="editedAttachmentUrlId" value="attachment-download.action">
+ <s:param name="id" value="%{#attachment.topiaId}" />
+ <s:param name="original" value="false" />
+ </s:url>
+ <s:a href="%{editedAttachmentUrlId}" cssClass="fa fa-pencil float-right" title="Ouvrir la version éditée"></s:a>
+ </s:if>
+ <s:else>
+ <span class="fa fa-pencil float-right" title="Pas de version éditée"></span>
+ </s:else>
+ <!-- original attachment -->
+ <s:url id="originalAttachmentUrlId" value="attachment-download.action">
+ <s:param name="id" value="%{#attachment.topiaId}" />
+ <s:param name="original" value="true" />
+ </s:url>
+ <s:a href="%{originalAttachmentUrlId}" cssClass="fa fa-folder-open-o float-right margin-right-10" title="Ouvrir la version originale"></s:a>
+
+ <span class="margin-right-2-icons"><s:text name="%{decorate(#attachment)}" /></span>
+ </span></li>
+ </s:iterator>
+ </ul>
+ </s:if>
+ </li>
+
+ <!-- group -->
+ <li class="dropdown">
+ <a href="#" class="dropdown-toggle" title="Éléments groupés">
+ <span class="fa fa-link"></span> (<s:property value="demand.emailGroup != null ? demand.emailGroup.sizeEmail() : 1"/>) <span class="caret"></span>
+ </a>
+ <ul class="dropdown-menu" role="menu">
+ <s:if test="demand.emailGroup != null">
+ <s:iterator value="demand.emailGroup.email" var="email">
+ <li><span>
+ <s:if test="demand.equals(#email)">
+ <span class="fa fa-eye float-right" title="Élément courant"></span>
+ <span class="margin-right-1-icon"><s:property value="#email.title"/></span>
+ </s:if>
+ <s:else>
+ <s:url id="detailUrlId" value="demand-detail.action">
+ <s:param name="id" value="%{#email.topiaId}" />
+ </s:url>
+ <s:a href="%{detailUrlId}" cssClass="fa fa-eye float-right" title="Ouvrir l'élément groupé"></s:a>
+ <span class="margin-right-1-icon"><s:property value="#email.title"/></span>
+ </s:else>
+ </span></li>
+ </s:iterator>
+ </s:if>
+ <s:else>
+ <li><span>
+ <span class="fa fa-eye float-right" title="Élément courant"></span>
+ <span class="margin-right-1-icon"><s:property value="#email.title"/></span>
+ </span></li>
+ </s:else>
+ </ul>
+ </li>
+ </ul>
+ </div><!-- /.container-fluid -->
+ </nav>
+
+ <dl class="dl-horizontal large-dl">
+ <dt>Reçu le</dt>
+ <dd><s:property value="demand.receptionDate" /></dd>
+ <dt>Émetteur</dt>
+ <dd><s:property value="demand.sender" /></dd>
+ <dt>Objet</dt>
+ <dd><s:property value="demand.object" /></dd>
+ <dt>Client (marque)</dt>
+ <dd><s:if test="demand.client != null"><s:property value="demand.client.code" /> (<s:property value="demand.client.brand" />)</s:if></dd>
+ <dt>Type</dt>
+ <dd><s:text name="%{decorate(demand.demandType)}" /></dd>
+ <dt>Priorité</dt>
+ <dd><s:text name="%{decorate(demand.priority)}" /></dd>
+ <dt>Référence chantier</dt>
+ <dd><s:property value="demand.projectReference" /></dd>
+ <dt>Notre référence</dt>
+ <dd><s:property value="demand.companyReference" /></dd>
+ <dt>État d'attente</dt>
+ <dd><s:text name="%{decorate(demand.waitingState)}" /></dd>
+ </dl>
+
+ <dl class="dl-horizontal large-dl">
+ <s:if test="demand.firstOpeningDate != null">
+ <dt>Première ouverture</dt>
+ <dd>par <s:text name="%{decorateUser(demand.firstOpeningUser)}" /> le <s:text name="%{decorate(demand.firstOpeningDate)}" /></dd>
+ </s:if>
+ <s:if test="demand.lastModificationDate != null">
+ <dt>Dernière modification</dt>
+ <dd>par <s:text name="%{decorateUser(demand.lastModificationUser)}" /> le <s:text name="%{decorate(demand.lastModificationDate)}" /></dd>
+ </s:if>
+ <s:if test="demand.lastAttachmentOpeningInFolderDate != null">
+ <dt>Dernière ouverture de pièce jointe</dt>
+ <dd>par <s:text name="%{decorateUser(demand.lastAttachmentOpeningInFolderUser)}" /> le <s:text name="%{decorate(demand.lastAttachmentOpeningInFolderDate)}" /></dd>
+ </s:if>
+ </dl>
+
+ <s:if test="demand.sizeRangeRow() > 0">
+ <table class="table table-bordered">
+ <thead>
+ <tr>
+ <th title="Gamme">Gamme</th>
+ <th title="N° commande / devis">N° commande / devis</th>
+ <th title="Quantité de devis">Qté devis</th>
+ <th title="Quantité de produits">Qté produits</th>
+ <th title="Quantité de SAV">Qté SAV</th>
+ </tr>
+ </thead>
+ <tbody>
+ <s:iterator value="demand.rangeRow" var="row">
+ <tr>
+ <td title="<s:text name="%{decorate(#row.range)}" />"><s:text name="%{decorate(#row.range)}" /></td>
+ <td title="<s:property value="#row.commandNumber"/>"><s:property value="#row.commandNumber"/></td>
+ <td title="<s:property value="#row.quotationQuantity"/>"><s:property value="#row.quotationQuantity"/></td>
+ <td title="<s:property value="#row.productQuantity"/>"><s:property value="#row.productQuantity"/></td>
+ <td title="<s:property value="#row.savQuantity"/>"><s:property value="#row.savQuantity"/></td>
+ </tr>
+ </s:iterator>
+ </tbody>
+ <tfoot>
+ <tr>
+ <th>Total</th>
+ <th></th>
+ <th><s:property value="quotationTotal"/></th>
+ <th><s:property value="productTotal"/></th>
+ <th><s:property value="savTotal"/></th>
+ </tr>
+ </tfoot>
+ </table>
+ </s:if>
+
+ <dl class="dl-horizontal large-dl">
+ <dt>À</dt>
+ <dd><s:property value="emailUIModel.toRecipients" /></dd>
+ <dt>Copie à</dt>
+ <dd><s:property value="emailUIModel.ccRecipients" /></dd>
+ <dt>Sujet</dt>
+ <dd><s:property value="emailUIModel.subject" /></dd>
+ <dt>Contenu de l'email reçu</dt>
+ <dd><s:property value="emailUIModel.content" escapeHtml="false"/></dd>
+ <dt>Message</dt>
+ <dd><s:text name="%{decorate(demand.comment)}" />
+ </dl>
+
+ </s:if>
+
+
+ <div class="modal fade" id="replyModal"
+ tabindex="-1" role="dialog"
+ aria-labelledby="replyModalLabel" aria-hidden="true">
+
+ <div class="modal-dialog modal-lg">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal">
+ <span aria-hidden="true">×</span><span class="sr-only">Close</span>
+ </button>
+ <h4 class="modal-title" id="replyModalLabel">{{currentReply.subject}}</h4>
+ </div>
+ <div class="modal-body">
+ <dl class="dl-horizontal">
+ <dt>De</dt>
+ <dd>{{currentReply.sender}}</dd>
+ <dt>À</dt>
+ <dd>{{currentReply.toRecipients}}</dd>
+ <dt>Copie à</dt>
+ <dd>{{currentReply.ccRecipients}}</dd>
+ <dt>Copie cachée à</dt>
+ <dd>{{currentReply.bccRecipients}}</dd>
+ <dt>Sujet</dt>
+ <dd>{{currentReply.subject}}</dd>
+ </dl>
+ <hr/>
+ <p ng-bind-html="currentReply.content"></p>
+ <hr/>
+ Pièces jointes
+ <ul>
+ <li ng-repeat="attachment in currentReply.attachments">
+ {{attachment.filename}}
+ </li>
+ </ul>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-default" data-dismiss="modal">Fermer</button>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ </div>
</body>
</html>
\ No newline at end of file
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-10-07 16:13:01 UTC (rev 674)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators/layout.jsp 2014-10-10 09:40:02 UTC (rev 675)
@@ -52,33 +52,50 @@
<div class="navbar-header">
<a href="<s:url value='/' />" class="navbar-brand">FaxToMail</a>
</div>
- <s:if test="authenticated">
- <nav class="collapse navbar-collapse" role="navigation">
- <ul class="nav navbar-nav">
-
+ <nav class="collapse navbar-collapse" role="navigation">
+ <ul class="nav navbar-nav">
+ <s:if test="authenticated">
<s:if test="admin">
- <li><a href="<s:url action='ldap-input' namespace="/admin" />">
- <span class="fa fa-database"></span> Active Directory</a></li>
- <li><a href="<s:url action='configuration-input' namespace="/admin" />">
- <span class="fa fa-cog"></span> Configuration</a></li>
- <li><a href="<s:url action='import-input' namespace="/admin" />">
- <span class="fa fa-file-excel-o"></span> Import</a></li>
- <li><a href="<s:url action='lock-input' namespace="/admin" />">
- <span class="fa fa-unlock-alt"></span> Verrouillages</a></li>
+ <li class="dropdown">
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="fa fa-wrench"></span> Administration <span class="caret"></span></a>
+ <ul class="dropdown-menu" role="menu">
+ <li><a href="<s:url action='ldap-input' namespace="/admin" />">
+ <span class="fa fa-database"></span> Active Directory</a></li>
+ <li><a href="<s:url action='configuration-input' namespace="/admin" />">
+ <span class="fa fa-cogs"></span> Configuration</a></li>
+ <li><a href="<s:url action='import-input' namespace="/admin" />">
+ <span class="fa fa-file-excel-o"></span> Import</a></li>
+ <li><a href="<s:url action='lock-input' namespace="/admin" />">
+ <span class="fa fa-unlock-alt"></span> Verrouillages</a></li>
+ <li><a href="<s:url action='import-archive-input' namespace="/admin" />">
+ <span class="fa fa-archive"></span> Reprise des archives</a></li>
+ </ul>
+ </li>
</s:if>
<li><a href="<s:url action='user-folder-input' namespace="/admin" />">
<span class="fa fa-folder-open"></span> Dossiers utilisateur</a></li>
- </ul>
- <ul class="nav navbar-nav navbar-right">
+ </s:if>
+
+ <li><a href="<s:url action='archive-search-input' />">
+ <span class="fa fa-search"></span> Recherche archive</a></li>
+
+ </ul>
+
+ <ul class="nav navbar-nav navbar-right">
+ <s:if test="authenticated">
<li><a><span class="fa fa-user"></span>
<s:property value="authenticatedUser.firstName" /> <s:property value="authenticatedUser.lastName" /></a></li>
<li><a href="<s:url action='logout' namespace="/" />">
<span class="fa fa-power-off"></span> Déconnexion</a></li>
- </ul>
- </nav>
- </s:if>
+ </s:if>
+ <s:else>
+ <li><a href="<s:url action='login-input' namespace="/" />">
+ <span class="fa fa-power-off"></span> Connexion</a></li>
+ </s:else>
+ </ul>
+ </nav>
</div>
</header>
Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/wro.xml
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/wro.xml 2014-10-07 16:13:01 UTC (rev 674)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/wro.xml 2014-10-10 09:40:02 UTC (rev 675)
@@ -54,8 +54,6 @@
<js>classpath:META-INF/resources/webjars/respond/1.4.2/src/respond.js</js>
</group>
-
-
<group name='faxtomail'>
<group-ref>jquery</group-ref>
<group-ref>jquery-ui</group-ref>
@@ -95,4 +93,12 @@
<group name='faxtomail-archive-search'>
<css>/css/faxtomail.css</css>
</group>
+
+ <group name='faxtomail-detail-demand'>
+ <group-ref>angular-sanitize</group-ref>
+ <js>/js/demand-detail.js</js>
+ <css>/css/faxtomail.css</css>
+ <css>/css/demand-detail.css</css>
+ </group>
+
</groups>
Added: trunk/faxtomail-ui-web/src/main/webapp/css/demand-detail.css
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/css/demand-detail.css (rev 0)
+++ trunk/faxtomail-ui-web/src/main/webapp/css/demand-detail.css 2014-10-10 09:40:02 UTC (rev 675)
@@ -0,0 +1,45 @@
+.float-right {
+ float: right;
+}
+
+.margin-right-1-icon {
+ margin-right: 25px;
+}
+
+.margin-right-2-icons {
+ margin-right: 45px;
+}
+
+.margin-right-10 {
+ margin-right: 10px;
+}
+
+.large-dl dt {
+ width: 235px;
+}
+
+.large-dl dd {
+ margin-left: 255px;
+}
+
+.dropdown-menu > li > span {
+ display: block;
+ padding: 3px 20px;
+ clear: both;
+ font-weight: normal;
+ color: #333;
+ white-space: nowrap;
+}
+
+.dropdown-menu > li > span:hover, .dropdown-menu > li > span:focus {
+ color: #262626;
+ background-color: #F5F5F5;
+}
+
+.dropdown-menu > li span,.dropdown-menu > li a {
+ line-height: 1.42857;
+}
+
+.dropdown-menu > li a {
+ text-decoration: none;
+}
\ No newline at end of file
Added: trunk/faxtomail-ui-web/src/main/webapp/js/demand-detail.js
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/js/demand-detail.js (rev 0)
+++ trunk/faxtomail-ui-web/src/main/webapp/js/demand-detail.js 2014-10-10 09:40:02 UTC (rev 675)
@@ -0,0 +1,15 @@
+var DemandDetailModule = angular.module('DemandDetailModule', ['FaxToMail', 'ngSanitize']);
+
+DemandDetailModule.controller('DemandDetailController', ['$scope', 'DemandDetailData',
+ function($scope, DemandDetailData) {
+
+ // {Array} replies
+ $scope.replies = DemandDetailData.replies;
+ $scope.currentReply = null;
+
+ $scope.showReplyModal = function(index) {
+ $scope.currentReply = $scope.replies[index];
+ $('#replyModal').modal('show');
+ }
+
+}]);
Modified: trunk/faxtomail-ui-web/src/main/webapp/js/faxtomail.js
===================================================================
--- trunk/faxtomail-ui-web/src/main/webapp/js/faxtomail.js 2014-10-07 16:13:01 UTC (rev 674)
+++ trunk/faxtomail-ui-web/src/main/webapp/js/faxtomail.js 2014-10-10 09:40:02 UTC (rev 675)
@@ -92,3 +92,11 @@
}
};
});
+
+var ngBindHtmlDirective = ['$sce', function($sce) {
+ return function(scope, element, attr) {
+ scope.$watch($sce.parseAsHtml(attr.ngBindHtml), function(value) {
+ element.html(value || '');
+ });
+ };
+ }];
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-10-07 16:13:01 UTC (rev 674)
+++ trunk/pom.xml 2014-10-10 09:40:02 UTC (rev 675)
@@ -306,6 +306,12 @@
</dependency>
<dependency>
+ <groupId>org.swinglabs</groupId>
+ <artifactId>pdf-renderer</artifactId>
+ <version>1.0.5</version>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>1.8.7</version>
1
0