Sfoglia il codice sorgente

Annullamento conformità errate pratiche di tipo B e C

master
Salvatore La Manna 4 anni fa
parent
commit
21015fd1e0
  1. 237
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/PuliziaDatabase.java
  2. 13
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/model/impl/AvvisoImpl.java
  3. 23
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/scheduler/SchedulerGeneraDocumento.java
  4. 21
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/hook/events/StartupAction.java
  5. 3
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/hook/listener/DLFileEntryListener.java
  6. 4
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/portlet/EmailPortlet.java
  7. 35
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/portlet/EmailTemplatesPortlet.java
  8. 35
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/service/impl/EmailAttachmentLocalServiceImpl.java
  9. 35
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/service/impl/EmailTemplateServiceImpl.java
  10. 80
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/util/MailEngine.java
  11. 2
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/util/MailSenderUtil.java
  12. 4
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/service.properties

237
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/PuliziaDatabase.java

@ -5,94 +5,231 @@
*/
package it.mwg.sismica.bo.util;
import flexjson.JSONSerializer;
import it.tref.liferay.portos.bo.model.Avviso;
import it.tref.liferay.portos.bo.model.Collaudo;
import it.tref.liferay.portos.bo.model.ControlloPratica;
import it.tref.liferay.portos.bo.model.Delega;
import it.tref.liferay.portos.bo.model.DettPratica;
import it.tref.liferay.portos.bo.model.DocAggiuntiva;
import it.tref.liferay.portos.bo.model.DocPratica;
import it.tref.liferay.portos.bo.model.FineLavori;
import it.tref.liferay.portos.bo.model.IntPratica;
import it.tref.liferay.portos.bo.model.Soggetto;
import it.tref.liferay.portos.bo.model.Sorteggio;
import it.tref.liferay.portos.bo.service.AvvisoLocalServiceUtil;
import it.tref.liferay.portos.bo.service.CollaudoLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DelegaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.ConfigurazioneLocalServiceUtil;
import it.tref.liferay.portos.bo.service.ControlloPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DocAggiuntivaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.FineLavoriLocalServiceUtil;
import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.SoggettoLocalServiceUtil;
import it.tref.liferay.portos.bo.service.SorteggioLocalServiceUtil;
import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants;
import it.tref.liferay.portos.bo.shared.util.StatoPraticaConstants;
import it.tref.liferay.portos.bo.util.AvvisoUtil;
import it.tref.liferay.portos.bo.util.WorkflowConstants;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.liferay.portal.kernel.cache.CacheRegistryUtil;
import com.liferay.portal.kernel.cache.MultiVMPoolUtil;
import com.liferay.portal.kernel.cache.SingleVMPoolUtil;
import com.liferay.portal.kernel.dao.jdbc.DataAccess;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.repository.model.FileEntry;
import com.liferay.portal.kernel.repository.model.Folder;
import com.liferay.portal.kernel.servlet.DirectServletRegistryUtil;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.UniqueList;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.model.Group;
import com.liferay.portal.model.Organization;
import com.liferay.portal.model.User;
import com.liferay.portal.service.ClassNameLocalServiceUtil;
import com.liferay.portal.security.permission.ActionKeys;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portlet.documentlibrary.model.DLFileEntry;
import com.liferay.portlet.documentlibrary.model.DLFileEntryMetadata;
import com.liferay.portlet.documentlibrary.model.DLFolder;
import com.liferay.portlet.documentlibrary.model.DLSyncConstants;
import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil;
import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil;
import com.liferay.portlet.dynamicdatamapping.model.DDMContent;
import com.liferay.portlet.dynamicdatamapping.model.DDMStorageLink;
import com.liferay.portlet.messageboards.model.MBDiscussion;
public class PuliziaDatabase {
private static final Log _log = LogFactoryUtil.getLog(PuliziaDatabase.class);
private static final int SLICE = 1000;
public static List<String> pulisci(ServiceContext serviceContext) {
public static List<String> pulisci(ServiceContext serviceContext) throws SystemException {
List<String> esito = new ArrayList<>();
int numeroPratiche = 0;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date min = null;
Date max = null;
try {
List<IntPratica> pratiche = null;
min = sdf.parse("2020-09-25 18:43:49");
max = sdf.parse("2020-09-25 18:44:15");
} catch (ParseException e) {
esitoLog(esito, "Errore date: " + e.getMessage());
return esito;
}
long companyId = serviceContext.getCompanyId();
long folderId = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(companyId,
ConfigurazioneConstants.TEMPLATE_FOLDER_ID);
long templateAnnullamentoId = 0;
try {
Folder folder = DLAppLocalServiceUtil.getFolder(folderId);
FileEntry template = DLAppLocalServiceUtil.getFileEntry(folder.getGroupId(), folderId, "ATAP");
templateAnnullamentoId = template.getFileEntryId();
} catch (PortalException e1) {
}
if (Validator.isNull(templateAnnullamentoId)) {
esitoLog(esito, "Template ATAP non trovato");
return esito;
}
String descLongAnnullamento = "Annullamento d'ufficio";
long templateConformitaId = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(companyId,
"conf.geniocivile.avviso.template.id.deposito.B2");
String descLongConformita = "Avviso di conformità";
List<Avviso> sbagliati = new ArrayList<>();
List<Long> inviate = new UniqueList<>();
List<Long> conformi = new UniqueList<>();
int start = 0;
List<Avviso> avvisi = new ArrayList<>();
do {
pratiche = IntPraticaLocalServiceUtil.getIntPraticas(start, start + SLICE);
for (IntPratica pratica : pratiche) {
List<Avviso> avvisi = AvvisoLocalServiceUtil.findByIntPratica(pratica.getIntPraticaId(),
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
int noFile = 0;
avvisi = AvvisoLocalServiceUtil.getAvvisos(start, start + SLICE);
for (Avviso avviso : avvisi) {
if (0 == avviso.getFileEntryIdBase()) {
AvvisoLocalServiceUtil.deleteAvviso(avviso);
noFile++;
if (avviso.getDtAvviso().after(min) && avviso.getDtAvviso().before(max)
&& avviso.getTipoDocumento().equalsIgnoreCase(StatoPraticaConstants.CONFORME)) {
sbagliati.add(avviso);
} else if (avviso.getFileEntryIdTemplate() == templateAnnullamentoId) {
inviate.add(avviso.getIntPraticaId());
} else if (avviso.getFileEntryIdTemplate() == templateConformitaId) {
conformi.add(avviso.getIntPraticaId());
}
}
if (noFile > 0) {
start += SLICE;
} while (avvisi.size() > 0);
SimpleDateFormat dfmt = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
JSONSerializer jsonSerializer = new JSONSerializer();
int noIntPratica = 0;
int annullatiA = 0;
int annullatiB = 0;
int annullatiC = 0;
for (Avviso avviso : sbagliati) {
long intPraticaId = avviso.getIntPraticaId();
if (!inviate.contains(intPraticaId)) {
IntPratica intPratica = null;
try {
intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId);
} catch (PortalException e) {
}
if (Validator.isNull(intPratica)) {
noIntPratica++;
} else {
Map<String, String> parameters = new HashMap<>();
parameters.put("dataProtocolloAnnullato", dfmt.format(avviso.getDtProtocollo()));
parameters.put("numeroProtocolloAnnullato", avviso.getProtocollo());
DettPratica dettPratica = DettPraticaLocalServiceUtil
.getLastCompletedByIntPratica(intPraticaId);
List<ControlloPratica> controlli = ControlloPraticaLocalServiceUtil
.findByIntPraticaId_Status(intPraticaId, WorkflowConstants.STATUS_PENDING);
long controlloPraticaId = 0;
if (controlli.size() > 0) {
controlloPraticaId = controlli.get(controlli.size() - 1).getPrimaryKey();
}
ServiceContext ctx = new ServiceContext();
ctx.setCompanyId(intPratica.getCompanyId());
ctx.setScopeGroupId(intPratica.getGroupId());
ctx.setUserId(intPratica.getUserId());
ctx.setGroupPermissions(new String[] { ActionKeys.VIEW });
String jsonParameters = StringPool.BLANK;
switch (intPratica.getTipoProcedura().toUpperCase()) {
case "A":
annullatiA++;
break;
case "B":
case "B1":
Sorteggio sorteggio = SorteggioLocalServiceUtil.findByIntPratica(intPratica
.getIntPraticaId());
if (Validator.isNull(sorteggio)) {
jsonParameters = jsonSerializer.serialize(parameters);
try {
AvvisoLocalServiceUtil.addAvviso(intPraticaId, descLongAnnullamento,
new Date(), AvvisoUtil.TIPO_AVVISO_DIRETTO, "MA",
templateAnnullamentoId, dettPratica.getPrimaryKey(),
DettPratica.class.getName(), StringPool.BLANK, jsonParameters,
controlloPraticaId, serviceContext);
if (!conformi.contains(intPraticaId)) {
AvvisoLocalServiceUtil.addAvviso(intPratica.getIntPraticaId(),
descLongConformita, new Date(), AvvisoUtil.TIPO_AVVISO_DIRETTO,
StatoPraticaConstants.CONFORME, templateConformitaId,
dettPratica.getDettPraticaId(), DettPratica.class.getName(),
controlloPraticaId, serviceContext);
}
} catch (PortalException e) {
esitoLog(esito,
"Pratica " + pratica.getNumeroProgetto() + "(" + pratica.getIntPraticaId()
+ ") - " + avvisi.size() + " avvisi, eliminati: " + noFile);
"Errore nell'invio per pratica " + intPratica.getNumeroProgetto()
+ ", " + e.getMessage());
}
esitoLog(esito, "Pratica "
+ intPratica.getNumeroProgetto()
+ " ("
+ intPraticaId
+ "), procedura "
+ intPratica.getTipoProcedura()
+ ", invio annullamento"
+ (conformi.contains(intPraticaId) ? ", conformità già inviata"
: " e conformità"));
annullatiB++;
} else {
esitoLog(esito, "Pratica " + intPratica.getNumeroProgetto() + " (" + intPraticaId
+ "), procedura " + intPratica.getTipoProcedura()
+ ", non invio perché sorteggiata");
}
break;
case "C":
Avviso valido = null;
avvisi = AvvisoLocalServiceUtil.findByIntPraticaId_tipoDocumento(intPraticaId,
StatoPraticaConstants.VIDIMATA);
for (Avviso presente : avvisi) {
if (presente.getPrimaryKey() != avviso.getPrimaryKey()) {
if ((presente.getPrimaryKey() <= avviso.getPrimaryKey())
&& (Validator.isNull(valido) || (valido.getPrimaryKey() > presente
.getPrimaryKey()))) {
valido = presente;
}
}
}
if (Validator.isNotNull(valido)) {
parameters.put("dataProtocolloValido", dfmt.format(valido.getDtProtocollo()));
parameters.put("numeroProtocolloValido", valido.getProtocollo());
jsonParameters = jsonSerializer.serialize(parameters);
try {
AvvisoLocalServiceUtil.addAvviso(intPraticaId, descLongAnnullamento,
new Date(), AvvisoUtil.TIPO_AVVISO_DIRETTO, "MA",
templateAnnullamentoId, dettPratica.getPrimaryKey(),
DettPratica.class.getName(), StringPool.BLANK, jsonParameters,
controlloPraticaId, serviceContext);
} catch (PortalException e) {
esitoLog(esito,
"Errore nell'invio per pratica " + intPratica.getNumeroProgetto()
+ ", " + e.getMessage());
}
}
esitoLog(esito, "Pratica " + intPratica.getNumeroProgetto() + " (" + intPraticaId
+ "), procedura " + intPratica.getTipoProcedura() + ", " + jsonParameters);
annullatiC++;
break;
}
}
}
start += SLICE;
numeroPratiche += pratiche.size();
} while (pratiche.size() > 0);
esitoLog(esito, numeroPratiche + " pratiche");
} catch (Exception e) {
esitoLog(esito, "Interrotto per errore: " + e.getMessage());
}
_log.info(sbagliati.size() + " avvisi");
_log.info("Procedura A = " + annullatiA);
_log.info("Procedura B = " + annullatiB);
_log.info("Procedura C = " + annullatiC);
_log.info("IntPratica non esistente = " + noIntPratica);
return esito;
}

13
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/model/impl/AvvisoImpl.java

@ -124,11 +124,14 @@ public class AvvisoImpl extends AvvisoBaseImpl {
public String getDescriptionOggettoProtocollo() throws PortalException, SystemException {
String tipoDocumento = AvvisoUtil.getAllTipoDocumento().containsKey(this.getTipoDocumento()) ? AvvisoUtil
.getAllTipoDocumento().get(this.getTipoDocumento())
: "label.admingeniocivile.avviso.tipoDocumento.avvisomanuale";
String fullDescription = LanguageUtil.get(LocaleUtil.ITALIAN, tipoDocumento);
String fullDescription = LanguageUtil.get(LocaleUtil.ITALIAN,
"label.admingeniocivile.avviso.tipoDocumento.avvisomanuale");
if (AvvisoUtil.getAllTipoDocumento().containsKey(this.getTipoDocumento())) {
fullDescription = LanguageUtil.get(LocaleUtil.ITALIAN,
AvvisoUtil.getAllTipoDocumento().get(this.getTipoDocumento()));
} else if (Validator.isNotNull(this.getDescLong())) {
fullDescription = this.getDescLong();
}
if (this.getTipoDocumento().equalsIgnoreCase(StatoPraticaConstants.VIDIMATA)) {

23
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/scheduler/SchedulerGeneraDocumento.java

@ -132,29 +132,6 @@ public class SchedulerGeneraDocumento implements MessageListener {
if (Validator.isNotNull(avviso.getJsonParameters())) {
JSONDeserializer<Map<String, String>> deserializer = JSONFactoryUtil.createJSONDeserializer();
parameters.putAll(deserializer.deserialize(avviso.getJsonParameters()));
// TODO vedere se vann oaggiunti dati presi in altro modo
// if
// (parameters.containsKey(WorkflowConstants.WORKFLOW_PARAM_NAME_DELEGATO_OUT))
// {
// User user = null;
// String delegato =
// GetterUtil.getString(parameters.get(WorkflowConstants.WORKFLOW_PARAM_NAME_DELEGATO_OUT));
// List<ExpandoValue> expandoValues =
// ExpandoValueLocalServiceUtil.getColumnValues(companyId,
// User.class.getName(),
// Constants.CUSTOM_FIELD_TABLE_NAME,
// Constants.CUSTOM_FIELD_GC_USERID, delegato,
// QueryUtil.ALL_POS,
// QueryUtil.ALL_POS);
// if (expandoValues != null && !expandoValues.isEmpty()) {
// ExpandoValue expandoValue = expandoValues.get(0);
// user =
// UserLocalServiceUtil.fetchUserById(expandoValue.getClassPK());
// }
// parameters.put(WorkflowConstants.WORKFLOW_PARAM_NAME_DELEGATO,
// user.getFullName());
// }
}
Object bean;

21
liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/hook/events/StartupAction.java

@ -40,12 +40,12 @@ public class StartupAction extends SimpleAction {
// Folders
String[] groupActions = {ActionKeys.VIEW};
String[] guestActions = {ActionKeys.VIEW};
String[] groupActions = { ActionKeys.VIEW };
String[] guestActions = { ActionKeys.VIEW };
addDLFolderIfNotExists(userDefault.getUserId(), companyGroup.getGroupId(), companyGroup.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, EmailConstants.DEFAULT_ATTACHMENTS_FOLDER_NAME, true,
groupActions, guestActions);
addDLFolderIfNotExists(userDefault.getUserId(), companyGroup.getGroupId(),
companyGroup.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
EmailConstants.DEFAULT_ATTACHMENTS_FOLDER_NAME, true, groupActions, guestActions);
} catch (Exception e) {
_log.error(e, e);
@ -53,9 +53,9 @@ public class StartupAction extends SimpleAction {
}
}
private DLFolder addDLFolderIfNotExists(long userId, long groupId, long repositoryId, long parentFolderId,
String name, boolean hidden, String[] groupActions, String[] guestActions) throws PortalException,
SystemException {
private DLFolder addDLFolderIfNotExists(long userId, long groupId, long repositoryId,
long parentFolderId, String name, boolean hidden, String[] groupActions, String[] guestActions)
throws PortalException, SystemException {
DLFolder dlFolder = null;
@ -73,9 +73,8 @@ public class StartupAction extends SimpleAction {
serviceContext.setGuestPermissions(guestActions);
}
dlFolder =
DLFolderLocalServiceUtil.addFolder(userId, groupId, repositoryId, false, parentFolderId, name,
StringPool.BLANK, hidden, serviceContext);
dlFolder = DLFolderLocalServiceUtil.addFolder(userId, groupId, repositoryId, false,
parentFolderId, name, StringPool.BLANK, hidden, serviceContext);
}
return dlFolder;

3
liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/hook/listener/DLFileEntryListener.java

@ -14,7 +14,8 @@ public class DLFileEntryListener extends BaseModelListener<DLFileEntry> {
public void onBeforeRemove(DLFileEntry model) throws ModelListenerException {
try {
EmailAttachment emailAttachment = EmailAttachmentLocalServiceUtil.fetchByFileEntryId(model.getFileEntryId());
EmailAttachment emailAttachment = EmailAttachmentLocalServiceUtil.fetchByFileEntryId(model
.getFileEntryId());
if (emailAttachment != null) {
throw new ModelListenerException();
}

4
liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/portlet/EmailPortlet.java

@ -42,8 +42,8 @@ public class EmailPortlet extends MVCPortlet {
}
public void annullaEmail(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException,
SystemException {
public void annullaEmail(ActionRequest actionRequest, ActionResponse actionResponse)
throws PortalException, SystemException {
_log.debug("annullaEmail - inizio metodo");

35
liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/portlet/EmailTemplatesPortlet.java

@ -38,8 +38,8 @@ public class EmailTemplatesPortlet extends MVCPortlet {
private static Log _log = LogFactoryUtil.getLog(EmailTemplatesPortlet.class);
public void editTemplateEmail(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException,
SystemException {
public void editTemplateEmail(ActionRequest actionRequest, ActionResponse actionResponse)
throws PortalException, SystemException {
String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
@ -62,14 +62,12 @@ public class EmailTemplatesPortlet extends MVCPortlet {
try {
EmailTemplate emailTemplate = null;
if (cmd.equals(Constants.ADD)) {
emailTemplate =
EmailTemplateServiceUtil.addEmailTemplate(templateName, from, to, cc, ccn, subject, body,
attachmentPermitted, serviceContext);
emailTemplate = EmailTemplateServiceUtil.addEmailTemplate(templateName, from, to, cc, ccn,
subject, body, attachmentPermitted, serviceContext);
emailTemplateId = emailTemplate.getEmailTemplateId();
} else if (cmd.equals(Constants.UPDATE)) {
emailTemplate =
EmailTemplateServiceUtil.updateEmailTemplate(emailTemplateId, templateName, from, to, cc, ccn, subject,
body, attachmentPermitted, serviceContext);
emailTemplate = EmailTemplateServiceUtil.updateEmailTemplate(emailTemplateId, templateName,
from, to, cc, ccn, subject, body, attachmentPermitted, serviceContext);
}
emailTemplateId = emailTemplate.getEmailTemplateId();
@ -87,16 +85,16 @@ public class EmailTemplatesPortlet extends MVCPortlet {
}
public void deleteEmailTemplate(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException,
SystemException {
public void deleteEmailTemplate(ActionRequest actionRequest, ActionResponse actionResponse)
throws PortalException, SystemException {
long emailTemplateId = ParamUtil.getLong(actionRequest, "emailTemplateId");
EmailTemplateServiceUtil.deleteEmailTemplate(emailTemplateId);
}
public void addEmailByTemplate(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException,
SystemException {
public void addEmailByTemplate(ActionRequest actionRequest, ActionResponse actionResponse)
throws PortalException, SystemException {
UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest);
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
@ -122,8 +120,8 @@ public class EmailTemplatesPortlet extends MVCPortlet {
String templateParamJSON = ParamUtil.getString(actionRequest, "templateParamJSON");
JSONObject templateParamJSONObj = JSONFactoryUtil.createJSONObject(templateParamJSON);
MailManagerUtil.addEmailByTemplate(className, classPK, emailTemplateId, templateParamJSONObj, fileAttachments,
serviceContext);
MailManagerUtil.addEmailByTemplate(className, classPK, emailTemplateId, templateParamJSONObj,
fileAttachments, serviceContext);
} else if (sendMode == SendTemplateMode.EDIT) {
@ -134,9 +132,10 @@ public class EmailTemplatesPortlet extends MVCPortlet {
String subject = ParamUtil.getString(actionRequest, "subject");
String body = ParamUtil.getString(actionRequest, "body");
EmailLocalServiceUtil.addEmail(className, classPK, from, StringUtil.split(to, StringPool.COMMA),
StringUtil.split(cc, StringPool.COMMA), StringUtil.split(ccn, StringPool.COMMA), subject, body, true,
fileAttachments, serviceContext);
EmailLocalServiceUtil.addEmail(className, classPK, from,
StringUtil.split(to, StringPool.COMMA), StringUtil.split(cc, StringPool.COMMA),
StringUtil.split(ccn, StringPool.COMMA), subject, body, true, fileAttachments,
serviceContext);
}
UploadPortletRequestUtil.copyRequestParameters(uploadPortletRequest, actionResponse);
actionResponse.setRenderParameter("mvcPath", "/html/email_templates/send_popup/close_popup.jsp");
@ -145,8 +144,6 @@ public class EmailTemplatesPortlet extends MVCPortlet {
throw new SystemException("Error add email by template.", ex);
}
}
}

35
liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/service/impl/EmailAttachmentLocalServiceImpl.java

@ -13,7 +13,6 @@
package it.tref.liferay.portos.mailmanager.service.impl;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.repository.model.FileEntry;
@ -41,13 +40,15 @@ import java.util.List;
* The implementation of the email attachment local service.
*
* <p>
* All custom service methods should be put in this class. Whenever methods are added, rerun
* ServiceBuilder to copy their definitions into the
* {@link it.noovle.azimut.icf.mailmanager.service.EmailAttachmentLocalService} interface.
* All custom service methods should be put in this class. Whenever methods are
* added, rerun ServiceBuilder to copy their definitions into the
* {@link it.noovle.azimut.icf.mailmanager.service.EmailAttachmentLocalService}
* interface.
*
* <p>
* This is a local service. Methods of this service will not have security checks based on the
* propagated JAAS credentials because this service can only be accessed from within the same VM.
* This is a local service. Methods of this service will not have security
* checks based on the propagated JAAS credentials because this service can only
* be accessed from within the same VM.
* </p>
*
* @author
@ -59,11 +60,11 @@ public class EmailAttachmentLocalServiceImpl extends EmailAttachmentLocalService
* NOTE FOR DEVELOPERS:
*
* Never reference this interface directly. Always use {@link
* it.noovle.azimut.icf.mailmanager.service.EmailAttachmentLocalServiceUtil} to access the
* email attachment local service.
* it.noovle.azimut.icf.mailmanager.service.EmailAttachmentLocalServiceUtil}
* to access the email attachment local service.
*/
public EmailAttachment addEmailAttachment(long companyId, long emailId, long folderId, String fileName, File file)
throws PortalException, SystemException {
public EmailAttachment addEmailAttachment(long companyId, long emailId, long folderId, String fileName,
File file) throws PortalException, SystemException {
Company company = companyLocalService.getCompany(companyId);
@ -82,15 +83,15 @@ public class EmailAttachmentLocalServiceImpl extends EmailAttachmentLocalService
}
ServiceContext serviceContext = new ServiceContext();
serviceContext.setGroupPermissions(new String[] {ActionKeys.VIEW});
serviceContext.setGuestPermissions(new String[] {ActionKeys.VIEW});
serviceContext.setGroupPermissions(new String[] { ActionKeys.VIEW });
serviceContext.setGuestPermissions(new String[] { ActionKeys.VIEW });
FileEntry fileEntry =
dlAppLocalService.addFileEntry(defaultUser.getUserId(), folder.getRepositoryId(), folder.getFolderId(),
sourceFileName, mimeType, title, StringPool.BLANK, StringPool.BLANK, file, serviceContext);
FileEntry fileEntry = dlAppLocalService.addFileEntry(defaultUser.getUserId(),
folder.getRepositoryId(), folder.getFolderId(), sourceFileName, mimeType, title,
StringPool.BLANK, StringPool.BLANK, file, serviceContext);
EmailAttachment emailAttachment =
emailAttachmentLocalService.createEmailAttachment(new EmailAttachmentPK(emailId, fileEntry.getFileEntryId()));
EmailAttachment emailAttachment = emailAttachmentLocalService
.createEmailAttachment(new EmailAttachmentPK(emailId, fileEntry.getFileEntryId()));
return emailAttachmentLocalService.addEmailAttachment(emailAttachment);
}

35
liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/service/impl/EmailTemplateServiceImpl.java

@ -26,13 +26,15 @@ import it.tref.liferay.portos.mailmanager.service.base.EmailTemplateServiceBaseI
* The implementation of the email template remote service.
*
* <p>
* All custom service methods should be put in this class. Whenever methods are added, rerun
* ServiceBuilder to copy their definitions into the
* {@link it.noovle.azimut.icf.mailmanager.service.EmailTemplateService} interface.
* All custom service methods should be put in this class. Whenever methods are
* added, rerun ServiceBuilder to copy their definitions into the
* {@link it.noovle.azimut.icf.mailmanager.service.EmailTemplateService}
* interface.
*
* <p>
* This is a remote service. Methods of this service are expected to have security checks based on
* the propagated JAAS credentials because this service can be accessed remotely.
* This is a remote service. Methods of this service are expected to have
* security checks based on the propagated JAAS credentials because this service
* can be accessed remotely.
* </p>
*
* @author
@ -44,28 +46,29 @@ public class EmailTemplateServiceImpl extends EmailTemplateServiceBaseImpl {
* NOTE FOR DEVELOPERS:
*
* Never reference this interface directly. Always use {@link
* it.noovle.azimut.icf.mailmanager.service.EmailTemplateServiceUtil} to access the email
* template remote service.
* it.noovle.azimut.icf.mailmanager.service.EmailTemplateServiceUtil} to
* access the email template remote service.
*/
public EmailTemplate addEmailTemplate(String templateName, String from, String[] to, String[] cc, String[] ccn,
String subject, String body, boolean attachmentPermitted, ServiceContext serviceContext) throws SystemException,
PortalException {
public EmailTemplate addEmailTemplate(String templateName, String from, String[] to, String[] cc,
String[] ccn, String subject, String body, boolean attachmentPermitted,
ServiceContext serviceContext) throws SystemException, PortalException {
EmailTemplatePermission.check(getPermissionChecker(), serviceContext.getScopeGroupId(), ActionKeys.ADD_ENTRY);
EmailTemplatePermission.check(getPermissionChecker(), serviceContext.getScopeGroupId(),
ActionKeys.ADD_ENTRY);
return emailTemplateLocalService.addEmailTemplate(templateName, from, to, cc, ccn, subject, body,
attachmentPermitted, serviceContext);
}
public EmailTemplate updateEmailTemplate(long emailTemplateId, String templateName, String from, String[] to,
String[] cc, String[] ccn, String subject, String body, boolean attachmentPermitted, ServiceContext serviceContext)
throws SystemException, PortalException {
public EmailTemplate updateEmailTemplate(long emailTemplateId, String templateName, String from,
String[] to, String[] cc, String[] ccn, String subject, String body, boolean attachmentPermitted,
ServiceContext serviceContext) throws SystemException, PortalException {
EmailTemplateEntryPermission.check(getPermissionChecker(), emailTemplateId, ActionKeys.UPDATE);
return emailTemplateLocalService.updateEmailTemplate(emailTemplateId, templateName, from, to, cc, ccn, subject,
body, attachmentPermitted, serviceContext);
return emailTemplateLocalService.updateEmailTemplate(emailTemplateId, templateName, from, to, cc,
ccn, subject, body, attachmentPermitted, serviceContext);
}
public EmailTemplate deleteEmailTemplate(long emailTemplateId) throws PortalException, SystemException {

80
liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/util/MailEngine.java

@ -120,34 +120,36 @@ public class MailEngine {
public static void send(InternetAddress from, InternetAddress to, String subject, String body)
throws MailEngineException {
send(from, new InternetAddress[] {to}, null, null, subject, body, false, null, null, null);
send(from, new InternetAddress[] { to }, null, null, subject, body, false, null, null, null);
}
public static void send(InternetAddress from, InternetAddress to, String subject, String body, boolean htmlFormat)
throws MailEngineException {
public static void send(InternetAddress from, InternetAddress to, String subject, String body,
boolean htmlFormat) throws MailEngineException {
send(from, new InternetAddress[] {to}, null, null, subject, body, htmlFormat, null, null, null);
send(from, new InternetAddress[] { to }, null, null, subject, body, htmlFormat, null, null, null);
}
public static void send(InternetAddress from, InternetAddress[] to, InternetAddress[] cc, InternetAddress[] bcc,
InternetAddress[] bulkAddresses, String subject, String body, boolean htmlFormat, InternetAddress[] replyTo,
String messageId, String inReplyTo) throws MailEngineException {
public static void send(InternetAddress from, InternetAddress[] to, InternetAddress[] cc,
InternetAddress[] bcc, InternetAddress[] bulkAddresses, String subject, String body,
boolean htmlFormat, InternetAddress[] replyTo, String messageId, String inReplyTo)
throws MailEngineException {
send(from, to, cc, bcc, bulkAddresses, subject, body, htmlFormat, replyTo, messageId, inReplyTo, null);
}
public static void send(InternetAddress from, InternetAddress[] to, InternetAddress[] cc, InternetAddress[] bcc,
InternetAddress[] bulkAddresses, String subject, String body, boolean htmlFormat, InternetAddress[] replyTo,
String messageId, String inReplyTo, List<FileAttachment> fileAttachments) throws MailEngineException {
public static void send(InternetAddress from, InternetAddress[] to, InternetAddress[] cc,
InternetAddress[] bcc, InternetAddress[] bulkAddresses, String subject, String body,
boolean htmlFormat, InternetAddress[] replyTo, String messageId, String inReplyTo,
List<FileAttachment> fileAttachments) throws MailEngineException {
send(from, to, cc, bcc, bulkAddresses, subject, body, htmlFormat, replyTo, messageId, inReplyTo, fileAttachments,
null);
send(from, to, cc, bcc, bulkAddresses, subject, body, htmlFormat, replyTo, messageId, inReplyTo,
fileAttachments, null);
}
public static void send(InternetAddress from, InternetAddress[] to, InternetAddress[] cc, InternetAddress[] bcc,
InternetAddress[] bulkAddresses, String subject, String body, boolean htmlFormat, InternetAddress[] replyTo,
String messageId, String inReplyTo, List<FileAttachment> fileAttachments, SMTPAccount smtpAccount)
throws MailEngineException {
public static void send(InternetAddress from, InternetAddress[] to, InternetAddress[] cc,
InternetAddress[] bcc, InternetAddress[] bulkAddresses, String subject, String body,
boolean htmlFormat, InternetAddress[] replyTo, String messageId, String inReplyTo,
List<FileAttachment> fileAttachments, SMTPAccount smtpAccount) throws MailEngineException {
long startTime = System.currentTimeMillis();
@ -169,7 +171,8 @@ public class MailEngine {
FileAttachment fileAttachment = fileAttachments.get(i);
if (fileAttachment instanceof it.tref.liferay.portos.mailmanager.shared.model.FileAttachment) {
((it.tref.liferay.portos.mailmanager.shared.model.FileAttachment) fileAttachment).generateFile();
((it.tref.liferay.portos.mailmanager.shared.model.FileAttachment) fileAttachment)
.generateFile();
}
File file = fileAttachment.getFile();
@ -331,22 +334,21 @@ public class MailEngine {
}
}
public static void send(InternetAddress from, InternetAddress[] to, InternetAddress[] cc, InternetAddress[] bcc,
String subject, String body) throws MailEngineException {
public static void send(InternetAddress from, InternetAddress[] to, InternetAddress[] cc,
InternetAddress[] bcc, String subject, String body) throws MailEngineException {
send(from, to, cc, bcc, subject, body, false, null, null, null);
}
public static void send(InternetAddress from, InternetAddress[] to, InternetAddress[] cc, InternetAddress[] bcc,
String subject, String body, boolean htmlFormat, InternetAddress[] replyTo, String messageId, String inReplyTo)
throws MailEngineException {
public static void send(InternetAddress from, InternetAddress[] to, InternetAddress[] cc,
InternetAddress[] bcc, String subject, String body, boolean htmlFormat,
InternetAddress[] replyTo, String messageId, String inReplyTo) throws MailEngineException {
send(from, to, cc, bcc, null, subject, body, htmlFormat, replyTo, messageId, inReplyTo, null);
}
public static void
send(InternetAddress from, InternetAddress[] to, InternetAddress[] cc, String subject, String body)
throws MailEngineException {
public static void send(InternetAddress from, InternetAddress[] to, InternetAddress[] cc, String subject,
String body) throws MailEngineException {
send(from, to, cc, null, subject, body, false, null, null, null);
}
@ -363,18 +365,18 @@ public class MailEngine {
send(from, to, null, null, subject, body, false, null, null, null);
}
public static void send(InternetAddress from, InternetAddress[] to, String subject, String body, boolean htmlFormat)
throws MailEngineException {
public static void send(InternetAddress from, InternetAddress[] to, String subject, String body,
boolean htmlFormat) throws MailEngineException {
send(from, to, null, null, subject, body, htmlFormat, null, null, null);
}
public static void send(MailMessage mailMessage) throws MailEngineException {
send(mailMessage.getFrom(), mailMessage.getTo(), mailMessage.getCC(), mailMessage.getBCC(), mailMessage
.getBulkAddresses(), mailMessage.getSubject(), mailMessage.getBody(), mailMessage.isHTMLFormat(), mailMessage
.getReplyTo(), mailMessage.getMessageId(), mailMessage.getInReplyTo(), mailMessage.getFileAttachments(),
mailMessage.getSMTPAccount());
send(mailMessage.getFrom(), mailMessage.getTo(), mailMessage.getCC(), mailMessage.getBCC(),
mailMessage.getBulkAddresses(), mailMessage.getSubject(), mailMessage.getBody(),
mailMessage.isHTMLFormat(), mailMessage.getReplyTo(), mailMessage.getMessageId(),
mailMessage.getInReplyTo(), mailMessage.getFileAttachments(), mailMessage.getSMTPAccount());
}
public static void send(String from, String to, String subject, String body) throws MailEngineException {
@ -425,9 +427,11 @@ public class MailEngine {
}
if (account.isSecure()) {
properties.setProperty("mail." + protocol + ".socketFactory.class", "javax.net.ssl.SSLSocketFactory");
properties.setProperty("mail." + protocol + ".socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
properties.setProperty("mail." + protocol + ".socketFactory.fallback", "false");
properties.setProperty("mail." + protocol + ".socketFactory.port", String.valueOf(account.getPort()));
properties.setProperty("mail." + protocol + ".socketFactory.port",
String.valueOf(account.getPort()));
}
return properties;
@ -444,7 +448,8 @@ public class MailEngine {
}
// private static boolean _isThrowsExceptionOnFailure() {
// return GetterUtil.getBoolean(PropsUtil.get(PropsKeys.MAIL_THROWS_EXCEPTION_ON_FAILURE));
// return
// GetterUtil.getBoolean(PropsUtil.get(PropsKeys.MAIL_THROWS_EXCEPTION_ON_FAILURE));
// }
private static void _send(Session session, Message message, InternetAddress[] bulkAddresses, int batchSize)
@ -459,7 +464,8 @@ public class MailEngine {
if (smtpAuth && Validator.isNotNull(user) && Validator.isNotNull(password)) {
String protocol = GetterUtil.getString(session.getProperty("mail.transport.protocol"), Account.PROTOCOL_SMTP);
String protocol = GetterUtil.getString(session.getProperty("mail.transport.protocol"),
Account.PROTOCOL_SMTP);
Transport transport = session.getTransport(protocol);
@ -504,8 +510,8 @@ public class MailEngine {
} catch (MessagingException me) {
if (me.getNextException() instanceof SocketException) {
if (_log.isWarnEnabled()) {
_log.warn("Failed to connect to a valid mail server. Please " + "make sure one is properly configured. "
+ me.getMessage());
_log.warn("Failed to connect to a valid mail server. Please "
+ "make sure one is properly configured. " + me.getMessage());
}
} else {
LogUtil.log(_log, me);

2
liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/util/MailSenderUtil.java

@ -30,7 +30,7 @@ import org.apache.commons.lang.StringUtils;
public class MailSenderUtil {
private static final Log _log = LogFactoryUtil.getLog(MailSenderUtil.class.getName());
private static final Log _log = LogFactoryUtil.getLog(MailSenderUtil.class);
public static void sendMail(Email email) throws Exception {

4
liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/service.properties

@ -13,8 +13,8 @@
##
build.namespace=portos_Mail
build.number=75
build.date=1592823810355
build.number=76
build.date=1603286289030
build.auto.upgrade=true
##

Caricamento…
Annulla
Salva