diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/AsseverazioniUtil.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/AsseverazioniUtil.java index b4b91dcb..0f77525d 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/AsseverazioniUtil.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/AsseverazioniUtil.java @@ -1,6 +1,7 @@ package it.tref.liferay.portos.bo.util; import it.tref.liferay.portos.bo.model.Asseverazione; +import it.tref.liferay.portos.bo.model.Delega; import it.tref.liferay.portos.bo.model.DettPratica; import it.tref.liferay.portos.bo.model.IntPratica; import it.tref.liferay.portos.bo.model.Soggetto; @@ -114,7 +115,7 @@ public class AsseverazioniUtil { public static final String ASSEVERAZIONI_INTEGRAZIONE = "asseverazioni_integrazione"; @SuppressWarnings("serial") - private static final Map> required = new HashMap>(15) { + private static final Map> REQUIRED = new HashMap>(15) { { put(DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A02, Arrays.asList(TipoSoggettoUtil.PROGETTISTA, TipoSoggettoUtil.DIRETTORE_LAVORI)); @@ -152,7 +153,7 @@ public class AsseverazioniUtil { }; @SuppressWarnings("serial") - private static final Map> recommended = new HashMap>(3) { + private static final Map> RECOMMENDED = new HashMap>(3) { { put(DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A04, Arrays.asList(TipoSoggettoUtil.DITTA)); put(DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A10, Arrays.asList(TipoSoggettoUtil.DITTA)); @@ -160,7 +161,7 @@ public class AsseverazioniUtil { } }; - private static final List oneIsEnough = Arrays.asList(DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A11, + private static final List ONE_IS_ENOUGH = Arrays.asList(DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A11, DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A12, DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_A17, DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_ALTRI, DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_DELEGA); @@ -226,8 +227,8 @@ public class AsseverazioniUtil { } else if (TipoSoggettoUtil.COMMITTENTE.equalsIgnoreCase(tipoSoggetto)) { return !ValidazionePraticaUtil.isA98Required(dettPratica); // ADT: RIMOZIONE IF NON NECESSARI - } else if (required.containsKey(ASSEVERAZIONI_DOMANDA)) { - return required.get(ASSEVERAZIONI_DOMANDA).contains(tipoSoggetto); + } else if (REQUIRED.containsKey(ASSEVERAZIONI_DOMANDA)) { + return REQUIRED.get(ASSEVERAZIONI_DOMANDA).contains(tipoSoggetto); } } return false; @@ -241,32 +242,32 @@ public class AsseverazioniUtil { || TipoIntegrazioneUtil.VARIANTE.equalsIgnoreCase(dettPratica.getTipoIntegrazione())) { return false; } - if (recommended.containsKey(ASSEVERAZIONI_DOMANDA)) { - return recommended.get(ASSEVERAZIONI_DOMANDA).contains(tipoSoggetto); + if (RECOMMENDED.containsKey(ASSEVERAZIONI_DOMANDA)) { + return RECOMMENDED.get(ASSEVERAZIONI_DOMANDA).contains(tipoSoggetto); } return false; } public static boolean isAsseverazioneRequiredByCodiceDoc(String codiceDoc, String tipoSoggetto) { - if (required.containsKey(codiceDoc)) { - return required.get(codiceDoc).contains(tipoSoggetto); + if (REQUIRED.containsKey(codiceDoc)) { + return REQUIRED.get(codiceDoc).contains(tipoSoggetto); } return false; } public static boolean isAsseverazioneRecommendedByCodiceDoc(String codiceDoc, String tipoSoggetto) { - if (recommended.containsKey(codiceDoc)) { - return recommended.get(codiceDoc).contains(tipoSoggetto); + if (RECOMMENDED.containsKey(codiceDoc)) { + return RECOMMENDED.get(codiceDoc).contains(tipoSoggetto); } return false; } public static List getRequiredSubjectsByCodiceDoc(String codiceDoc) { - if (required.containsKey(codiceDoc)) { - return required.get(codiceDoc); + if (REQUIRED.containsKey(codiceDoc)) { + return REQUIRED.get(codiceDoc); } return Collections.emptyList(); } @@ -285,42 +286,43 @@ public class AsseverazioniUtil { if (asseverazioniEseguite.size() == 0) { return false; } - List nuoviSoggetti = new ArrayList( - SoggettoLocalServiceUtil.getCfValidTmpByDettPratica(dettPraticaId)); - List nuoviDelegati = new ArrayList( - DelegaLocalServiceUtil.findCfByDettPratica_Tipologia_InEsito(dettPraticaId, new String[] { - TipoSoggettoUtil.COMMITTENTE, TipoSoggettoUtil.DIRETTORE_LAVORI, TipoSoggettoUtil.GEOLOGO, - TipoSoggettoUtil.DITTA, TipoSoggettoUtil.PROGETTISTA }, - new String[] { AsseverazioniUtil.STATO_ESEGUITA })); + Set cfNuoviSoggetti = new HashSet<>(); + for (Soggetto soggetto : SoggettoLocalServiceUtil.getValidTmpByDettPratica(dettPraticaId)) { + if (!TipoSoggettoUtil.COLLAUDATORE.equals(soggetto.getTipologiaSoggetto()) + || soggetto.getCodiceFiscale().equalsIgnoreCase( + dettPratica.getCodiceFiscalePrincipaleCollaudatore())) { + cfNuoviSoggetti.add(soggetto.getCodiceFiscale().toLowerCase()); + } + } + Set cfNuoviDelegati = new HashSet<>(); + for (Delega delega : DelegaLocalServiceUtil.findByDettPratica_Tipologia_InEsito(dettPraticaId, + new String[] { TipoSoggettoUtil.COMMITTENTE, TipoSoggettoUtil.DIRETTORE_LAVORI, + TipoSoggettoUtil.GEOLOGO, TipoSoggettoUtil.DITTA, TipoSoggettoUtil.PROGETTISTA }, + new String[] { AsseverazioniUtil.STATO_ESEGUITA })) { + cfNuoviDelegati.add(delega.getCodiceFiscale().toLowerCase()); + } Set cfAsseverazioni = new HashSet<>(); for (Asseverazione asseverazione : asseverazioniEseguite) { - cfAsseverazioni.add(asseverazione.getCodiceFiscale()); + cfAsseverazioni.add(asseverazione.getCodiceFiscale().toLowerCase()); } if (TipoIntegrazioneUtil.RICHIESTA_INTEGRAZIONE.equalsIgnoreCase(dettPratica.getTipoIntegrazione())) { - boolean titolareDigitale = false; User titolaredigitaleUser = UserLocalServiceUtil.getUser(intPratica.getUserId()); - if (cfAsseverazioni.contains(titolaredigitaleUser.getScreenName())) { - titolareDigitale = true; + boolean titolareDigitale = cfAsseverazioni.contains(titolaredigitaleUser.getScreenName().toLowerCase()); + if (ValidazionePraticaUtil.isA98Required(dettPratica)) { + for (Soggetto soggetto : SoggettoLocalServiceUtil.getValidTmpByDettPratica_TipologiaSoggetto( + dettPraticaId, TipoSoggettoUtil.COMMITTENTE)) { + cfNuoviSoggetti.remove(soggetto.getCodiceFiscale().toLowerCase()); + } } - if (cfAsseverazioni.containsAll(nuoviSoggetti)) { + if (cfAsseverazioni.containsAll(cfNuoviSoggetti)) { soggetti = true; - } else { - if (ValidazionePraticaUtil.isA98Required(dettPratica)) { - List committentiToRemove = SoggettoLocalServiceUtil - .getCfValidTmpByDettPratica_TipologiaSoggetto(dettPraticaId, - TipoSoggettoUtil.COMMITTENTE); - nuoviSoggetti.removeAll(committentiToRemove); - if (cfAsseverazioni.containsAll(nuoviSoggetti)) { - soggetti = true; - } - } } - nuoviDelegati.removeAll(nuoviSoggetti); - if (cfAsseverazioni.containsAll(nuoviDelegati)) { + cfNuoviDelegati.removeAll(cfNuoviSoggetti); + if (cfAsseverazioni.containsAll(cfNuoviDelegati)) { delegati = true; } if (!soggetti && delegati) { - if (cfAsseverazioni.containsAll(nuoviSoggetti)) { + if (cfAsseverazioni.containsAll(cfNuoviSoggetti)) { soggetti = true; } } @@ -338,29 +340,29 @@ public class AsseverazioniUtil { if (cfAsseverazioni.containsAll(cfSoggettiPrincipali)) { soggettiPrincipali = true; } - nuoviSoggetti.removeAll(cfSoggettiPrincipali); - if (cfAsseverazioni.containsAll(nuoviSoggetti)) { + cfNuoviSoggetti.removeAll(cfSoggettiPrincipali); + if (cfAsseverazioni.containsAll(cfNuoviSoggetti)) { soggetti = true; } else { if (ValidazionePraticaUtil.isA98Required(dettPratica)) { List committentiToRemove = SoggettoLocalServiceUtil .getCfValidTmpByDettPratica_TipologiaSoggetto(dettPraticaId, TipoSoggettoUtil.COMMITTENTE); - nuoviSoggetti.removeAll(committentiToRemove); - if (cfAsseverazioni.containsAll(nuoviSoggetti)) { + cfNuoviSoggetti.removeAll(committentiToRemove); + if (cfAsseverazioni.containsAll(cfNuoviSoggetti)) { soggetti = true; } } } - nuoviDelegati.removeAll(cfSoggettiPrincipali); - nuoviDelegati.removeAll(nuoviSoggetti); - if (cfAsseverazioni.containsAll(nuoviDelegati)) { + cfNuoviDelegati.removeAll(cfSoggettiPrincipali); + cfNuoviDelegati.removeAll(cfNuoviSoggetti); + if (cfAsseverazioni.containsAll(cfNuoviDelegati)) { delegati = true; } return soggettiPrincipali && soggetti && delegati; } } else { - for (String tipoSoggetto : required.get(ASSEVERAZIONI_DOMANDA)) { + for (String tipoSoggetto : REQUIRED.get(ASSEVERAZIONI_DOMANDA)) { // Se committente e c'รจ delega => true if (TipoSoggettoUtil.COMMITTENTE.equalsIgnoreCase(tipoSoggetto) && ValidazionePraticaUtil.isA98Required(dettPratica)) { @@ -388,7 +390,7 @@ public class AsseverazioniUtil { public static boolean isEnoughOne(String codiceDoc) { - return oneIsEnough.contains(codiceDoc); + return ONE_IS_ENOUGH.contains(codiceDoc); } public static boolean signaturesContains(long intPraticaId, String tipoSoggetto, List signatures) diff --git a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/fascicolofe/verify_fine-lavori.jsp b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/fascicolofe/verify_fine-lavori.jsp index 7c5164df..34ff7748 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/fascicolofe/verify_fine-lavori.jsp +++ b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/html/fascicolofe/verify_fine-lavori.jsp @@ -66,7 +66,6 @@ /> - <% System.out.println("################################# fineLavoriId = " + fineLavoriId); %> fileAttachments, ServiceContext serviceContext) throws Exception { - return addEmailByTemplate(className, classPK, emailTemplateId, templateParamJSON, fileAttachments, - false, serviceContext); + + return addEmailByTemplate(className, classPK, emailTemplateId, templateParamJSON, fileAttachments, false, + serviceContext); } public static Email addEmailByTemplate(String className, long classPK, long emailTemplateId, JSONObject templateParamJSON, ServiceContext serviceContext) throws Exception { - return addEmailByTemplate(className, classPK, emailTemplateId, templateParamJSON, null, false, - serviceContext); + + return addEmailByTemplate(className, classPK, emailTemplateId, templateParamJSON, null, false, serviceContext); } public static Email addEmailByTemplate(String className, long classPK, long emailTemplateId, JSONObject templateParamJSON, List fileAttachments, boolean sendSync, ServiceContext serviceContext) throws Exception { + EmailTemplate emailTemplate = EmailTemplateLocalServiceUtil.getEmailTemplate(emailTemplateId); - return addEmailByTemplate(className, classPK, emailTemplate, templateParamJSON, fileAttachments, - sendSync, serviceContext); + return addEmailByTemplate(className, classPK, emailTemplate, templateParamJSON, fileAttachments, sendSync, + serviceContext); } public static Email addEmailByTemplate(String className, long classPK, String emailTemplateName, JSONObject templateParamJSON, List fileAttachments, ServiceContext serviceContext) throws Exception { - return addEmailByTemplate(className, classPK, emailTemplateName, templateParamJSON, fileAttachments, - false, serviceContext); + return addEmailByTemplate(className, classPK, emailTemplateName, templateParamJSON, fileAttachments, false, + serviceContext); } public static Email addEmailByTemplate(String className, long classPK, String emailTemplateName, JSONObject templateParamJSON, ServiceContext serviceContext) throws Exception { - return addEmailByTemplate(className, classPK, emailTemplateName, templateParamJSON, null, false, - serviceContext); + + return addEmailByTemplate(className, classPK, emailTemplateName, templateParamJSON, null, false, serviceContext); } public static Email addEmailByTemplate(String className, long classPK, String emailTemplateName, @@ -65,15 +65,13 @@ public class MailManagerUtil { EmailTemplate emailTemplate = EmailTemplateLocalServiceUtil.fetchByC_GroupId_Name( serviceContext.getCompanyId(), serviceContext.getScopeGroupId(), emailTemplateName); - if (Validator.isNull(emailTemplate)) { Company company = CompanyLocalServiceUtil.getCompany(serviceContext.getCompanyId()); emailTemplate = EmailTemplateLocalServiceUtil.findByC_GroupId_Name(serviceContext.getCompanyId(), company.getGroupId(), emailTemplateName); } - - return addEmailByTemplate(className, classPK, emailTemplate, templateParamJSON, fileAttachments, - sendSync, serviceContext); + return addEmailByTemplate(className, classPK, emailTemplate, templateParamJSON, fileAttachments, sendSync, + serviceContext); } public static Email addEmailByTemplate(String className, long classPK, EmailTemplate emailTemplate, @@ -84,7 +82,6 @@ public class MailManagerUtil { templateParamJSON.getJSONObject(MailManagerConstants.TEMPLATE_PARAMETER_VARIABLES_KEY)); String body = VelocityUtil.evaluate(emailTemplate.getBody(), templateParamJSON.getJSONObject(MailManagerConstants.TEMPLATE_PARAMETER_VARIABLES_KEY)); - String to = templateParamJSON.getString(MailManagerConstants.TEMPLATE_PARAMETER_TO_KEY); if (Validator.isNull(to)) { to = emailTemplate.getTo(); @@ -97,16 +94,15 @@ public class MailManagerUtil { if (Validator.isNull(ccn)) { ccn = emailTemplate.getCcn(); } - return EmailLocalServiceUtil.addEmail(className, classPK, emailTemplate.getFrom(), StringUtil.split(to, StringPool.COMMA), StringUtil.split(cc, StringPool.COMMA), StringUtil.split(ccn, StringPool.COMMA), subject, body, true, fileAttachments, sendSync, emailTemplate.getTemplateName(), serviceContext); - } - public static Email addEmail(String className, long classPK, MailMessage mailMessage, - ServiceContext serviceContext) throws Exception { + public static Email addEmail(String className, long classPK, MailMessage mailMessage, ServiceContext serviceContext) + throws Exception { + return addEmail(className, classPK, mailMessage, false, serviceContext); } @@ -118,37 +114,28 @@ public class MailManagerUtil { String[] cc = MailUtil.fromInternetAddresses(mailMessage.getCC()); String[] bcc = MailUtil.fromInternetAddresses(mailMessage.getBCC()); String[] bulkAddresses = MailUtil.fromInternetAddresses(mailMessage.getBulkAddresses()); - String subject = mailMessage.getSubject(); String body = mailMessage.getBody(); - boolean htmlFormat = mailMessage.getHTMLFormat(); String[] replyTo = MailUtil.fromInternetAddresses(mailMessage.getReplyTo()); String messageId = mailMessage.getMessageId(); String inReplyTo = mailMessage.getInReplyTo(); - List fileAttachments = mailMessage.getFileAttachments(); - SMTPAccount smtpAccount = mailMessage.getSMTPAccount(); - String smtpHost = null; int smtpPort = 0; boolean smtpSecure = false; String smtpUsername = null; String smtpPassword = null; - if (smtpAccount != null) { - smtpHost = smtpAccount.getHost(); smtpPort = smtpAccount.getPort(); smtpSecure = smtpAccount.isSecure(); smtpUsername = smtpAccount.getUser(); smtpPassword = smtpAccount.getPassword(); } - - return EmailLocalServiceUtil.addEmail(className, classPK, from, to, cc, bcc, bulkAddresses, subject, - body, htmlFormat, replyTo, messageId, inReplyTo, smtpHost, smtpPort, smtpSecure, - smtpUsername, smtpPassword, fileAttachments, sendSync, null, serviceContext); + return EmailLocalServiceUtil.addEmail(className, classPK, from, to, cc, bcc, bulkAddresses, subject, body, + htmlFormat, replyTo, messageId, inReplyTo, smtpHost, smtpPort, smtpSecure, smtpUsername, smtpPassword, + fileAttachments, sendSync, null, serviceContext); } - } diff --git a/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/src/service.properties b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/src/service.properties index 079083d7..a9196a9a 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/src/service.properties +++ b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/src/service.properties @@ -13,8 +13,8 @@ ## build.namespace=portos_rep - build.number=32 - build.date=1631888946526 + build.number=33 + build.date=1634829831564 build.auto.upgrade=true ## diff --git a/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/constants/ReportConstants.java b/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/constants/ReportConstants.java index 72805085..fdfeae03 100644 --- a/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/constants/ReportConstants.java +++ b/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/constants/ReportConstants.java @@ -1,6 +1,7 @@ package it.tref.liferay.portos.report.shared.constants; public class ReportConstants { + public enum ReportProcessMode { ASYNC, SYNC } diff --git a/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/constants/ReportDestinationNames.java b/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/constants/ReportDestinationNames.java index 2df35ab8..a6de1351 100644 --- a/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/constants/ReportDestinationNames.java +++ b/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/constants/ReportDestinationNames.java @@ -2,7 +2,7 @@ package it.tref.liferay.portos.report.shared.constants; public class ReportDestinationNames { - public final static String SERIAL = "liferay/tref/portos/report_serial"; - public final static String SYNC = "liferay/tref/portos/report_sync"; - public final static String SYNC_PROTOCOLLO = "liferay/tref/portos/protocollo_sync"; + public final static String SERIAL = "liferay/tref/portos/report_serial"; + public final static String SYNC = "liferay/tref/portos/report_sync"; + public final static String SYNC_PROTOCOLLO = "liferay/tref/portos/protocollo_sync"; } diff --git a/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/dto/ReportDto.java b/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/dto/ReportDto.java index 51904e97..cacbab5a 100644 --- a/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/dto/ReportDto.java +++ b/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/dto/ReportDto.java @@ -1,186 +1,176 @@ package it.tref.liferay.portos.report.shared.dto; -import com.liferay.portal.kernel.util.Validator; - import it.tref.liferay.portos.report.shared.constants.ReportConstants.ReportType; import java.util.Map; -public class ReportDto { +import com.liferay.portal.kernel.util.Validator; - private String type; - private long folderId; - private long[] fileEntryIds; - private String fileName; - private String[] css; - private String portalURL; - private boolean showNumberOfPage; - private Object dataSource; - private Map parameters; - private String header; - private int headerHeight; - private String footer; - private int footerHeight; +public class ReportDto { - public ReportDto() { + private String type; + private long folderId; + private long[] fileEntryIds; + private String fileName; + private String[] css; + private String portalURL; + private boolean showNumberOfPage; + private Object dataSource; + private Map parameters; + private String header; + private int headerHeight; + private String footer; + private int footerHeight; - } + public ReportDto() { - public ReportDto(String type, long folderId, long[] fileEntryIds, String fileName, String[] css, String portalURL, - boolean showNumberOfPage, Object dataSource, Map parameters, String header, int headerHeight, - String footer, int footerHeight) { + } - this(); - this.type = type; - this.folderId = folderId; - this.fileEntryIds = fileEntryIds; - this.fileName = fileName; - this.css = css; - this.portalURL = portalURL; - this.showNumberOfPage = showNumberOfPage; - this.dataSource = dataSource; - this.parameters = parameters; - this.header = header; - this.headerHeight = headerHeight; - this.footer = footer; - this.footerHeight = footerHeight; - } + public ReportDto(String type, long folderId, long[] fileEntryIds, String fileName, String[] css, String portalURL, + boolean showNumberOfPage, Object dataSource, Map parameters, String header, + int headerHeight, String footer, int footerHeight) { - public String getType() { + this(); + this.type = type; + this.folderId = folderId; + this.fileEntryIds = fileEntryIds; + this.fileName = fileName; + this.css = css; + this.portalURL = portalURL; + this.showNumberOfPage = showNumberOfPage; + this.dataSource = dataSource; + this.parameters = parameters; + this.header = header; + this.headerHeight = headerHeight; + this.footer = footer; + this.footerHeight = footerHeight; + } - return type; - } + public String getType() { - public void setType(String type) { + return type; + } - this.type = type; - } + public void setType(String type) { - public long getFolderId() { + this.type = type; + } - return folderId; - } + public long getFolderId() { - public void setFolderId(long folderId) { + return folderId; + } - this.folderId = folderId; - } + public void setFolderId(long folderId) { - public long[] getFileEntryIds() { + this.folderId = folderId; + } - return fileEntryIds; - } + public long[] getFileEntryIds() { - public void setFileEntryIds(long[] fileEntryIds) { + return fileEntryIds; + } - this.fileEntryIds = fileEntryIds; - } + public void setFileEntryIds(long[] fileEntryIds) { - public String getFileName() { + this.fileEntryIds = fileEntryIds; + } - return fileName; - } + public String getFileName() { - public void setFileName(String fileName) { + return fileName; + } - this.fileName = fileName; - } + public void setFileName(String fileName) { - public String[] getCss() { + this.fileName = fileName; + } - return css; - } + public String[] getCss() { - public void setCss(String[] css) { + return css; + } - this.css = css; - } + public void setCss(String[] css) { - public String getPortalURL() { + this.css = css; + } - return portalURL; - } + public String getPortalURL() { - public void setPortalURL(String portalURL) { + return portalURL; + } - this.portalURL = portalURL; - } + public void setPortalURL(String portalURL) { - public boolean isShowNumberOfPage() { + this.portalURL = portalURL; + } - return showNumberOfPage; - } + public boolean isShowNumberOfPage() { - public void setShowNumberOfPage(boolean showNumberOfPage) { + return showNumberOfPage; + } - this.showNumberOfPage = showNumberOfPage; - } + public void setShowNumberOfPage(boolean showNumberOfPage) { - /* - * public Object getDataSource() { - * - * return dataSource; } - * - * public void setDataSource(Object dataSource) { - * - * this.dataSource = dataSource; } - */ - public Map getParameters() { + this.showNumberOfPage = showNumberOfPage; + } - return parameters; - } + public Map getParameters() { - public void setParameters(Map parameters) { + return parameters; + } - this.parameters = parameters; - } + public void setParameters(Map parameters) { - public String getHeader() { + this.parameters = parameters; + } - return header; - } + public String getHeader() { - public void setHeader(String header) { + return header; + } - this.header = header; - } + public void setHeader(String header) { - public String getFooter() { + this.header = header; + } - return footer; - } + public String getFooter() { - public void setFooter(String footer) { + return footer; + } - this.footer = footer; - } + public void setFooter(String footer) { - public int getHeaderHeight() { + this.footer = footer; + } - return headerHeight; - } + public int getHeaderHeight() { - public void setHeaderHeight(int headerHeight) { + return headerHeight; + } - this.headerHeight = headerHeight; - } + public void setHeaderHeight(int headerHeight) { - public int getFooterHeight() { + this.headerHeight = headerHeight; + } - return footerHeight; - } + public int getFooterHeight() { - public void setFooterHeight(int footerHeight) { + return footerHeight; + } - this.footerHeight = footerHeight; - } + public void setFooterHeight(int footerHeight) { - public ReportType getReportType() { + this.footerHeight = footerHeight; + } - if (Validator.isNotNull(getType())) { - return ReportType.valueOf(getType()); - } + public ReportType getReportType() { - return null; - } + if (Validator.isNotNull(getType())) { + return ReportType.valueOf(getType()); + } + return null; + } } diff --git a/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/dto/ReportResultDto.java b/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/dto/ReportResultDto.java index aeaccb03..8ffb75c8 100644 --- a/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/dto/ReportResultDto.java +++ b/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/dto/ReportResultDto.java @@ -1,12 +1,11 @@ - package it.tref.liferay.portos.report.shared.dto; -import com.liferay.portal.kernel.util.Validator; - import it.tref.liferay.portos.report.shared.constants.ReportConstants.ReportResult; import java.io.Serializable; +import com.liferay.portal.kernel.util.Validator; + public class ReportResultDto implements Serializable { private static final long serialVersionUID = -5807088639699043383L; @@ -16,13 +15,9 @@ public class ReportResultDto implements Serializable { private String result; private String resultMessage; - public ReportResultDto() { - - } + public ReportResultDto() {} - public ReportResultDto( - long reportTaskId, long[] fileEntryIds, String result, - String resultMessage) { + public ReportResultDto(long reportTaskId, long[] fileEntryIds, String result, String resultMessage) { this(); this.reportTaskId = reportTaskId; @@ -76,7 +71,6 @@ public class ReportResultDto implements Serializable { if (Validator.isNotNull(getResult())) { return ReportResult.valueOf(getResult()); } - return null; } } diff --git a/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/util/PdfUtil.java b/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/util/PdfUtil.java index 0ae9dc68..98bdb636 100644 --- a/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/util/PdfUtil.java +++ b/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/util/PdfUtil.java @@ -1,6 +1,13 @@ - package it.tref.liferay.portos.report.shared.util; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + import com.itextpdf.text.Document; import com.itextpdf.text.DocumentException; import com.itextpdf.text.Element; @@ -21,14 +28,6 @@ import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.util.Validator; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; - public class PdfUtil { private final static Log _log = LogFactoryUtil.getLog(PdfUtil.class); @@ -36,17 +35,13 @@ public class PdfUtil { public static byte[] merge(InputStream pdf1, InputStream pdf2) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - List pdfs = new ArrayList(); pdfs.add(pdf1); pdfs.add(pdf2); - Document document = new Document(); try { - List readers = new ArrayList(); Iterator iteratorPDFs = pdfs.iterator(); - // Create Readers for the pdfs. while (iteratorPDFs.hasNext()) { InputStream pdf = iteratorPDFs.next(); @@ -55,109 +50,74 @@ public class PdfUtil { } // Create a writer for the outputstream PdfWriter writer = PdfWriter.getInstance(document, outputStream); - document.open(); PdfContentByte cb = writer.getDirectContent(); - PdfImportedPage page; - int pageOfCurrentReaderPDF = 0; Iterator iteratorPDFReader = readers.iterator(); - while (iteratorPDFReader.hasNext()) { PdfReader pdfReader = iteratorPDFReader.next(); - // Create a new page in the target for each source page. while (pageOfCurrentReaderPDF < pdfReader.getNumberOfPages()) { document.newPage(); pageOfCurrentReaderPDF++; - page = - writer.getImportedPage( - pdfReader, pageOfCurrentReaderPDF); + page = writer.getImportedPage(pdfReader, pageOfCurrentReaderPDF); cb.addTemplate(page, 0, 0); } pageOfCurrentReaderPDF = 0; } iteratorPDFReader = readers.iterator(); // Loop through the PDF files and add to the output. - while (iteratorPDFReader.hasNext()) { - } - + while (iteratorPDFReader.hasNext()) {} outputStream.flush(); document.close(); outputStream.close(); - return outputStream.toByteArray(); - } - catch (Exception e) { + } catch (Exception e) { _log.error("Errore", e); return null; - } - finally { + } finally { if (document.isOpen()) { document.close(); } } } - public static byte[] mergePdf(List reports, boolean showNumberOfPage) - throws Exception { + public static byte[] mergePdf(List reports, boolean showNumberOfPage) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); - Document document = new Document(); - PdfCopy pdfCopy = new PdfCopy(document, baos); - document.open(); - - List> outlines = - new ArrayList>(); - + List> outlines = new ArrayList>(); int totalPage = 0; for (byte[] report : reports) { PdfReader pdfReader = new PdfReader(report); totalPage += pdfReader.getNumberOfPages(); pdfReader.close(); } - int curentPageNumber = 0; for (byte[] report : reports) { - PdfReader pdfReader = new PdfReader(report); - pdfCopy.setOutlines(outlines); - int n = pdfReader.getNumberOfPages(); for (int page = 0; page < n;) { - curentPageNumber++; - - PdfImportedPage pdfImportedPage = - pdfCopy.getImportedPage(pdfReader, ++page); + PdfImportedPage pdfImportedPage = pdfCopy.getImportedPage(pdfReader, ++page); PageStamp stamp = pdfCopy.createPageStamp(pdfImportedPage); - if (showNumberOfPage) { // add page numbers - ColumnText.showTextAligned( - stamp.getUnderContent(), - Element.ALIGN_CENTER, - new Phrase(String.format( - "%d / %d", curentPageNumber, totalPage)), - pdfImportedPage.getHeight() / 2, 20, 0); + ColumnText.showTextAligned(stamp.getUnderContent(), Element.ALIGN_CENTER, + new Phrase(String.format("%d / %d", curentPageNumber, totalPage)), + pdfImportedPage.getHeight() / 2, 20, 0); } - stamp.alterContents(); pdfCopy.addPage(pdfImportedPage); } - pdfCopy.freeReader(pdfReader); - pdfReader.close(); } - document.close(); - return baos.toByteArray(); } @@ -166,13 +126,11 @@ public class PdfUtil { protected ElementList header; protected ElementList footer; - public HeaderFooter(String headerHtml, String footerHtml) - throws IOException { + public HeaderFooter(String headerHtml, String footerHtml) throws IOException { if (Validator.isNotNull(headerHtml)) { header = XMLWorkerHelper.parseToElementList(headerHtml, null); } - if (Validator.isNotNull(footerHtml)) { footer = XMLWorkerHelper.parseToElementList(footerHtml, null); } @@ -183,7 +141,6 @@ public class PdfUtil { try { ColumnText ct = new ColumnText(writer.getDirectContent()); - if (Validator.isNotNull(header)) { ct.setSimpleColumn(new Rectangle(36, 832, 559, 810)); for (Element e : header) { @@ -191,7 +148,6 @@ public class PdfUtil { } ct.go(); } - if (Validator.isNotNull(footer)) { ct.setSimpleColumn(new Rectangle(36, 10, 559, 32)); for (Element e : footer) { @@ -199,8 +155,7 @@ public class PdfUtil { } ct.go(); } - } - catch (DocumentException de) { + } catch (DocumentException de) { throw new ExceptionConverter(de); } } diff --git a/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/util/VelocityUtil.java b/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/util/VelocityUtil.java index 3639ab23..5cffd7df 100644 --- a/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/util/VelocityUtil.java +++ b/liferay-plugins-sdk-6.2/shared/portos-report-shared/src/it/tref/liferay/portos/report/shared/util/VelocityUtil.java @@ -1,68 +1,52 @@ /** - * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved. - * - * The contents of this file are subject to the terms of the Liferay Enterprise Subscription License - * ("License"). You may not use this file except in compliance with the License. You can obtain a - * copy of the License by contacting Liferay, Inc. See the License for the specific language - * governing permissions and limitations under the License, including but not limited to - * distribution rights of the Software. - * - * - * + * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved. The contents of this file are subject to the terms of the + * Liferay Enterprise Subscription License ("License"). You may not use this file except in compliance with the License. + * You can obtain a copy of the License by contacting Liferay, Inc. See the License for the specific language governing + * permissions and limitations under the License, including but not limited to distribution rights of the Software. */ package it.tref.liferay.portos.report.shared.util; -import com.liferay.portal.kernel.io.unsync.UnsyncStringWriter; -import com.liferay.portal.kernel.util.PropsKeys; -import com.liferay.portal.kernel.util.Validator; - import java.util.Map; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.VelocityEngine; import org.apache.velocity.runtime.RuntimeConstants; +import com.liferay.portal.kernel.io.unsync.UnsyncStringWriter; +import com.liferay.portal.kernel.util.PropsKeys; +import com.liferay.portal.kernel.util.Validator; + /** * @author Brian Wing Shun Chan */ public class VelocityUtil { - public static String evaluate(String input) throws Exception { - - return evaluate(input, null); - } - - public static String evaluate(String input, Map variables) throws Exception { - - VelocityEngine velocityEngine = new VelocityEngine(); - - velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, - com.liferay.portal.kernel.util.PropsUtil.get(PropsKeys.VELOCITY_ENGINE_LOGGER)); - - velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM + ".log4j.category", - com.liferay.portal.kernel.util.PropsUtil.get(PropsKeys.VELOCITY_ENGINE_LOGGER_CATEGORY)); - - velocityEngine.init(); - - VelocityContext velocityContext = new VelocityContext(); - - if (variables != null) { - for (Map.Entry entry : variables.entrySet()) { - String key = entry.getKey(); - Object value = entry.getValue(); - - if (Validator.isNotNull(key)) { - velocityContext.put(key, value); - } - } - } - - UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter(); - - velocityEngine.evaluate(velocityContext, unsyncStringWriter, VelocityUtil.class.getName(), input); - - return unsyncStringWriter.toString(); - } - + public static String evaluate(String input) throws Exception { + + return evaluate(input, null); + } + + public static String evaluate(String input, Map variables) throws Exception { + + VelocityEngine velocityEngine = new VelocityEngine(); + velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, + com.liferay.portal.kernel.util.PropsUtil.get(PropsKeys.VELOCITY_ENGINE_LOGGER)); + velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM + ".log4j.category", + com.liferay.portal.kernel.util.PropsUtil.get(PropsKeys.VELOCITY_ENGINE_LOGGER_CATEGORY)); + velocityEngine.init(); + VelocityContext velocityContext = new VelocityContext(); + if (variables != null) { + for (Map.Entry entry : variables.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + if (Validator.isNotNull(key)) { + velocityContext.put(key, value); + } + } + } + UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter(); + velocityEngine.evaluate(velocityContext, unsyncStringWriter, VelocityUtil.class.getName(), input); + return unsyncStringWriter.toString(); + } }