Salvatore La Manna 4 anni fa
parent
commit
fb367a70f8
  1. 14
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/mwg/sismica/bo/util/HttpServiceUtil.java
  2. 2
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/IntPraticaLocalService.java
  3. 8
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/IntPraticaLocalServiceClp.java
  4. 5
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/IntPraticaLocalServiceUtil.java
  5. 4
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/IntPraticaLocalServiceWrapper.java
  6. 162
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/MailUtil.java
  7. 91
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/AllegatiUtil.java
  8. 663
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/SismicaUtil.java
  9. 55
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/SorteggioPraticaUtil.java
  10. 85
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/hook/CfOrganizationMembershipPolicy.java
  11. 73
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/model/impl/CollaudoImpl.java
  12. 962
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/model/impl/DettPraticaImpl.java
  13. 6
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/model/listener/ControlloPraticaModelListener.java
  14. 8
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/model/listener/DettPraticaModelListener.java
  15. 6
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/model/listener/DocPraticaModelListener.java
  16. 12
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/model/listener/IntPraticaModelListener.java
  17. 19
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/model/listener/KaleoInstanceModelListener.java
  18. 23
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/model/listener/KaleoInstanceTokenModelListener.java
  19. 20
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/model/listener/KaleoLogModelListener.java
  20. 25
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/model/listener/KaleoTaskInstanceTokenModelListener.java
  21. 6
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/model/listener/SoggettoModelListener.java
  22. 32
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/AllegatiManualiPortlet.java
  23. 26
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/AmministrazionePortlet.java
  24. 46
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/DocAggiuntivaPortlet.java
  25. 147
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/FascicoloPortlet.java
  26. 43
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/GestioneAttivitaIstruttorePortlet.java
  27. 101
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/HomeBOPortlet.java
  28. 7
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/RicercaProtocolloPortlet.java
  29. 26
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/SismicaAdministrationPortlet.java
  30. 18
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/SorteggioPortlet.java
  31. 67
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/scheduler/SchedulerEstrazioneFirme.java
  32. 73
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/scheduler/SchedulerGeneraDocumento.java
  33. 9
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/scheduler/SchedulerGeneraProtocollo.java
  34. 331
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/scheduler/SchedulerInvioDocumento.java
  35. 6
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/base/IntPraticaLocalServiceClpInvoker.java
  36. 16
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/ControlloPraticaLocalServiceImpl.java
  37. 903
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/DettPraticaLocalServiceImpl.java
  38. 9
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/IntPraticaLocalServiceImpl.java
  39. 66
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/IntPraticaServiceImpl.java
  40. 53
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/util/ProtocollazioneUtil.java
  41. 11
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/portal.properties
  42. 4
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties
  43. 183
      liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/fe/portlet/AllegatiPraticaPortlet.java
  44. 173
      liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/fe/portlet/FascicoloFePortlet.java
  45. 8
      liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/fe/portlet/SoggettiPraticaPortlet.java
  46. 3
      liferay-plugins-sdk-6.2/portlets/portos-kaleo-controller-portlet/.settings/org.eclipse.wst.common.component
  47. 31
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/hook/events/StartupAction.java
  48. 5
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/hook/listener/DLFileEntryListener.java
  49. 31
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/messaging/SendMailMessageListener.java
  50. 24
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/portlet/EmailPortlet.java
  51. 80
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/portlet/EmailTemplatesPortlet.java
  52. 84
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/service/impl/EmailAttachmentLocalServiceImpl.java
  53. 260
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/service/impl/EmailLocalServiceImpl.java
  54. 39
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/service/impl/EmailServiceImpl.java
  55. 107
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/service/impl/EmailTemplateLocalServiceImpl.java
  56. 64
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/service/impl/EmailTemplateServiceImpl.java
  57. 2
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/util/MailEngine.java
  58. 6
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/util/MailSenderUtil.java
  59. 28
      liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/mailmanager/util/VelocityUtil.java
  60. 3
      liferay-plugins-sdk-6.2/portlets/portos-report-engine-portlet/.settings/org.eclipse.wst.common.component
  61. 61
      liferay-plugins-sdk-6.2/shared/portos-mail-manager-shared/src/it/tref/liferay/portos/mailmanager/shared/messaging/util/MailManagerUtil.java
  62. 24
      liferay-plugins-sdk-6.2/shared/portos-mail-manager-shared/src/it/tref/liferay/portos/mailmanager/shared/model/FileAttachment.java

14
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/mwg/sismica/bo/util/HttpServiceUtil.java

@ -5,6 +5,8 @@ import it.tref.liferay.portos.bo.service.ConfigurazioneLocalServiceUtil;
import it.tref.liferay.portos.bo.shared.protocollo.model.Protocollo;
import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.apache.http.HttpResponse;
@ -32,21 +34,20 @@ public class HttpServiceUtil {
JSONSerializer serializer = new JSONSerializer();
serializer.exclude("*.class");
String json = serializer.serialize(protocolloBean);
String url = ConfigurazioneLocalServiceUtil.findByC_ChiaveString(companyId,
ConfigurazioneConstants.PROTOCOLLAZIONE_SERVICE_URL);
JSONObject risposta = null;
HttpPost request = new HttpPost(url);
request.addHeader("Content-type", ContentTypes.APPLICATION_JSON);
request.setEntity(new StringEntity(json, StringPool.UTF8));
CloseableHttpClient client = HttpClientBuilder.create().build();
HttpResponse response = client.execute(request);
int statusCode = response.getStatusLine().getStatusCode();
String responseBody = EntityUtils.toString(response.getEntity(), StringPool.UTF8);
try {
client.close();
} catch (IOException e) {
}
if (statusCode == HttpServletResponse.SC_OK || statusCode == HttpServletResponse.SC_CREATED) {
risposta = JSONFactoryUtil.createJSONObject(responseBody);
}
@ -54,6 +55,7 @@ public class HttpServiceUtil {
}
public static JSONObject postJson(String url, String json) throws Exception {
JSONObject risposta = null;
Options options = new Options();
options.setLocation(url);
@ -72,16 +74,16 @@ public class HttpServiceUtil {
}
public static String getUrl(String url) throws Exception {
return getUrl(url, StringPool.BLANK);
}
public static String getUrl(String url, String defaultValue) throws Exception {
Options options = new Options();
options.setLocation(url);
options.setPost(false);
String responseBody = HttpUtil.URLtoString(options);
if (options.getResponse().getResponseCode() != HttpServletResponse.SC_OK) {
throw new Exception(url + ": " + options.getResponse().getResponseCode());
// responseBody = defaultValue;

2
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/IntPraticaLocalService.java

@ -403,7 +403,7 @@ public interface IntPraticaLocalService extends BaseLocalService,
@com.liferay.portal.kernel.search.Indexable(type = IndexableType.REINDEX)
public it.tref.liferay.portos.bo.model.IntPratica updateStatoPratica(
long intPraticaId, long dettPraticaId, java.lang.String statoPratica)
long intPraticaId, java.lang.String statoPratica)
throws com.liferay.portal.kernel.exception.PortalException,
com.liferay.portal.kernel.exception.SystemException;

8
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/IntPraticaLocalServiceClp.java

@ -201,9 +201,7 @@ public class IntPraticaLocalServiceClp implements IntPraticaLocalService {
_methodName36 = "updateStatoPratica";
_methodParameterTypes36 = new String[] {
"long", "long", "java.lang.String"
};
_methodParameterTypes36 = new String[] { "long", "java.lang.String" };
_methodName37 = "updateIntPraticaSorteggio";
@ -1658,7 +1656,7 @@ public class IntPraticaLocalServiceClp implements IntPraticaLocalService {
@Override
public it.tref.liferay.portos.bo.model.IntPratica updateStatoPratica(
long intPraticaId, long dettPraticaId, java.lang.String statoPratica)
long intPraticaId, java.lang.String statoPratica)
throws com.liferay.portal.kernel.exception.PortalException,
com.liferay.portal.kernel.exception.SystemException {
Object returnObj = null;
@ -1669,8 +1667,6 @@ public class IntPraticaLocalServiceClp implements IntPraticaLocalService {
new Object[] {
intPraticaId,
dettPraticaId,
ClpSerializer.translateInput(statoPratica)
});
}

5
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/IntPraticaLocalServiceUtil.java

@ -457,11 +457,10 @@ public class IntPraticaLocalServiceUtil {
}
public static it.tref.liferay.portos.bo.model.IntPratica updateStatoPratica(
long intPraticaId, long dettPraticaId, java.lang.String statoPratica)
long intPraticaId, java.lang.String statoPratica)
throws com.liferay.portal.kernel.exception.PortalException,
com.liferay.portal.kernel.exception.SystemException {
return getService()
.updateStatoPratica(intPraticaId, dettPraticaId, statoPratica);
return getService().updateStatoPratica(intPraticaId, statoPratica);
}
public static it.tref.liferay.portos.bo.model.IntPratica updateIntPraticaSorteggio(

4
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/IntPraticaLocalServiceWrapper.java

@ -492,11 +492,11 @@ public class IntPraticaLocalServiceWrapper implements IntPraticaLocalService,
@Override
public it.tref.liferay.portos.bo.model.IntPratica updateStatoPratica(
long intPraticaId, long dettPraticaId, java.lang.String statoPratica)
long intPraticaId, java.lang.String statoPratica)
throws com.liferay.portal.kernel.exception.PortalException,
com.liferay.portal.kernel.exception.SystemException {
return _intPraticaLocalService.updateStatoPratica(intPraticaId,
dettPraticaId, statoPratica);
statoPratica);
}
@Override

162
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/MailUtil.java

@ -1,7 +1,6 @@
package it.tref.liferay.portos.bo.util;
import it.tref.liferay.portos.bo.model.Avviso;
import it.tref.liferay.portos.bo.model.Collaudo;
import it.tref.liferay.portos.bo.model.Comune;
import it.tref.liferay.portos.bo.model.ControlloPratica;
import it.tref.liferay.portos.bo.model.DettPratica;
@ -43,24 +42,19 @@ import com.liferay.portal.service.UserLocalServiceUtil;
public class MailUtil {
public static void invioMailNotifica(long intPraticaId, long dettPraticaId, long classPk, String className,
String[] to, String[] cc, String[] ccn, String templateName, JSONObject templateVariables,
List<FileAttachment> allegati, ServiceContext serviceContext) throws PortalException, SystemException {
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId);
DettPratica dettPratica = DettPraticaLocalServiceUtil.fetchDettPratica(dettPraticaId);
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId());
Comune comune = ComuneLocalServiceUtil.getComune(territorio.getComuneId());
Provincia provincia =
ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(), territorio.getCodiceProvincia());
Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(),
territorio.getCodiceProvincia());
User titolaredigitaleUser = UserLocalServiceUtil.getUser(intPratica.getUserId());
List<Soggetto> titolari =
SoggettoLocalServiceUtil.getValidByIntPratica_CodiceFiscale(intPratica.getIntPraticaId(),
titolaredigitaleUser.getScreenName());
List<Soggetto> titolari = SoggettoLocalServiceUtil.getValidByIntPratica_CodiceFiscale(
intPratica.getIntPraticaId(), titolaredigitaleUser.getScreenName());
String titolareDigitale = StringPool.BLANK;
String titolareDigitaleMail = StringPool.BLANK;
String titolareDigitaleRoles = StringPool.BLANK;
@ -68,27 +62,24 @@ public class MailUtil {
titolareDigitale = titolari.get(0).getTitle();
titolareDigitaleMail = titolari.get(0).getEmail();
for (Soggetto titolare : titolari) {
titolareDigitaleRoles +=
LanguageUtil.get(LocaleUtil.ITALIAN, "gc-soggetto-" + titolare.getTipologiaSoggetto()) + " ";
titolareDigitaleRoles += LanguageUtil.get(LocaleUtil.ITALIAN,
"gc-soggetto-" + titolare.getTipologiaSoggetto())
+ " ";
}
}
String committenteTitle = StringPool.BLANK;
String descIntervento = StringPool.BLANK;
String tempId = StringPool.BLANK;
if (Validator.isNotNull(dettPratica)) {
tempId = dettPratica.getTitle();
descIntervento = dettPratica.getDescLongIntervento();
Soggetto committentePrincipale =
SoggettoLocalServiceUtil.getValidByIntPratica_CodiceFiscale_TipologiaSoggetto(intPratica.getIntPraticaId(),
Soggetto committentePrincipale = SoggettoLocalServiceUtil
.getValidByIntPratica_CodiceFiscale_TipologiaSoggetto(intPratica.getIntPraticaId(),
dettPratica.getCodiceFiscalePrincipaleCommittente(), TipoSoggettoUtil.COMMITTENTE);
if (Validator.isNotNull(committentePrincipale)) {
committenteTitle = committentePrincipale.getTitle();
}
}
// JSONObject templateVariables = JSONFactoryUtil.createJSONObject();
templateVariables.put("tempId", tempId);
templateVariables.put("praticaNum", intPratica.getNumeroProgetto());
templateVariables.put("titolareDigitale", titolareDigitale);
@ -98,204 +89,169 @@ public class MailUtil {
templateVariables.put("provincia", provincia.getProvincia());
templateVariables.put("comune", comune.getDenominazione());
templateVariables.put("committente", committenteTitle);
// Iterator<String> iterator = templateVariablesExtra.keys();
// while (iterator.hasNext()) {
// String key = iterator.next();
// templateVariables.put(key, templateVariablesExtra.getString(key));
// }
MailManagerUtil.sendMailByTemplatName(className, classPk, templateName, to, cc, ccn, templateVariables, allegati,
serviceContext);
MailManagerUtil.sendMailByTemplatName(className, classPk, templateName, to, cc, ccn, templateVariables,
allegati, serviceContext);
}
/**
* ADT
*
* @throws SystemException
* @throws PortalException
*/
// ADT
public static void invioNotificaAssegnazioneIstruttore(Avviso avviso) throws PortalException, SystemException {
_log.info("start invioNotificaAssegnazioneIstruttore: avviso_id = " + avviso.getAvvisoId() + " - IntPraticaId = " + avviso.getIntPraticaId());
_log.info("start invioNotificaAssegnazioneIstruttore: avviso_id = " + avviso.getAvvisoId()
+ " - IntPraticaId = " + avviso.getIntPraticaId());
DettPratica dettPratica = DettPraticaLocalServiceUtil.getDettPratica(avviso.getClassPk());
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(dettPratica.getIntPraticaId());
if (avviso.getControlloPraticaId() == 0) {
_log.info("invioNotificaAssegnazioneIstruttore - skip invio email - controllopratica non trovato per avviso_id = " + avviso.getAvvisoId());
_log.info("invioNotificaAssegnazioneIstruttore - skip invio email - controllopratica non trovato per avviso_id = "
+ avviso.getAvvisoId());
AvvisoLocalServiceUtil.updateAvvisoInviatoTecnico(avviso.getAvvisoId(), true);
return;
}
ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil.getControlloPratica(avviso.getControlloPraticaId());
ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil.getControlloPratica(avviso
.getControlloPraticaId());
ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(controlloPratica.getCompanyId());
serviceContext.setScopeGroupId(controlloPratica.getGroupId());
serviceContext.setUserId(controlloPratica.getUserId());
User tecnicoIstruttore = recuperaTecnicoIstruttore(intPratica);
/////////////////////////////////////////////////////
if (tecnicoIstruttore == null) {
_log.info("invioNotificaAssegnazioneIstruttore - skip invio email - tecnicoIstruttore non trovato per avviso_id = " + avviso.getAvvisoId());
_log.info("invioNotificaAssegnazioneIstruttore - skip invio email - tecnicoIstruttore non trovato per avviso_id = "
+ avviso.getAvvisoId());
AvvisoLocalServiceUtil.updateAvvisoInviatoTecnico(avviso.getAvvisoId(), true);
return;
}
///////////////////////////////////////////////
String[] to = { tecnicoIstruttore.getEmailAddress() };
String[] cc = new String[0];
String[] ccn = new String[0];
// recupero dati
String tipoPratica = "";
String tipoPratica = StringPool.BLANK;
if (AzioniPraticheUtil.isDeposito(intPratica.getIntPraticaId())) {
tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-01");
} else if (AzioniPraticheUtil.isAutorizzazione(intPratica.getIntPraticaId())) {
tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-02");
}
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId());
Comune comune = ComuneLocalServiceUtil.getComune(territorio.getComuneId());
Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(), territorio.getCodiceProvincia());
// //////////////////////////
Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(),
territorio.getCodiceProvincia());
JSONObject templateVariables = JSONFactoryUtil.createJSONObject();
templateVariables.put("receiver", tecnicoIstruttore.getFullName());
templateVariables.put("tipoPratica", tipoPratica);
templateVariables.put("tipoOggetto", "Assegnazione Istruttoria");
templateVariables.put("dataInvio", FastDateFormatFactoryUtil.getSimpleDateFormat("dd/MM/yyyy HH:mm").format(intPratica.getStatusDate() != null ? intPratica.getStatusDate() : new Date()));
templateVariables.put(
"dataInvio",
FastDateFormatFactoryUtil.getSimpleDateFormat("dd/MM/yyyy HH:mm").format(
intPratica.getStatusDate() != null ? intPratica.getStatusDate() : new Date()));
templateVariables.put("praticaNum", intPratica.getNumeroProgetto());
templateVariables.put("provincia", provincia.getProvincia());
templateVariables.put("comune", comune.getDenominazione());
String className = IntPratica.class.getName();
long classPk = intPratica.getIntPraticaId();
MailManagerUtil.sendMailByTemplatName(className, classPk, "NOTIFICA-BO", to, cc, ccn, templateVariables, null, serviceContext);
MailManagerUtil.sendMailByTemplatName(className, classPk, "NOTIFICA-BO", to, cc, ccn, templateVariables, null,
serviceContext);
AvvisoLocalServiceUtil.updateAvvisoInviatoTecnico(avviso.getAvvisoId(), true);
}
/**
* Invio notifica istruttore dopo inserimento parere geologo
*
* @param parereGeologoId
* @param serviceContext
*/
// Invio notifica istruttore dopo inserimento parere geologo
public static void invioNotificaIstruttoreByGeologo(long parereGeologoId, ServiceContext serviceContext) {
_log.info("start invioNotificaIstruttoreByGeologo parereGeologoId=" + parereGeologoId);
_log.info("start invioNotificaIstruttoreByGeologo parereGeologoId=" + parereGeologoId);
long intPraticaId = 0L;
try {
ParereGeologo parereGeologo = ParereGeologoLocalServiceUtil.getParereGeologo(parereGeologoId);
intPraticaId = parereGeologo.getIntPraticaId();
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId);
User tecnicoIstruttore = recuperaTecnicoIstruttore(intPratica);
_log.info("email tecnico istruttore=" + tecnicoIstruttore.getEmailAddress());
String[] to = { tecnicoIstruttore.getEmailAddress() };
String[] cc = new String[0];
String[] ccn = new String[0];
// recupero dati
String tipoPratica = "";
String tipoPratica = StringPool.BLANK;
if (AzioniPraticheUtil.isDeposito(intPratica.getIntPraticaId())) {
tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-01");
} else if (AzioniPraticheUtil.isAutorizzazione(intPratica.getIntPraticaId())) {
tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-02");
}
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId());
Comune comune = ComuneLocalServiceUtil.getComune(territorio.getComuneId());
Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(), territorio.getCodiceProvincia());
// //////////////////////////
Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(),
territorio.getCodiceProvincia());
JSONObject templateVariables = JSONFactoryUtil.createJSONObject();
templateVariables.put("receiver", tecnicoIstruttore.getFullName());
templateVariables.put("tipoPratica", tipoPratica);
templateVariables.put("tipoOggetto", "Risposta a Richiesta Parere Geologo");
templateVariables.put("dataInvio", FastDateFormatFactoryUtil.getSimpleDateFormat("dd/MM/yyyy HH:mm").format(parereGeologo.getDtCompilazione() != null ? parereGeologo.getDtCompilazione() : new Date()));
templateVariables
.put("dataInvio",
FastDateFormatFactoryUtil.getSimpleDateFormat("dd/MM/yyyy HH:mm").format(
parereGeologo.getDtCompilazione() != null ? parereGeologo.getDtCompilazione()
: new Date()));
templateVariables.put("praticaNum", intPratica.getNumeroProgetto());
templateVariables.put("provincia", provincia.getProvincia());
templateVariables.put("comune", comune.getDenominazione());
String className = ParereGeologo.class.getName();
long classPk = parereGeologoId;
MailManagerUtil.sendMailByTemplatName(className, classPk, "NOTIFICA-BO", to, cc, ccn, templateVariables, null, serviceContext);
MailManagerUtil.sendMailByTemplatName(className, classPk, "NOTIFICA-BO", to, cc, ccn, templateVariables,
null, serviceContext);
} catch (Exception e) {
_log.error("invioNotificaIstruttoreByGeologo - Errore invio mail al tecnico istruttore per pratica id=" + intPraticaId, e);
_log.error("invioNotificaIstruttoreByGeologo - Errore invio mail al tecnico istruttore per pratica id="
+ intPraticaId, e);
}
}
/**
* Invio Notifica Geologo
*
* @param geologoUserId
* @param intPraticaId
* @param dettPraticaId
* @param serviceContext
*/
public static void invioNotificaGeologo(ParereGeologo parereGeologo, ServiceContext serviceContext) {
_log.info("start invioNotificaGeologo parereGeologo=" + parereGeologo.getParereGeologoId());
try {
User geologo = UserLocalServiceUtil.getUser(parereGeologo.getGeologoUserId());
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(parereGeologo.getIntPraticaId());
//DettPratica dettPratica = DettPraticaLocalServiceUtil.fetchDettPratica(parereGeologo.getDettPraticaId());
_log.info("email geologo = " + geologo.getEmailAddress());
String[] to = { geologo.getEmailAddress() };
String[] cc = new String[0];
String[] ccn = new String[0];
// recupero dati
String tipoPratica = "";
String tipoPratica = StringPool.BLANK;
if (AzioniPraticheUtil.isDeposito(intPratica.getIntPraticaId())) {
tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-01");
} else if (AzioniPraticheUtil.isAutorizzazione(intPratica.getIntPraticaId())) {
tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-02");
}
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId());
Comune comune = ComuneLocalServiceUtil.getComune(territorio.getComuneId());
Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(), territorio.getCodiceProvincia());
// //////////////////////////
Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(),
territorio.getCodiceProvincia());
JSONObject templateVariables = JSONFactoryUtil.createJSONObject();
templateVariables.put("receiver", geologo.getFullName());
templateVariables.put("tipoPratica", tipoPratica);
templateVariables.put("tipoOggetto", "Richiesta Parere");
templateVariables.put("dataInvio", FastDateFormatFactoryUtil.getSimpleDateFormat("dd/MM/yyyy HH:mm").format(parereGeologo.getDtCompilazione() != null ? parereGeologo.getDtCompilazione() : new Date()));
templateVariables
.put("dataInvio",
FastDateFormatFactoryUtil.getSimpleDateFormat("dd/MM/yyyy HH:mm").format(
parereGeologo.getDtCompilazione() != null ? parereGeologo.getDtCompilazione()
: new Date()));
templateVariables.put("praticaNum", intPratica.getNumeroProgetto());
templateVariables.put("provincia", provincia.getProvincia());
templateVariables.put("comune", comune.getDenominazione());
String className = ParereGeologo.class.getName();
long classPk = parereGeologo.getParereGeologoId();
MailManagerUtil.sendMailByTemplatName(className, classPk, "NOTIFICA-GEOLOGO", to, cc, ccn, templateVariables, null, serviceContext);
MailManagerUtil.sendMailByTemplatName(className, classPk, "NOTIFICA-GEOLOGO", to, cc, ccn,
templateVariables, null, serviceContext);
} catch (Exception e) {
_log.error("invioNotificaGeologo - Errore invio mail al geologo - ParereGeologoId=" + parereGeologo.getParereGeologoId(), e);
_log.error(
"invioNotificaGeologo - Errore invio mail al geologo - ParereGeologoId="
+ parereGeologo.getParereGeologoId(), e);
}
}
public static User recuperaTecnicoIstruttore(IntPratica intPratica) throws PortalException, SystemException {
long statusByUserId = intPratica.getStatusByUserId();
User istruttoreUser = null;
if (Validator.isNotNull(statusByUserId) && intPratica.getStatus() != WorkflowConstants.STATUS_DRAFT) {
istruttoreUser = UserLocalServiceUtil.getUser(statusByUserId);
_log.info("istruttore pratica id=" + intPratica.getIntPraticaId() + ":" + istruttoreUser.getScreenName() + " " + istruttoreUser.getEmailAddress());
_log.info("istruttore pratica id=" + intPratica.getIntPraticaId() + ":" + istruttoreUser.getScreenName()
+ " " + istruttoreUser.getEmailAddress());
}
return istruttoreUser;
}
private static final Log _log = LogFactoryUtil.getLog(MailUtil.class);
}

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

@ -52,22 +52,20 @@ import com.liferay.portlet.documentlibrary.NoSuchFolderException;
import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil;
public class AllegatiUtil {
private final static Log _log = LogFactoryUtil.getLog(AllegatiUtil.class);
public static void sostituisciDL(ActionRequest actionRequest, ActionResponse actionResponse)
throws Exception {
public static void sostituisciDL(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
List<String> esito = new ArrayList<>();
String className = ParamUtil.getString(actionRequest, "className");
actionResponse.setRenderParameter("className", className);
long classPK = ParamUtil.getLong(actionRequest, "classPK");
actionResponse.setRenderParameter("classPK", String.valueOf(classPK));
UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest);
String sourceFileName = uploadRequest.getFileName("file");
File file = uploadRequest.getFile("file");
byte[] bytes = FileUtil.getBytes(file);
if (Validator.isNull(bytes)) {
esito.add("Nessun file allegato");
} else {
@ -85,8 +83,8 @@ public class AllegatiUtil {
actionResponse.setRenderParameter("esito", esito.toArray(new String[esito.size()]));
}
private static List<String> sostituisciAllegatoSoggetto(long soggettoId, String sourceFileName,
byte[] bytes, Date date) throws PortalException, SystemException, IOException {
private static List<String> sostituisciAllegatoSoggetto(long soggettoId, String sourceFileName, byte[] bytes,
Date date) throws PortalException, SystemException, IOException {
List<String> esito = new ArrayList<>();
Soggetto soggetto = null;
@ -101,10 +99,8 @@ public class AllegatiUtil {
esito.add("Il soggetto " + soggettoId + " non ha un'allegato da sostituire");
return esito;
}
long companyId = soggetto.getCompanyId();
long userId = soggetto.getUserId();
DocPratica docPratica = null;
try {
docPratica = DocPraticaLocalServiceUtil.getDocPratica(docPraticaId);
@ -112,10 +108,8 @@ public class AllegatiUtil {
}
if (Validator.isNull(docPratica)) {
esito.add("Ricreo docPratica " + docPraticaId);
docPratica = DocPraticaLocalServiceUtil.createDocPratica(docPraticaId);
User user = UserLocalServiceUtil.getUser(userId);
docPratica.setClassName(Soggetto.class.getName());
docPratica.setClassPk(soggettoId);
docPratica.setCompanyId(companyId);
@ -135,28 +129,22 @@ public class AllegatiUtil {
return esito;
}
private static List<String> sostituisciAllegatoDocPratica(long docPraticaId, String sourceFileName,
byte[] bytes, Date date) throws SystemException, PortalException, IOException {
private static List<String> sostituisciAllegatoDocPratica(long docPraticaId, String sourceFileName, byte[] bytes,
Date date) throws SystemException, PortalException, IOException {
List<String> esito = new ArrayList<>();
DocPratica docPratica = DocPraticaLocalServiceUtil.getDocPratica(docPraticaId);
long companyId = docPratica.getCompanyId();
long userId = docPratica.getUserId();
ServiceContext serviceContext = getServiceContext(companyId, docPratica.getGroupId(), userId);
long dettPraticaId = getDettPraticaId(docPratica.getIntPraticaId());
Folder folder = getFolder(PraticaUtil.getFolderName(dettPraticaId), serviceContext);
String title = getTitle(docPratica, sourceFileName, date);
FileEntry fileEntry = addOrUpdateFileEntry(docPratica.getDlFileEntryId(), folder, userId,
sourceFileName, title, sourceFileName, bytes, serviceContext);
FileEntry fileEntry = addOrUpdateFileEntry(docPratica.getDlFileEntryId(), folder, userId, sourceFileName,
title, sourceFileName, bytes, serviceContext);
docPratica.setDlFileEntryId(fileEntry.getFileEntryId());
String sha256 = DigestUtils.sha256Hex(bytes);
docPratica.setSha256(sha256);
// Sostituzione delle firme digitali con quelle presenti nel file
FirmeBean firmeBean = FirmeUtil.deserialize(docPratica.getJsonFirmatari());
Set<String> firmeFile = new HashSet<>();
@ -168,43 +156,35 @@ public class AllegatiUtil {
}
firmeBean.setFirmeDigitali(firmeDigitali);
docPratica.setJsonFirmatari(FirmeUtil.serialize(firmeBean));
DocPraticaLocalServiceUtil.updateDocPratica(docPratica);
esito.add("DocPratica " + docPraticaId + ": aggiornato fileEntry " + fileEntry.getFileEntryId()
+ ", sha256=" + sha256);
esito.add("DocPratica " + docPraticaId + ": aggiornato fileEntry " + fileEntry.getFileEntryId() + ", sha256="
+ sha256);
return esito;
}
private static List<String> sostituisciAllegatoPagamento(long pagamentoId, String sourceFileName,
byte[] bytes) throws SystemException, PortalException, IOException {
private static List<String> sostituisciAllegatoPagamento(long pagamentoId, String sourceFileName, byte[] bytes)
throws SystemException, PortalException, IOException {
List<String> esito = new ArrayList<>();
Pagamento pagamento = PagamentoLocalServiceUtil.getPagamento(pagamentoId);
Date now = new Date();
long userId = pagamento.getUserId();
ServiceContext serviceContext = getServiceContext(pagamento.getCompanyId(), pagamento.getGroupId(),
userId);
ServiceContext serviceContext = getServiceContext(pagamento.getCompanyId(), pagamento.getGroupId(), userId);
long dettPraticaId = getDettPraticaId(pagamento.getIntPraticaId());
Folder folder = getFolder(PraticaUtil.getFolderName(dettPraticaId), serviceContext);
String title = now.getTime() + "_pagamento_manuale_" + pagamento.getPagamentoId()
+ StringPool.UNDERLINE + sourceFileName;
FileEntry fileEntry = addOrUpdateFileEntry(pagamento.getFileEntryId(), folder, userId,
sourceFileName, title, StringPool.BLANK, bytes, serviceContext);
String title = now.getTime() + "_pagamento_manuale_" + pagamento.getPagamentoId() + StringPool.UNDERLINE
+ sourceFileName;
FileEntry fileEntry = addOrUpdateFileEntry(pagamento.getFileEntryId(), folder, userId, sourceFileName, title,
StringPool.BLANK, bytes, serviceContext);
pagamento.setFileEntryId(fileEntry.getFileEntryId());
PagamentoLocalServiceUtil.updatePagamento(pagamento);
esito.add("Pagamento " + pagamentoId + ": aggiunto file " + fileEntry.getFileEntryId()
+ StringPool.SPACE + title);
esito.add("Pagamento " + pagamentoId + ": aggiunto file " + fileEntry.getFileEntryId() + StringPool.SPACE
+ title);
return esito;
}
private static long getDettPraticaId(long intPraticaId) throws SystemException {
DettPratica dettPratica = DettPraticaLocalServiceUtil.getLastEditableByIntPratica(intPraticaId);
if (Validator.isNull(dettPratica)) {
List<DettPratica> list = DettPraticaLocalServiceUtil.findByIntPraticaId(intPraticaId);
@ -214,6 +194,7 @@ public class AllegatiUtil {
}
private static ServiceContext getServiceContext(long companyId, long groupId, long userId) {
ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(companyId);
serviceContext.setScopeGroupId(groupId);
@ -226,24 +207,23 @@ public class AllegatiUtil {
SystemException {
Folder folder = null;
long parentFolderId = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(
serviceContext.getCompanyId(), ConfigurazioneConstants.ATTACHMENT_FOLDER_ID);
long parentFolderId = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(serviceContext.getCompanyId(),
ConfigurazioneConstants.ATTACHMENT_FOLDER_ID);
Folder parentFolder = DLAppLocalServiceUtil.getFolder(parentFolderId);
long repositoryId = parentFolder.getRepositoryId();
try {
folder = DLAppLocalServiceUtil.getFolder(repositoryId, parentFolderId, folderName);
} catch (NoSuchFolderException e) {
folder = DLAppLocalServiceUtil.addFolder(serviceContext.getUserId(), repositoryId,
parentFolderId, folderName, StringPool.BLANK, serviceContext);
folder = DLAppLocalServiceUtil.addFolder(serviceContext.getUserId(), repositoryId, parentFolderId,
folderName, StringPool.BLANK, serviceContext);
}
return folder;
}
private static String getTitle(DocPratica docPratica, String sourceFileName, Date date) {
String className = DocPratica.class.getName();
String tipologia = docPratica.getTipologia();
if (IntPratica.class.getName().equals(className)) {
if (tipologia.equalsIgnoreCase(DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_ANNULLAMENTO_FASCICOLO)) {
sourceFileName = date.getTime() + "_annullamento_" + docPratica.getIntPraticaId()
@ -255,20 +235,19 @@ public class AllegatiUtil {
return sourceFileName;
}
private static FileEntry addOrUpdateFileEntry(long fileEntryId, Folder folder, long userId,
String sourceFileName, String title, String description, byte[] bytes,
ServiceContext serviceContext) throws SystemException, PortalException {
private static FileEntry addOrUpdateFileEntry(long fileEntryId, Folder folder, long userId, String sourceFileName,
String title, String description, byte[] bytes, ServiceContext serviceContext) throws SystemException,
PortalException {
String mimeType = MimeTypesUtil.getContentType(sourceFileName);
FileEntry fileEntry = null;
try {
fileEntry = DLAppLocalServiceUtil.getFileEntry(fileEntryId);
fileEntry = DLAppLocalServiceUtil.updateFileEntry(userId, fileEntry.getFileEntryId(),
sourceFileName, mimeType, title, description, StringPool.BLANK, false, bytes,
serviceContext);
fileEntry = DLAppLocalServiceUtil.updateFileEntry(userId, fileEntry.getFileEntryId(), sourceFileName,
mimeType, title, description, StringPool.BLANK, false, bytes, serviceContext);
} catch (PortalException e) {
fileEntry = DLAppLocalServiceUtil.addFileEntry(userId, folder.getRepositoryId(),
folder.getFolderId(), sourceFileName, mimeType, title, description, StringPool.BLANK,
bytes, serviceContext);
fileEntry = DLAppLocalServiceUtil.addFileEntry(userId, folder.getRepositoryId(), folder.getFolderId(),
sourceFileName, mimeType, title, description, StringPool.BLANK, bytes, serviceContext);
}
return fileEntry;
}

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

File diff soppresso perché troppo grande Load Diff

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

@ -69,14 +69,9 @@ public class SorteggioPraticaUtil {
private static final String FILE_ENTRY_TEMPLATE_SORTEGGIO = "Sorteggio";
/**
*
* Implementazione della procedura di sorteggio secondo i requisiti della Regione Siciliana.
*
* @author Manifattura Web Group per Regione Siciliana
* @param companyId
* @param dtSorteggio
* @throws PortalException
* @throws SystemException
*/
public static List<String> sorteggio(long companyId, Date dtSorteggio) throws PortalException, SystemException {
@ -84,22 +79,18 @@ public class SorteggioPraticaUtil {
if (lock.tryLock()) {
SimpleDateFormat sdf = new SimpleDateFormat(DATE_TIME_FORMAT);
esito.add("Sorteggio iniziato in data " + sdf.format(dtSorteggio) + ".<br><br>");
Map<String, List<IntPratica>> sorteggiabili = IntPraticaLocalServiceUtil.findSorteggiabiliNew(companyId,
dtSorteggio);
int numeroSorteggiabili = 0;
for (Map.Entry<String, List<IntPratica>> s : sorteggiabili.entrySet()) {
numeroSorteggiabili += s.getValue().size();
}
esito.add("<h1>" + numeroSorteggiabili + " pratiche sottoposte a sorteggio.</h1>");
SecureRandom rnd = new SecureRandom();
List<IntPratica> sorteggiate = new ArrayList<>();
for (Map.Entry<String, List<IntPratica>> s : sorteggiabili.entrySet()) {
String codiceProvincia = s.getKey();
List<IntPratica> elenco = s.getValue();
Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(companyId, codiceProvincia);
long numeroSorteggiate = (long) Math.ceil(0.1 * elenco.size());
String testoSorteggio;
@ -109,11 +100,9 @@ public class SorteggioPraticaUtil {
testoSorteggio = "sarà estratta 1 pratica";
}
esito.add("<h2><small>(" + sdf.format(new Date()) + ")</small> Provincia di "
+ provincia.getProvincia() + " " + elenco.size() + " pratiche, " + testoSorteggio
+ provincia.getProvincia() + StringPool.SPACE + elenco.size() + " pratiche, " + testoSorteggio
+ ".</h2><ol>");
Map<Integer, IntPratica> ordinate = new HashMap<>();
int chiave;
for (IntPratica pratica : elenco) {
do {
@ -122,18 +111,15 @@ public class SorteggioPraticaUtil {
ordinate.put(chiave, pratica);
}
TreeMap<Integer, IntPratica> mescolate = new TreeMap<Integer, IntPratica>(ordinate);
long contatore = 0;
for (Map.Entry<Integer, IntPratica> m : mescolate.entrySet()) {
IntPratica pratica = m.getValue();
long intPraticaId = pratica.getIntPraticaId();
DettPratica dettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(intPraticaId);
ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(dettPratica.getCompanyId());
serviceContext.setScopeGroupId(dettPratica.getGroupId());
serviceContext.setUserId(dettPratica.getUserId());
if (contatore++ < numeroSorteggiate) {
sorteggiate.add(pratica);
esito.add("<li>Sorteggiata: " + pratica.getNumeroProgetto() + " (id " + intPraticaId + ") del "
@ -141,7 +127,6 @@ public class SorteggioPraticaUtil {
} else {
pratica.setDtSorteggio(dtSorteggio);
IntPraticaLocalServiceUtil.updateIntPratica(pratica);
esito.add("<li>Non sorteggiata: " + pratica.getNumeroProgetto() + " (id " + intPraticaId
+ ") del " + sdf.format(pratica.getDtPratica()) + " (" + m.getKey() + ")</li>");
}
@ -152,9 +137,7 @@ public class SorteggioPraticaUtil {
saveSorteggio(companyId, sorteggiate, dtSorteggio);
}
esito.add("Sorteggio terminato in data " + sdf.format(new Date()) + ".<br><br>");
creaReportSorteggio(companyId, dtSorteggio, esito);
// Salvataggio data ultimo sorteggio
ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(companyId);
@ -162,10 +145,8 @@ public class SorteggioPraticaUtil {
serviceContext.setUserId(UserLocalServiceUtil.getDefaultUserId(companyId));
ConfigurazioneLocalServiceUtil.storeConfig(ConfigurazioneConstants.DATE_ULTIMO_SORTEGGIO,
sdf.format(dtSorteggio), serviceContext);
lock.unlock();
}
return esito;
}
@ -174,47 +155,39 @@ public class SorteggioPraticaUtil {
Role role = RoleLocalServiceUtil.getRole(companyId, RoleConstants.ADMINISTRATOR);
long userId = UserLocalServiceUtil.getRoleUsers(role.getRoleId(), 0, 1).get(0).getUserId();
Company company = CompanyLocalServiceUtil.getCompany(companyId);
Folder folderTemplate = DLAppLocalServiceUtil.getFolder(company.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, "Template");
FileEntry fileEntryTemplate = DLAppLocalServiceUtil.getFileEntry(folderTemplate.getGroupId(),
folderTemplate.getFolderId(), FILE_ENTRY_TEMPLATE_SORTEGGIO);
Folder folderReport = DLAppLocalServiceUtil.getFolder(company.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, FOLDER_SORTEGGIO);
StringBuilder sb = new StringBuilder(contenuto.size());
for (String riga : contenuto) {
sb.append(riga);
}
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("html", sb.toString());
ReportDto reportDto = new ReportDto();
reportDto.setFileEntryIds(new long[] { fileEntryTemplate.getFileEntryId() });
reportDto.setFolderId(folderReport.getFolderId());
reportDto.setFileName(reportFileName(companyId, dtSorteggio));
reportDto.setHeader(StringPool.BLANK);
reportDto.setHeaderHeight(1);
reportDto.setFooter(StringPool.BLANK);
reportDto.setFooterHeight(40);
reportDto.setParameters(parameters);
reportDto.setShowNumberOfPage(true);
reportDto.setType(ReportConstants.ReportType.VELOCITY_TO_PDF.toString());
String resourcePath = SorteggioPraticaUtil.class.getName().replaceAll("\\w+\\.", "../")
.replace(SorteggioPraticaUtil.class.getSimpleName(), "resource/asseverazioni");
reportDto.setPortalURL(SorteggioPraticaUtil.class.getResource(resourcePath).getPath());
ReportUtil.generateReport(companyId, userId, reportDto, null);
return null;
}
private static String reportFileName(long companyId, Date dtSorteggio) {
Calendar calSorteggio = DateUtils.toCalendar(dtSorteggio);
String anno = String.valueOf(calSorteggio.get(Calendar.YEAR));
int settimana = calSorteggio.get(Calendar.WEEK_OF_YEAR);
@ -222,75 +195,62 @@ public class SorteggioPraticaUtil {
}
private static String reportFileName(long companyId, String anno, int settimana) {
return "Sorteggio_" + settimana + "_" + anno + "_" + companyId;
return "Sorteggio_" + settimana + StringPool.UNDERLINE + anno + StringPool.UNDERLINE + companyId;
}
/**
* @author Manifattura Web Group per Regione Siciliana
*
* @param companyId
* @param pratiche
* Lista di pratiche sorteggiate
* @param dtSorteggio
* Data del sorteggio
* @throws PortalException
* @throws SystemException
*/
private static void saveSorteggio(long companyId, List<IntPratica> pratiche, Date dtSorteggio)
throws PortalException, SystemException {
long progressivoEstrazione = 1;
for (IntPratica pratica : pratiche) {
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(pratica.getTerritorioId());
Comune comune = ComuneLocalServiceUtil.getComune(territorio.getComuneId());
Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(),
comune.getCodiceProvincia());
DettPratica dettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(pratica
.getIntPraticaId());
String committente = StringPool.BLANK;
List<Soggetto> soggetti = SoggettoLocalServiceUtil.findByIntPratica_TipologiaSoggetto_Aggiuntivo_Rimosso(
pratica.getIntPraticaId(), TipoSoggettoUtil.COMMITTENTE, false, false);
if (soggetti.size() > 0) {
Soggetto soggetto = soggetti.get(0);
if (Validator.isNotNull(soggetto.getNome()) && Validator.isNotNull(soggetto.getCognome()))
committente = soggetto.getNome() + " " + soggetto.getCognome();
committente = soggetto.getNome() + StringPool.SPACE + soggetto.getCognome();
else if (Validator.isNotNull(soggetto.getDenominazione()))
committente = soggetto.getDenominazione();
else
committente = soggetto.getLegaleRap();
}
// anno, mese, settimana della data sorteggio
Calendar calSorteggio = Calendar.getInstance();
calSorteggio.setTime(dtSorteggio);
String anno = String.valueOf(calSorteggio.get(Calendar.YEAR));
String mese = String.format("%02d", calSorteggio.get(Calendar.MONTH) + 1);
int sett = calSorteggio.get(Calendar.WEEK_OF_YEAR);
ServiceContext sc = new ServiceContext();
sc.setCompanyId(dettPratica.getCompanyId());
sc.setScopeGroupId(dettPratica.getGroupId());
sc.setUserId(dettPratica.getUserId());
SorteggioLocalServiceUtil.addSorteggio(pratica.getIntPraticaId(), dettPratica.getDettPraticaId(), anno,
mese, sett, dtSorteggio, StringPool.BLANK, APERTO, StringPool.BLANK, progressivoEstrazione++,
pratica.getNumeroProgetto(), committente, comune.getDenominazione(), provincia.getProvincia(),
false, pratica.getIntPraticaId(), false, sc);
ControlloPratica controllo = ControlloPraticaLocalServiceUtil.addControlloPratica(pratica.getGroupId(),
pratica.getUserId(), pratica.getIntPraticaId(), dettPratica.getDettPraticaId(), true, sc);
long idTemplate = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(sc.getCompanyId(),
"conf.geniocivile.avviso.template.id.deposito.S");
AvvisoLocalServiceUtil.addAvviso(pratica.getIntPraticaId(), "Avviso di sorteggio", dtSorteggio,
AvvisoUtil.TIPO_AVVISO_DIRETTO, StatoPraticaConstants.SOTTOPOSTA_A_PARERE, idTemplate,
dettPratica.getDettPraticaId(), DettPratica.class.getName(), controllo.getControlloPraticaId(), sc);
IntPraticaLocalServiceUtil.updateIntPraticaSorteggio(pratica.getIntPraticaId(), dtSorteggio,
StatoPraticaConstants.SOTTOPOSTA_A_PARERE);
IntPraticaLocalServiceUtil.reIndexFascicolo(pratica, companyId);
@ -301,13 +261,10 @@ public class SorteggioPraticaUtil {
throws PortalException, SystemException {
Company company = CompanyLocalServiceUtil.getCompany(companyId);
Folder folder = DLAppLocalServiceUtil.getFolder(company.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, FOLDER_SORTEGGIO);
String fileName = reportFileName(companyId, dtSorteggio);
FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(groupId, folder.getFolderId(), fileName);
return fileEntry;
}
@ -315,11 +272,9 @@ public class SorteggioPraticaUtil {
throws PortalException, SystemException {
Company company = CompanyLocalServiceUtil.getCompany(companyId);
Folder folder = DLAppLocalServiceUtil.getFolder(company.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, FOLDER_SORTEGGIO);
String fileName = reportFileName(companyId, anno, settimana);
return DLAppLocalServiceUtil.getFileEntry(groupId, folder.getFolderId(), fileName);
}
}

85
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/hook/CfOrganizationMembershipPolicy.java

@ -1,85 +0,0 @@
package it.tref.liferay.portos.bo.hook;
import it.tref.liferay.portos.bo.shared.util.Constants;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
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.model.Company;
import com.liferay.portal.model.Group;
import com.liferay.portal.model.Organization;
import com.liferay.portal.model.User;
import com.liferay.portal.security.membershippolicy.BaseOrganizationMembershipPolicy;
import com.liferay.portal.service.CompanyLocalServiceUtil;
import com.liferay.portal.service.GroupLocalServiceUtil;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portlet.asset.model.AssetCategory;
import com.liferay.portlet.asset.model.AssetTag;
public class CfOrganizationMembershipPolicy extends BaseOrganizationMembershipPolicy {
private static Log _log = LogFactoryUtil.getLog(CfOrganizationMembershipPolicy.class);
@Override
public void checkMembership(long[] userIds, long[] addOrganizationIds, long[] removeOrganizationIds) {
}
@Override
public boolean isMembershipAllowed(long userId, long groupId) {
try {
Group group = GroupLocalServiceUtil.getGroup(groupId);
Company company = CompanyLocalServiceUtil.getCompany(group.getCompanyId());
String allowedCF = (String) company.getExpandoBridge().getAttribute(
Constants.CF_ORGANIZATION_MEMBERSHIP, false);
List<String> allowedCFs = Arrays.asList(allowedCF.split("\\,"));
User user = UserLocalServiceUtil.getUser(userId);
if (allowedCFs.contains(user.getScreenName())) {
return true;
}
} catch (PortalException | SystemException e) {
_log.error(e, e);
}
return false;
}
@Override
public boolean isMembershipRequired(long userId, long groupId) {
return false;
}
@Override
public boolean isRoleAllowed(long userId, long groupId, long roleId) {
return true;
}
@Override
public boolean isRoleRequired(long userId, long groupId, long roleId) {
return false;
}
@Override
public void propagateMembership(long[] userIds, long[] addOrganizationIds, long[] removeOrganizationIds) {
}
@Override
public void verifyPolicy(Organization organization) {
}
@Override
public void verifyPolicy(Organization organization, Organization oldOrganization,
List<AssetCategory> oldAssetCategories, List<AssetTag> oldAssetTags,
Map<String, Serializable> oldExpandoAttributes) {
}
}

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

@ -1,13 +1,13 @@
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under the terms of the
* GNU Lesser General Public License as published by the Free Software Foundation; either version
* 2.1 of the License, or (at your option) any later version.
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library 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
* Lesser General Public License for more details.
* This library 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 Lesser General Public License for more
* details.
*/
package it.tref.liferay.portos.bo.model.impl;
@ -28,90 +28,69 @@ import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.Validator;
/**
* The extended model implementation for the Collaudo service. Represents a row
* in the &quot;portos_bo_Collaudo&quot; database table, with each column mapped
* to a property of this class.
* The extended model implementation for the Collaudo service. Represents a row in the &quot;portos_bo_Collaudo&quot;
* database table, with each column mapped to a property of this class.
*
* <p>
* Helper methods and all application logic should be put in this class.
* Whenever methods are added, rerun ServiceBuilder to copy their definitions
* into the {@link it.tref.liferay.portos.bo.model.Collaudo} interface.
* Helper methods and all application logic should be put in this class. Whenever methods are added, rerun
* ServiceBuilder to copy their definitions into the {@link it.tref.liferay.portos.bo.model.Collaudo} interface.
* </p>
*
* @author Davide Barbagallo, 3F Consulting
*/
public class CollaudoImpl extends CollaudoBaseImpl {
/*
* NOTE FOR DEVELOPERS:
*
* Never reference this class directly. All methods that expect a collaudo
* model instance should use the {@link
* it.tref.liferay.portos.bo.model.Collaudo} interface instead.
* NOTE FOR DEVELOPERS: Never reference this class directly. All methods that expect a collaudo model instance
* should use the {@link it.tref.liferay.portos.bo.model.Collaudo} interface instead.
*/
/**
*
*/
private static final long serialVersionUID = -6015747485641141721L;
private static final Log _log = LogFactoryUtil.getLog(CollaudoImpl.class);
public CollaudoImpl() {
}
@Override
public String getTitle(Locale locale) {
StringBuilder sb = new StringBuilder();
try {
IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(getIntPraticaId());
// sb.append("Progetto ");
if (AzioniPraticheUtil.isDeposito(intPratica.getIntPraticaId())) {
sb.append("Deposito ");
} else if (AzioniPraticheUtil.isAutorizzazione(intPratica.getIntPraticaId())) {
sb.append("Autorizzazione ");
}
sb.append("n. ");
if (Validator.isNotNull(getProtocollo())) {
sb.append(intPratica.getNumeroProgetto());
// TODO da decidere che data, per adesso si mette quella di
// creazione il numero protocollo
// sbagliato dovrebbe essere il primo
sb.append(" del ");
sb.append(FastDateFormatFactoryUtil.getDate(locale).format(intPratica.getDtPratica()));
sb.append(StringPool.SPACE + StringPool.DASH + StringPool.SPACE);
sb.append(" id ");
sb.append(intPratica.getIntPraticaId());
// TODO da decidere che data, per adesso si mette quella di creazione il numero protocollo sbagliato
// dovrebbe essere il primo
sb.append(intPratica.getNumeroProgetto()).append(" del ")
.append(FastDateFormatFactoryUtil.getDate(locale).format(intPratica.getDtPratica()))
.append(StringPool.SPACE).append(StringPool.DASH).append(StringPool.SPACE).append(" id ")
.append(intPratica.getIntPraticaId());
} else {
if (Validator.isNotNull(intPratica.getNumeroProgetto())) {
sb.append(intPratica.getNumeroProgetto());
sb.append(StringPool.SPACE + StringPool.DASH + StringPool.SPACE);
sb.append(intPratica.getNumeroProgetto()).append(StringPool.SPACE).append(StringPool.DASH)
.append(StringPool.SPACE);
}
sb.append(getCollaudoId());
sb.append(" (Temporaneo) ");
sb.append(StringPool.SPACE + StringPool.DASH + StringPool.SPACE);
sb.append(" id ");
sb.append(intPratica.getIntPraticaId());
sb.append(getCollaudoId()).append(" (Temporaneo) ").append(StringPool.SPACE).append(StringPool.DASH)
.append(StringPool.SPACE).append(" id ").append(intPratica.getIntPraticaId());
}
} catch (PortalException e) {
_log.error(e, e);
} catch (SystemException e) {
} catch (PortalException | SystemException e) {
_log.error(e, e);
}
return sb.toString();
}
@Override
public String getTitle() {
return getTitle(LocaleUtil.getSiteDefault());
}
@Override
public String getFullDescription() {
return getTitle();

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

File diff soppresso perché troppo grande Load Diff

6
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/model/listener/ControlloPraticaModelListener.java

@ -19,21 +19,15 @@ public class ControlloPraticaModelListener extends BaseModelListener<ControlloPr
public void onAfterUpdate(ControlloPratica model) throws ModelListenerException {
try {
Indexer intIndexer = IndexerRegistryUtil.getIndexer(IntPratica.class);
Indexer controlloIndexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class);
intIndexer.delete(model.getCompanyId(), model.getUuid());
intIndexer.reindex(IntPratica.class.getName(), model.getIntPraticaId());
controlloIndexer.delete(model.getCompanyId(), model.getUuid());
controlloIndexer.reindex(ControlloPratica.class.getName(), model.getControlloPraticaId());
} catch (SearchException e) {
_log.error(e, e);
}
super.onAfterUpdate(model);
}
}

8
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/model/listener/DettPraticaModelListener.java

@ -25,23 +25,17 @@ public class DettPraticaModelListener extends BaseModelListener<DettPratica> {
public void onAfterUpdate(DettPratica model) throws ModelListenerException {
try {
Indexer indexer = IndexerRegistryUtil.getIndexer(IntPratica.class);
indexer.reindex(IntPratica.class.getName(), model.getIntPraticaId());
if (_log.isDebugEnabled()) {
_log.debug("DettPraticaModelListener - Chiamato Reindex IntPraticaId : "
+ model.getIntPraticaId());
_log.debug("DettPraticaModelListener - Chiamato Reindex IntPraticaId : " + model.getIntPraticaId());
}
if (model.getStatus() == WorkflowConstants.STATUS_APPROVED) {
IntPraticaLocalServiceUtil.updateModifiedDate(model.getIntPraticaId(), new Date());
}
} catch (SearchException | NoSuchIntPraticaException | SystemException e) {
_log.error(e, e);
}
super.onAfterUpdate(model);
}
}

6
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/model/listener/DocPraticaModelListener.java

@ -19,18 +19,14 @@ public class DocPraticaModelListener extends BaseModelListener<DocPratica> {
public void onAfterUpdate(DocPratica model) throws ModelListenerException {
try {
Indexer indexer = IndexerRegistryUtil.getIndexer(IntPratica.class);
indexer.reindex(IntPratica.class.getName(), model.getIntPraticaId());
if (_log.isDebugEnabled()) {
_log.debug("DettPraticaModelListener - Chiamato Reindex IntPraticaId : "
+ model.getIntPraticaId());
_log.debug("DettPraticaModelListener - Chiamato Reindex IntPraticaId : " + model.getIntPraticaId());
}
} catch (SearchException e) {
_log.error(e, e);
}
super.onAfterUpdate(model);
}
}

12
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/model/listener/IntPraticaModelListener.java

@ -27,19 +27,14 @@ public class IntPraticaModelListener extends BaseModelListener<IntPratica> {
public void onAfterUpdate(IntPratica model) throws ModelListenerException {
try {
Indexer intIndexer = IndexerRegistryUtil.getIndexer(IntPratica.class);
Indexer controlloIndexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class);
intIndexer.delete(model.getCompanyId(), model.getUuid());
intIndexer.reindex(IntPratica.class.getName(), model.getIntPraticaId());
DynamicQuery queryCP = DynamicQueryFactoryUtil.forClass(ControlloPratica.class);
queryCP.add(RestrictionsFactoryUtil.eq("intPraticaId", model.getIntPraticaId()));
List<ControlloPratica> appList = ControlloPraticaLocalServiceUtil.dynamicQuery(queryCP,
QueryUtil.ALL_POS, QueryUtil.ALL_POS);
if (appList != null && !appList.isEmpty()) {
for (ControlloPratica controlloPratica : appList) {
controlloIndexer.delete(model.getCompanyId(), controlloPratica.getUuid());
@ -47,14 +42,9 @@ public class IntPraticaModelListener extends BaseModelListener<IntPratica> {
controlloPratica.getControlloPraticaId());
}
}
} catch (SearchException e) {
_log.error(e, e);
} catch (SystemException e) {
} catch (SearchException | SystemException e) {
_log.error(e, e);
}
super.onAfterUpdate(model);
}
}

19
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/model/listener/KaleoInstanceModelListener.java

@ -19,22 +19,17 @@ public class KaleoInstanceModelListener extends BaseModelListener<KaleoInstance>
public void onAfterUpdate(KaleoInstance model) throws ModelListenerException {
try {
if (model.getClassName().equals(ControlloPratica.class.getName())) {
Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class);
indexer.reindex(ControlloPratica.class.getName(), model.getClassPK());
if (_log.isDebugEnabled()) {
_log.debug("KaleoInstanceModelListener - Chiamato Reindex ControlloPraticaId : "
+ model.getClassPK());
}
}
} catch (SearchException e) {
_log.error(e, e);
}
super.onAfterUpdate(model);
}
@ -55,28 +50,23 @@ public class KaleoInstanceModelListener extends BaseModelListener<KaleoInstance>
public void onAfterRemove(KaleoInstance model) throws ModelListenerException {
try {
if (model.getClassName().equals(ControlloPratica.class.getName())) {
Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class);
indexer.reindex(ControlloPratica.class.getName(), model.getClassPK());
if (_log.isDebugEnabled()) {
_log.debug("KaleoInstanceModelListener - Chiamato Reindex ControlloPraticaId : "
+ model.getClassPK());
}
}
} catch (SearchException e) {
_log.error(e, e);
}
super.onAfterRemove(model);
}
@Override
public void onAfterRemoveAssociation(Object classPK, String associationClassName,
Object associationClassPK) throws ModelListenerException {
public void onAfterRemoveAssociation(Object classPK, String associationClassName, Object associationClassPK)
throws ModelListenerException {
super.onAfterRemoveAssociation(classPK, associationClassName, associationClassPK);
}
@ -101,8 +91,8 @@ public class KaleoInstanceModelListener extends BaseModelListener<KaleoInstance>
}
@Override
public void onBeforeRemoveAssociation(Object classPK, String associationClassName,
Object associationClassPK) throws ModelListenerException {
public void onBeforeRemoveAssociation(Object classPK, String associationClassName, Object associationClassPK)
throws ModelListenerException {
super.onBeforeRemoveAssociation(classPK, associationClassName, associationClassPK);
}
@ -112,5 +102,4 @@ public class KaleoInstanceModelListener extends BaseModelListener<KaleoInstance>
super.onBeforeUpdate(model);
}
}

23
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/model/listener/KaleoInstanceTokenModelListener.java

@ -1,7 +1,5 @@
package it.tref.liferay.portos.bo.model.listener;
import java.util.Date;
import it.tref.liferay.portos.bo.model.ControlloPratica;
import it.tref.liferay.portos.bo.model.DettPratica;
import it.tref.liferay.portos.bo.model.IntPratica;
@ -10,6 +8,8 @@ import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.shared.util.TipoIntegrazioneUtil;
import java.util.Date;
import com.liferay.counter.service.CounterLocalServiceUtil;
import com.liferay.portal.ModelListenerException;
import com.liferay.portal.kernel.exception.PortalException;
@ -32,22 +32,17 @@ public class KaleoInstanceTokenModelListener extends BaseModelListener<KaleoInst
public void onAfterUpdate(KaleoInstanceToken model) throws ModelListenerException {
try {
if (model.getClassName().equals(ControlloPratica.class.getName())) {
Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class);
indexer.reindex(ControlloPratica.class.getName(), model.getClassPK());
if (_log.isDebugEnabled()) {
_log.debug("KaleoInstanceTokenModelListener - Chiamato Reindex ControlloPraticaId : "
+ model.getClassPK());
}
}
} catch (SearchException e) {
_log.error(e, e);
}
super.onAfterUpdate(model);
}
@ -61,6 +56,7 @@ public class KaleoInstanceTokenModelListener extends BaseModelListener<KaleoInst
@Override
public void onAfterCreate(KaleoInstanceToken model) throws ModelListenerException {
ControlloPratica cp;
try {
cp = ControlloPraticaLocalServiceUtil.getControlloPratica(model.getClassPK());
@ -69,12 +65,12 @@ public class KaleoInstanceTokenModelListener extends BaseModelListener<KaleoInst
// TODO Auto-generated catch block
e.printStackTrace();
}
// TODO Auto-generated method stub
super.onAfterCreate(model);
}
private void gestioneWFVarianti(ControlloPratica cp, KaleoInstanceToken model) {
try {
DettPratica dettPratica = DettPraticaLocalServiceUtil.getDettPratica(cp.getDettPraticaId());
if (dettPratica.getTipoIntegrazione().equals(TipoIntegrazioneUtil.VARIANTE)
@ -91,7 +87,6 @@ public class KaleoInstanceTokenModelListener extends BaseModelListener<KaleoInst
} else {
_log.info("gestioneWFVarianti - statusByuserId determinato =" + statusByuserId);
}
long kaleoTaskInstanceTokenID = CounterLocalServiceUtil
.increment("com.liferay.counter.model.Counter");
_log.info("kaleoTaskInstanceTokenID=" + kaleoTaskInstanceTokenID);
@ -116,38 +111,29 @@ public class KaleoInstanceTokenModelListener extends BaseModelListener<KaleoInst
+ x.getKaleoTaskInstanceTokenId());
_log.info("gestioneWFVarianti - correttamente eseguito - ControlloPraticaId = "
+ cp.getControlloPraticaId());
// ///////////////////////////////////////////////////////////////////
}
} catch (Exception e) {
_log.error(
"gestioneWFVarianti - Errore in gestioneWFVarianti - dettaPratiacaId="
+ cp.getDettPraticaId(), e);
// throw e;
}
}
@Override
public void onAfterRemove(KaleoInstanceToken model) throws ModelListenerException {
try {
if (model.getClassName().equals(ControlloPratica.class.getName())) {
Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class);
indexer.reindex(ControlloPratica.class.getName(), model.getClassPK());
if (_log.isDebugEnabled()) {
_log.debug("KaleoInstanceTokenModelListener - Chiamato Reindex ControlloPraticaId : "
+ model.getClassPK());
}
}
} catch (SearchException e) {
_log.error(e, e);
}
super.onAfterRemove(model);
}
@ -195,5 +181,4 @@ public class KaleoInstanceTokenModelListener extends BaseModelListener<KaleoInst
// TODO Auto-generated method stub
super.onBeforeUpdate(model);
}
}

20
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/model/listener/KaleoLogModelListener.java

@ -23,30 +23,22 @@ public class KaleoLogModelListener extends BaseModelListener<KaleoLog> {
public void onAfterCreate(KaleoLog model) throws ModelListenerException {
try {
long kaleoInstanceTokenId = model.getKaleoInstanceTokenId();
KaleoInstanceToken instanceToken = KaleoInstanceTokenLocalServiceUtil
.fetchKaleoInstanceToken(kaleoInstanceTokenId);
if (Validator.isNotNull(instanceToken)) {
if (instanceToken.getClassName().equals(ControlloPratica.class.getName())) {
Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class);
indexer.reindex(ControlloPratica.class.getName(), instanceToken.getClassPK());
if (_log.isDebugEnabled()) {
_log.debug("KaleoLogModelListener - Chiamato Reindex ControlloPraticaId : "
+ instanceToken.getClassPK());
}
}
}
} catch (SearchException e) {
_log.error(e, e);
} catch (SystemException e) {
} catch (SearchException | SystemException e) {
_log.error(e, e);
}
super.onAfterUpdate(model);
}
@ -62,30 +54,22 @@ public class KaleoLogModelListener extends BaseModelListener<KaleoLog> {
public void onAfterRemove(KaleoLog model) throws ModelListenerException {
try {
long kaleoInstanceTokenId = model.getKaleoInstanceTokenId();
KaleoInstanceToken instanceToken = KaleoInstanceTokenLocalServiceUtil
.fetchKaleoInstanceToken(kaleoInstanceTokenId);
if (Validator.isNotNull(instanceToken)) {
if (instanceToken.getClassName().equals(ControlloPratica.class.getName())) {
Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class);
indexer.reindex(ControlloPratica.class.getName(), instanceToken.getClassPK());
if (_log.isDebugEnabled()) {
_log.debug("KaleoLogModelListener - Chiamato Reindex ControlloPraticaId : "
+ instanceToken.getClassPK());
}
}
}
} catch (SearchException e) {
_log.error(e, e);
} catch (SystemException e) {
} catch (SearchException | SystemException e) {
_log.error(e, e);
}
super.onAfterRemove(model);
}

25
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/model/listener/KaleoTaskInstanceTokenModelListener.java

@ -19,22 +19,16 @@ public class KaleoTaskInstanceTokenModelListener extends BaseModelListener<Kaleo
public void onAfterUpdate(KaleoTaskInstanceToken model) throws ModelListenerException {
try {
if (model.getClassName().equals(ControlloPratica.class.getName())) {
Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class);
indexer.reindex(ControlloPratica.class.getName(), model.getClassPK());
if (_log.isDebugEnabled()) {
_log.debug("KaleoTaskInstanceToken - Chiamato Reindex ControlloPraticaId : "
+ model.getClassPK());
_log.debug("KaleoTaskInstanceToken - Chiamato Reindex ControlloPraticaId : " + model.getClassPK());
}
}
} catch (SearchException e) {
_log.error(e, e);
}
super.onAfterUpdate(model);
}
@ -57,28 +51,22 @@ public class KaleoTaskInstanceTokenModelListener extends BaseModelListener<Kaleo
public void onAfterRemove(KaleoTaskInstanceToken model) throws ModelListenerException {
try {
if (model.getClassName().equals(ControlloPratica.class.getName())) {
Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class);
indexer.reindex(ControlloPratica.class.getName(), model.getClassPK());
if (_log.isDebugEnabled()) {
_log.debug("KaleoTaskInstanceToken - Chiamato Reindex ControlloPraticaId : "
+ model.getClassPK());
_log.debug("KaleoTaskInstanceToken - Chiamato Reindex ControlloPraticaId : " + model.getClassPK());
}
}
} catch (SearchException e) {
_log.error(e, e);
}
super.onAfterRemove(model);
}
@Override
public void onAfterRemoveAssociation(Object classPK, String associationClassName,
Object associationClassPK) throws ModelListenerException {
public void onAfterRemoveAssociation(Object classPK, String associationClassName, Object associationClassPK)
throws ModelListenerException {
// TODO Auto-generated method stub
super.onAfterRemoveAssociation(classPK, associationClassName, associationClassPK);
@ -107,8 +95,8 @@ public class KaleoTaskInstanceTokenModelListener extends BaseModelListener<Kaleo
}
@Override
public void onBeforeRemoveAssociation(Object classPK, String associationClassName,
Object associationClassPK) throws ModelListenerException {
public void onBeforeRemoveAssociation(Object classPK, String associationClassName, Object associationClassPK)
throws ModelListenerException {
// TODO Auto-generated method stub
super.onBeforeRemoveAssociation(classPK, associationClassName, associationClassPK);
@ -120,5 +108,4 @@ public class KaleoTaskInstanceTokenModelListener extends BaseModelListener<Kaleo
// TODO Auto-generated method stub
super.onBeforeUpdate(model);
}
}

6
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/model/listener/SoggettoModelListener.java

@ -19,18 +19,14 @@ public class SoggettoModelListener extends BaseModelListener<Soggetto> {
public void onAfterUpdate(Soggetto model) throws ModelListenerException {
try {
Indexer indexer = IndexerRegistryUtil.getIndexer(IntPratica.class);
indexer.reindex(IntPratica.class.getName(), model.getIntPraticaId());
if (_log.isDebugEnabled()) {
_log.debug("DettPraticaModelListener - Chiamato Reindex IntPraticaId : "
+ model.getIntPraticaId());
_log.debug("DettPraticaModelListener - Chiamato Reindex IntPraticaId : " + model.getIntPraticaId());
}
} catch (SearchException e) {
_log.error(e, e);
}
super.onAfterUpdate(model);
}
}

32
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/AllegatiManualiPortlet.java

@ -3,8 +3,6 @@ package it.tref.liferay.portos.bo.portlet;
import it.tref.liferay.portos.bo.model.AllegatoManuale;
import it.tref.liferay.portos.bo.service.AllegatoManualeLocalServiceUtil;
import it.tref.liferay.portos.bo.service.AllegatoManualeServiceUtil;
import it.tref.liferay.portos.bo.shared.util.PortletKeys;
import it.tref.liferay.portos.bo.util.FilesImporter;
import java.io.File;
import java.io.IOException;
@ -22,7 +20,6 @@ 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.portlet.PortletResponseUtil;
import com.liferay.portal.kernel.repository.model.FileEntry;
import com.liferay.portal.kernel.servlet.HttpHeaders;
import com.liferay.portal.kernel.servlet.SessionErrors;
@ -48,6 +45,7 @@ public class AllegatiManualiPortlet extends MVCPortlet {
public void uploadAllegatoManuale(ActionRequest actionRequest, ActionResponse actionResponse)
throws PortalException, SystemException {
try {
UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest);
ServiceContext serviceContext = ServiceContextFactory.getInstance(uploadRequest);
@ -56,7 +54,6 @@ public class AllegatiManualiPortlet extends MVCPortlet {
String descrizione = ParamUtil.getString(uploadRequest, "descrizione");
String sourceFileName = uploadRequest.getFileName("docFile");
File file = uploadRequest.getFile("docFile");
if (Validator.isNotNull(sourceFileName) && file != null) {
// validazione: solo alcune estensioni
String ext = FileUtil.getExtension(sourceFileName);
@ -70,7 +67,6 @@ public class AllegatiManualiPortlet extends MVCPortlet {
} else {
SessionErrors.add(actionRequest, "error.geniocivilefe.allegato.manuale.is.request");
}
if (SessionErrors.isEmpty(actionRequest)) {
if (Validator.isNotNull(intPraticaId) && Validator.isNotNull(dettPraticaId)) {
byte[] content = FileUtil.getBytes(file);
@ -84,10 +80,10 @@ public class AllegatiManualiPortlet extends MVCPortlet {
_log.error("Error", e);
throw new SystemException(e);
}
}
public void deleteAllegatoManuale(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long allegatoManualeId = ParamUtil.getLong(actionRequest, "allegatoManualeId");
AllegatoManualeServiceUtil.deleteAllegatoManuale(allegatoManualeId);
}
@ -97,56 +93,34 @@ public class AllegatiManualiPortlet extends MVCPortlet {
PortletException {
String id = resourceRequest.getResourceID();
try {
if ("downloadAll".equals(id)) {
long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId");
List<AllegatoManuale> docs = AllegatoManualeServiceUtil.findByIntPratica(intPraticaId);
ZipWriter zipWriter = ZipWriterFactoryUtil.getZipWriter();
for (AllegatoManuale doc : docs) {
InputStream inputStream = null;
try {
FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(doc.getFileEntryId());
inputStream = DLFileEntryLocalServiceUtil.getFileAsStream(fileEntry.getFileEntryId(),
fileEntry.getVersion(), false);
String name = fileEntry.getTitle() + StringPool.PERIOD + fileEntry.getExtension();
zipWriter.addEntry(name, inputStream);
} finally {
StreamUtil.cleanUp(inputStream);
}
}
resourceResponse.reset();
File file = zipWriter.getFile();
byte[] data = Files.readAllBytes(file.toPath());
resourceResponse.setContentType(ContentTypes.APPLICATION_ZIP);
resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate");
resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"" + file.getName() + "\"");
"attachment; filename=\"" + file.getName() + StringPool.QUOTE);
resourceResponse.setContentLength(data.length);
resourceResponse.getPortletOutputStream().write(data);
resourceResponse.getPortletOutputStream().flush();
resourceResponse.getPortletOutputStream().close();
} else if ("importFile".equals(id)) {
long classPk = ParamUtil.getLong(resourceRequest, "classPk");
String className = ParamUtil.getString(resourceRequest, "className");
FilesImporter.importaFile(classPk, className);
PortletResponseUtil
.write(resourceResponse,
"<p style='margin-bottom:20px'><strong>Completato</strong></p><a href='#' class='btn btn-success' onclick=\"Liferay.Portlet.refresh('#p_p_id_"
+ PortletKeys.FASCICOLOFE + "_')\">Refresh</a>");
} else {
super.serveResource(resourceRequest, resourceResponse);
}

26
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/AmministrazionePortlet.java

@ -45,6 +45,7 @@ public class AmministrazionePortlet extends MVCPortlet {
private static final Log _log = LogFactoryUtil.getLog(AmministrazionePortlet.class);
public void saveProvincia(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long provinciaId = ParamUtil.getLong(actionRequest, "provinciaId");
String codiceProvincia = ParamUtil.getString(actionRequest, "codiceProvincia");
String provincia = ParamUtil.getString(actionRequest, "provincia");
@ -73,6 +74,7 @@ public class AmministrazionePortlet extends MVCPortlet {
}
public void saveConfigScheduler(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
try {
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
serviceContext.setScopeGroupId(-1L);
@ -147,21 +149,21 @@ public class AmministrazionePortlet extends MVCPortlet {
}
public void saveConfigTemplate(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
try {
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
final String _PREFIX_START_CONFIGURAZIONE = "configurazione--";
final String _PREFIX_END_CONFIGURAZIONE = "--";
final String _PREFIX_END_CONFIGURAZIONE = StringPool.DOUBLE_DASH;
Enumeration<String> enu = actionRequest.getParameterNames();
while (enu.hasMoreElements()) {
String name = enu.nextElement();
if (!name.startsWith(_PREFIX_START_CONFIGURAZIONE) && !name.endsWith("--")) {
continue;
}
if (name.startsWith(_PREFIX_START_CONFIGURAZIONE) && name.endsWith(_PREFIX_END_CONFIGURAZIONE)) {
String key = name.substring(_PREFIX_START_CONFIGURAZIONE.length(), name.length()
- _PREFIX_END_CONFIGURAZIONE.length());
String value = ParamUtil.getString(actionRequest, name);
ConfigurazioneServiceUtil.storeConfig(key, value, serviceContext);
}
}
String redirect = ParamUtil.getString(actionRequest, "redirect");
if (Validator.isNull(redirect)) {
actionResponse.setRenderParameter("tabs1", "parametri");
@ -173,6 +175,7 @@ public class AmministrazionePortlet extends MVCPortlet {
}
public void saveComune(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long comuneId = ParamUtil.getLong(actionRequest, "comuneId");
String codiceProvincia = ParamUtil.getString(actionRequest, "codiceProvincia");
String codiceComune = ParamUtil.getString(actionRequest, "codiceComune");
@ -206,6 +209,7 @@ public class AmministrazionePortlet extends MVCPortlet {
}
public void saveTerritorio(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long territorioId = ParamUtil.getLong(actionRequest, "territorioId");
long comuneId = ParamUtil.getLong(actionRequest, "comuneId");
long groupId = ParamUtil.getLong(actionRequest, "groupId");
@ -236,6 +240,7 @@ public class AmministrazionePortlet extends MVCPortlet {
}
public void deleteComune(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long comuneId = ParamUtil.getLong(actionRequest, "comuneId");
if (comuneId > 0) {
ComuneLocalServiceUtil.deleteComune(comuneId);
@ -243,6 +248,7 @@ public class AmministrazionePortlet extends MVCPortlet {
}
public void deleteComunes(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long[] deleteComuneIds = ParamUtil.getLongValues(actionRequest, "deleteComuneIds");
for (long deleteComuneId : deleteComuneIds) {
ComuneLocalServiceUtil.deleteComune(deleteComuneId);
@ -251,6 +257,7 @@ public class AmministrazionePortlet extends MVCPortlet {
}
public void deleteProvincia(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long provinciaId = ParamUtil.getLong(actionRequest, "provinciaId");
if (provinciaId > 0) {
ProvinciaLocalServiceUtil.deleteProvincia(provinciaId);
@ -258,6 +265,7 @@ public class AmministrazionePortlet extends MVCPortlet {
}
public void deleteProvincias(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long[] deleteProvinciaIds = ParamUtil.getLongValues(actionRequest, "deleteProvinciaIds");
for (long deleteProvinciaId : deleteProvinciaIds) {
ProvinciaLocalServiceUtil.deleteProvincia(deleteProvinciaId);
@ -266,6 +274,7 @@ public class AmministrazionePortlet extends MVCPortlet {
}
public void deleteTerritorio(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long territorioId = ParamUtil.getLong(actionRequest, "territorioId");
if (territorioId > 0) {
ComuneLocalServiceUtil.deleteComune(territorioId);
@ -273,6 +282,7 @@ public class AmministrazionePortlet extends MVCPortlet {
}
public void importProvincias(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest);
ThemeDisplay themeDisplay = (ThemeDisplay) uploadPortletRequest.getAttribute(WebKeys.THEME_DISPLAY);
String delimiter = ParamUtil.getString(uploadPortletRequest, "delimiter");
@ -326,6 +336,7 @@ public class AmministrazionePortlet extends MVCPortlet {
}
public void importComunes(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest);
ThemeDisplay themeDisplay = (ThemeDisplay) uploadPortletRequest.getAttribute(WebKeys.THEME_DISPLAY);
String delimiter = ParamUtil.getString(uploadPortletRequest, "delimiter");
@ -357,21 +368,22 @@ public class AmministrazionePortlet extends MVCPortlet {
_log.error("Il comune italiano non ha un codice istat assegnato e non sarà inserito: "
+ csvRecord);
} else {
boolean isProvincia = Validator.isNotNull(provincia) && provincia.equals("1") ? true : false;
boolean isProvincia = Validator.isNotNull(provincia) && provincia.equals("1");
Comune comuneO = ComuneLocalServiceUtil
.fetchByC_CB(themeDisplay.getCompanyId(), codiceBelfiore);
if (comuneO == null)
comuneO = ComuneLocalServiceUtil.fetchByC_CI(themeDisplay.getCompanyId(), codiceIstat);
if (comuneO == null) {
_log.debug("Il comune non esiste e verra' creato: " + csvRecord);
if (nazioneEstera)
if (nazioneEstera) {
ComuneLocalServiceUtil.addComune(themeDisplay.getUserId(), codiceProvincia,
codiceComune, codiceIstat, codiceBelfiore, denominazione, false, true,
StringPool.BLANK, StringPool.BLANK, serviceContext);
else
} else {
ComuneLocalServiceUtil.addComune(themeDisplay.getUserId(), codiceProvincia,
codiceComune, codiceIstat, codiceBelfiore, denominazione, isProvincia, false,
StringPool.BLANK, StringPool.BLANK, serviceContext);
}
} else {
_log.debug("Il comune esiste e verra' aggiornato: " + csvRecord);
ComuneLocalServiceUtil.updateComune(themeDisplay.getUserId(), comuneO.getPrimaryKey(),

46
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/DocAggiuntivaPortlet.java

@ -3,8 +3,6 @@ package it.tref.liferay.portos.bo.portlet;
import it.tref.liferay.portos.bo.model.DocAggiuntiva;
import it.tref.liferay.portos.bo.service.DocAggiuntivaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DocAggiuntivaServiceUtil;
import it.tref.liferay.portos.bo.shared.util.PortletKeys;
import it.tref.liferay.portos.bo.util.FilesImporter;
import java.io.File;
import java.io.IOException;
@ -22,7 +20,6 @@ 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.portlet.PortletResponseUtil;
import com.liferay.portal.kernel.repository.model.FileEntry;
import com.liferay.portal.kernel.servlet.HttpHeaders;
import com.liferay.portal.kernel.servlet.SessionErrors;
@ -46,8 +43,9 @@ public class DocAggiuntivaPortlet extends MVCPortlet {
private Log _log = LogFactoryUtil.getLog(DocAggiuntivaPortlet.class);
public void uploadDocAggiuntiva(ActionRequest actionRequest, ActionResponse actionResponse)
throws PortalException, SystemException {
public void uploadDocAggiuntiva(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException,
SystemException {
try {
UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest);
ServiceContext serviceContext = ServiceContextFactory.getInstance(uploadRequest);
@ -57,7 +55,6 @@ public class DocAggiuntivaPortlet extends MVCPortlet {
boolean feVisible = ParamUtil.getBoolean(uploadRequest, "feVisible");
String sourceFileName = uploadRequest.getFileName("docFile");
File file = uploadRequest.getFile("docFile");
if (Validator.isNotNull(sourceFileName) && file != null) {
// lunghezza fissata a 200
if (sourceFileName.length() > 200) {
@ -66,7 +63,6 @@ public class DocAggiuntivaPortlet extends MVCPortlet {
} else {
SessionErrors.add(actionRequest, "error.geniocivilefe.pagamento.allegato.is.request");
}
if (!SessionErrors.isEmpty(actionRequest)) {
PortalUtil.copyRequestParameters(actionRequest, actionResponse);
} else {
@ -75,39 +71,32 @@ public class DocAggiuntivaPortlet extends MVCPortlet {
DocAggiuntivaLocalServiceUtil.addDocAggiuntiva(serviceContext.getUserId(), intPraticaId,
dettPraticaId, descrizione, feVisible, content, sourceFileName, serviceContext);
}
}
PortalUtil.copyRequestParameters(actionRequest, actionResponse);
} catch (Exception e) {
PortalUtil.copyRequestParameters(actionRequest, actionResponse);
_log.error("Error", e);
throw new SystemException(e);
}
}
public void deleteDocAggiuntiva(ActionRequest actionRequest, ActionResponse actionResponse)
throws Exception {
public void deleteDocAggiuntiva(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long docAggiuntivaId = ParamUtil.getLong(actionRequest, "docAggiuntivaId");
DocAggiuntivaServiceUtil.deleteDocAggiuntiva(docAggiuntivaId);
}
@Override
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
throws IOException, PortletException {
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException,
PortletException {
String id = resourceRequest.getResourceID();
try {
if ("downloadAll".equals(id)) {
long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId");
List<DocAggiuntiva> docs = DocAggiuntivaServiceUtil.findByIntPratica(intPraticaId);
ZipWriter zipWriter = ZipWriterFactoryUtil.getZipWriter();
for (DocAggiuntiva doc : docs) {
InputStream inputStream = null;
try {
if (Validator.isNull(doc.getFileEntryId())) {
@ -123,34 +112,17 @@ public class DocAggiuntivaPortlet extends MVCPortlet {
StreamUtil.cleanUp(inputStream);
}
}
resourceResponse.reset();
File file = zipWriter.getFile();
byte[] data = Files.readAllBytes(file.toPath());
resourceResponse.setContentType(ContentTypes.APPLICATION_ZIP);
resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate");
resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\""
+ file.getName() + "\"");
resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"" + file.getName() + StringPool.QUOTE);
resourceResponse.setContentLength(data.length);
resourceResponse.getPortletOutputStream().write(data);
resourceResponse.getPortletOutputStream().flush();
resourceResponse.getPortletOutputStream().close();
} else if ("importFile".equals(id)) {
long classPk = ParamUtil.getLong(resourceRequest, "classPk");
String className = ParamUtil.getString(resourceRequest, "className");
FilesImporter.importaFile(classPk, className);
PortletResponseUtil
.write(resourceResponse,
"<p style='margin-bottom:20px'><strong>Completato</strong></p><a href='#' class='btn btn-success' onclick=\"Liferay.Portlet.refresh('#p_p_id_"
+ PortletKeys.FASCICOLOFE + "_')\">Refresh</a>");
} else {
super.serveResource(resourceRequest, resourceResponse);
}

147
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/FascicoloPortlet.java

@ -4,7 +4,6 @@ import it.tref.liferay.portos.bo.model.Comune;
import it.tref.liferay.portos.bo.model.DettPratica;
import it.tref.liferay.portos.bo.model.DocPratica;
import it.tref.liferay.portos.bo.model.HistoryWorkflowAction;
import it.tref.liferay.portos.bo.model.InfoFascicolo;
import it.tref.liferay.portos.bo.model.IntPratica;
import it.tref.liferay.portos.bo.model.Provincia;
import it.tref.liferay.portos.bo.model.Soggetto;
@ -15,7 +14,6 @@ import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DettPraticaServiceUtil;
import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.HistoryWorkflowActionLocalServiceUtil;
import it.tref.liferay.portos.bo.service.InfoFascicoloLocalServiceUtil;
import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.IntPraticaServiceUtil;
import it.tref.liferay.portos.bo.service.ParereGeologoServiceUtil;
@ -24,7 +22,6 @@ import it.tref.liferay.portos.bo.service.SoggettoLocalServiceUtil;
import it.tref.liferay.portos.bo.service.SorteggioLocalServiceUtil;
import it.tref.liferay.portos.bo.service.TerritorioLocalServiceUtil;
import it.tref.liferay.portos.bo.shared.util.DocumentiPraticaUtil;
import it.tref.liferay.portos.bo.shared.util.PortletKeys;
import it.tref.liferay.portos.bo.shared.util.StatoPraticaConstants;
import it.tref.liferay.portos.bo.shared.util.TipoSoggettoUtil;
import it.tref.liferay.portos.bo.util.PraticaUtil;
@ -53,6 +50,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.liferay.counter.service.CounterLocalServiceUtil;
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.json.JSONArray;
@ -61,7 +59,6 @@ import com.liferay.portal.kernel.json.JSONObject;
import com.liferay.portal.kernel.language.LanguageUtil;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.portlet.PortletResponseUtil;
import com.liferay.portal.kernel.repository.model.FileEntry;
import com.liferay.portal.kernel.search.Document;
import com.liferay.portal.kernel.search.Hits;
@ -89,9 +86,6 @@ import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil;
import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil;
import com.liferay.util.bridges.mvc.MVCPortlet;
/**
* Portlet implementation class FascicoloPortlet
*/
public class FascicoloPortlet extends MVCPortlet {
private Log _log = LogFactoryUtil.getLog(FascicoloPortlet.class);
@ -108,11 +102,12 @@ public class FascicoloPortlet extends MVCPortlet {
}
public void toggleWorkflow(ActionRequest actionRequest, ActionResponse actionResponse) {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
User user = themeDisplay.getUser();
boolean attivare = ParamUtil.getBoolean(actionRequest, "avviare");
boolean sospendere = ParamUtil.getBoolean(actionRequest, "sospendere");
long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0);
long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0L);
String stato_pratica = ParamUtil.getString(actionRequest, "seleziona_stato");
try {
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId);
@ -140,11 +135,10 @@ public class FascicoloPortlet extends MVCPortlet {
}
if (!attivare) {
intPratica.setStatoPratica(stato_pratica);
IntPraticaLocalServiceUtil.updateStatoPratica(intPraticaId, 0, stato_pratica);
IntPraticaLocalServiceUtil.updateStatoPratica(intPraticaId, stato_pratica);
} else {
intPratica.setStatoPratica(StatoPraticaConstants.SOTTOPOSTA_A_PARERE);
IntPraticaLocalServiceUtil.updateStatoPratica(intPraticaId, 0,
StatoPraticaConstants.SOTTOPOSTA_A_PARERE);
IntPraticaLocalServiceUtil.updateStatoPratica(intPraticaId, StatoPraticaConstants.SOTTOPOSTA_A_PARERE);
}
IntPraticaLocalServiceUtil.reIndexFasciolo(intPraticaId, intPratica.getCompanyId());
} catch (Exception e) {
@ -155,6 +149,7 @@ public class FascicoloPortlet extends MVCPortlet {
private void addRowHistoryWorkflowAction(long intPraticaId, long dettPraticaId, long companyId, long groupId,
User user, boolean attivato) throws SystemException {
HistoryWorkflowAction historyWorkflowAction = HistoryWorkflowActionLocalServiceUtil
.createHistoryWorkflowAction(CounterLocalServiceUtil.increment(HistoryWorkflowAction.class.getName()));
historyWorkflowAction.setAttivato(attivato);
@ -170,7 +165,8 @@ public class FascicoloPortlet extends MVCPortlet {
}
public void toggleSospensione(ActionRequest actionRequest, ActionResponse actionResponse) {
long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0);
long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0L);
boolean sospesa = ParamUtil.getBoolean(actionRequest, "sospesa");
try {
IntPraticaServiceUtil.sospendiPratica(intPraticaId, sospesa);
@ -182,7 +178,8 @@ public class FascicoloPortlet extends MVCPortlet {
}
public void cambiaStato(ActionRequest actionRequest, ActionResponse actionResponse) {
long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0);
long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0L);
String statoPratica = ParamUtil.getString(actionRequest, "nuovoStatoPratica");
_log.info("cambiaSospendiRiprendi: INTPRATICAID" + intPraticaId);
try {
@ -196,6 +193,7 @@ public class FascicoloPortlet extends MVCPortlet {
}
public void aggiungiRichiestaParere(ActionRequest actionRequest, ActionResponse actionResponse) {
long geologoId = ParamUtil.getLong(actionRequest, "geologoId");
long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId");
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId");
@ -211,8 +209,9 @@ public class FascicoloPortlet extends MVCPortlet {
}
public void cambiaTitolare(ActionRequest actionRequest, ActionResponse actionResponse) {
String nuovoSoggettoCF = ParamUtil.getString(actionRequest, "nuovoSoggettoCF");
long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0);
long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0L);
long companyId = ParamUtil.getLong(actionRequest, "companyId");
try {
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
@ -237,6 +236,7 @@ public class FascicoloPortlet extends MVCPortlet {
}
public void searchURL(ActionRequest actionRequest, ActionResponse actionResponse) {
String numeroProgetto = actionRequest.getParameter("numeroProgetto");
String protocollo = actionRequest.getParameter("protocollo");
String tipoPratica = actionRequest.getParameter("tipoPratica");
@ -255,15 +255,15 @@ public class FascicoloPortlet extends MVCPortlet {
String indirizzo = actionRequest.getParameter("indirizzo");
if (Validator.isNotNull(dataRichiestaInizio)) {
String[] dataRichiestaInizioSplitted = dataRichiestaInizio.split(StringPool.FORWARD_SLASH);
int month = Integer.valueOf(dataRichiestaInizioSplitted[1]) - 1;
actionResponse.setRenderParameter("dataRichiestaInizioDay", dataRichiestaInizioSplitted[0]);
int month = Integer.valueOf(dataRichiestaInizioSplitted[1]) - 1;
actionResponse.setRenderParameter("dataRichiestaInizioMonth", String.valueOf(month));
actionResponse.setRenderParameter("dataRichiestaInizioYear", dataRichiestaInizioSplitted[2]);
}
if (Validator.isNotNull(dataRichiestaFine)) {
String[] dataRichiestaFineSplitted = dataRichiestaFine.split(StringPool.FORWARD_SLASH);
int month = Integer.valueOf(dataRichiestaFineSplitted[1]) - 1;
actionResponse.setRenderParameter("dataRichiestaFineDay", dataRichiestaFineSplitted[0]);
int month = Integer.valueOf(dataRichiestaFineSplitted[1]) - 1;
actionResponse.setRenderParameter("dataRichiestaFineMonth", String.valueOf(month));
actionResponse.setRenderParameter("dataRichiestaFineYear", dataRichiestaFineSplitted[2]);
}
@ -306,12 +306,13 @@ public class FascicoloPortlet extends MVCPortlet {
actionResponse.setRenderParameter("ordinaTipo", ordinaTipo);
}
public void versiona(ActionRequest actionRequest, ActionResponse actionResponse) {
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId", 0);
public void versiona(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId", 0L);
long companyId = ParamUtil.getLong(actionRequest, "companyId");
try {
DettPraticaServiceUtil.sendToVersioning(dettPraticaId, companyId);
} catch (Exception e) {
} catch (PortalException | SystemException | IOException | NoSuchFieldException | SecurityException e) {
_log.error("error-versioning", e);
SessionErrors.add(actionRequest, "error-versioning");
}
@ -368,40 +369,11 @@ public class FascicoloPortlet extends MVCPortlet {
resourceResponse.setContentType(ContentTypes.APPLICATION_ZIP);
resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate");
resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"" + file.getName() + "\"");
"attachment; filename=\"" + file.getName() + StringPool.QUOTE);
resourceResponse.setContentLength(data.length);
resourceResponse.getPortletOutputStream().write(data);
resourceResponse.getPortletOutputStream().flush();
resourceResponse.getPortletOutputStream().close();
} else if ("importFile".equals(id)) {
PortletResponseUtil
.write(resourceResponse,
"<p style='margin-bottom:20px'><strong>Completato</strong></p><a href='#' class='btn btn-success' onclick=\"Liferay.Portlet.refresh('#p_p_id_"
+ PortletKeys.FASCICOLO + "_')\">Refresh</a>");
} else if ("importAllFascicoloFiles".equals(id)) {
long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId");
IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId);
if (Validator.isNull(intPratica)) {
_log.error("error.no.intpratica.exist with intpraticaid=" + intPraticaId);
}
String comingFrom = ParamUtil.getString(resourceRequest, "comingFrom", "bo");
InfoFascicolo infoFascicolo = InfoFascicoloLocalServiceUtil.fetchByIntPratica(intPratica
.getIntPraticaId());
if (Validator.isNull(infoFascicolo)) {
infoFascicolo = InfoFascicoloLocalServiceUtil.addInfoFascicolo(intPratica.getIntPraticaId(),
intPratica.getNumeroProgetto(), serviceContext);
} else {
if (infoFascicolo.getAlreadyImported() && comingFrom.equalsIgnoreCase("fe")) {
_log.error("intpratica.import.file.already-clicked with intpraticaid=" + intPraticaId);
return;
}
}
infoFascicolo.setAlreadyImported(true);
infoFascicolo = InfoFascicoloLocalServiceUtil.updateInfoFascicolo(infoFascicolo);
PortletResponseUtil
.write(resourceResponse,
"<p style='margin-bottom:20px'><strong>Completato</strong></p><a href='#' class='btn btn-success' onclick=\"Liferay.Portlet.refresh('#p_p_id_"
+ PortletKeys.FASCICOLO + "_')\">Refresh</a>");
} else if ("comuni".equals(id)) {
String provinciaId = ParamUtil.getString(resourceRequest, "provinciaId");
JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
@ -447,11 +419,12 @@ public class FascicoloPortlet extends MVCPortlet {
}
private String exportSearch(Locale locale, ResourceRequest resourceRequest, User user) {
String method = "exportSearch";
HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(resourceRequest);
StringBuilder sb = new StringBuilder();
List<IntPratica> lista = new ArrayList<IntPratica>();
Hits hits = IntPraticaAdvancedSearch.searchProgettiBO(httpRequest, user, -1, -1);
Hits hits = IntPraticaAdvancedSearch.searchProgettiBO(httpRequest, user, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
for (Document doc : hits.toList()) {
String intPraticaId = doc.get("intPraticaId");
try {
@ -466,41 +439,43 @@ public class FascicoloPortlet extends MVCPortlet {
_log.error(method + " IntPraticaLocalServiceUtil.fetchIntPratica IntPraticaId: " + intPraticaId, e);
}
}
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.sorteggiata")));
sb.append(StringPool.SEMICOLON);
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.pratica")));
sb.append(StringPool.SEMICOLON);
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.titolare")));
sb.append(StringPool.SEMICOLON);
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.committenti")));
sb.append(StringPool.SEMICOLON);
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.istruttore")));
sb.append(StringPool.SEMICOLON);
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.statoPratica")));
sb.append(StringPool.SEMICOLON);
// ADT BUG-ID=15 Sezione Ricerca / Export csv
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.provincia")));
sb.append(StringPool.SEMICOLON);
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.comune")));
sb.append(StringPool.SEMICOLON);
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale,
"label.scadenzegeniocivile.descrizioneIntervento")));
sb.append(StringPool.SEMICOLON);
sb.append(StringPool.NEW_LINE);
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.sorteggiata")))
.append(StringPool.SEMICOLON)
.append(CSVUtil.encode(LanguageUtil
.get(getPortletConfig(), locale, "label.scadenzegeniocivile.pratica")))
.append(StringPool.SEMICOLON)
.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale,
"label.scadenzegeniocivile.titolare")))
.append(StringPool.SEMICOLON)
.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale,
"label.scadenzegeniocivile.committenti")))
.append(StringPool.SEMICOLON)
.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale,
"label.scadenzegeniocivile.istruttore")))
.append(StringPool.SEMICOLON)
.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale,
"label.scadenzegeniocivile.statoPratica")))
.append(StringPool.SEMICOLON)
.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale,
"label.scadenzegeniocivile.provincia")))
.append(StringPool.SEMICOLON)
.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.comune")))
.append(StringPool.SEMICOLON)
.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale,
"label.scadenzegeniocivile.descrizioneIntervento"))).append(StringPool.SEMICOLON)
.append(StringPool.NEW_LINE);
for (IntPratica intPratica : lista) {
try {
DettPratica lastDettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(intPratica
.getIntPraticaId());
long intPraticaId = intPratica.getIntPraticaId();
DettPratica lastDettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(intPraticaId);
Territorio territorio = TerritorioLocalServiceUtil.fetchTerritorio(intPratica.getTerritorioId());
Comune comune = ComuneLocalServiceUtil.fetchComune(territorio.getComuneId());
Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(),
territorio.getCodiceProvincia());
boolean sorteggiata = SorteggioLocalServiceUtil.findByIntPratica(intPratica.getIntPraticaId()) != null;
sb.append(CSVUtil.encode((sorteggiata) ? "Si" : "No"));
sb.append(StringPool.SEMICOLON);
sb.append(CSVUtil.encode((sorteggiata) ? "Sì" : "No")).append(StringPool.SEMICOLON);
String praticaLabel = intPratica.getTitle(locale, true);
sb.append(CSVUtil.encode(praticaLabel));
sb.append(StringPool.SEMICOLON);
sb.append(CSVUtil.encode(praticaLabel)).append(StringPool.SEMICOLON);
List<Soggetto> titolari = SoggettoLocalServiceUtil.getValidByIntPratica_CodiceFiscale(
lastDettPratica.getIntPraticaId(), lastDettPratica.getCodiceFiscaleDelegatoCommittente());
Soggetto titolare = null;
@ -515,21 +490,20 @@ public class FascicoloPortlet extends MVCPortlet {
List<Soggetto> committenti = SoggettoLocalServiceUtil.findByIntPratica_TipologiaSoggetto(
lastDettPratica.getIntPraticaId(), TipoSoggettoUtil.COMMITTENTE);
for (Soggetto committente : committenti) {
builder.append(committente.getTitle() + " - " + committente.getCodiceFiscale()).append(
StringPool.COMMA_AND_SPACE);
builder.append(committente.getTitle()).append(" - ").append(committente.getCodiceFiscale())
.append(StringPool.COMMA_AND_SPACE);
}
if (builder.length() > 0)
builder.setLength(builder.length() - 12);
sb.append(builder.toString());
sb.append(StringPool.SEMICOLON);
sb.append(builder.toString()).append(StringPool.SEMICOLON);
User istruttore = UserLocalServiceUtil.fetchUser(intPratica.getStatusByUserId());
if (istruttore != null) {
sb.append(istruttore.getFullName());
}
sb.append(StringPool.SEMICOLON);
sb.append(LanguageUtil.get(locale,
PraticaUtil.getStatoPraticaLabel(intPratica.getStatoPratica(), intPratica)));
sb.append(StringPool.SEMICOLON);
sb.append(StringPool.SEMICOLON)
.append(LanguageUtil.get(locale,
PraticaUtil.getStatoPraticaLabel(intPratica.getStatoPratica(), intPratica)))
.append(StringPool.SEMICOLON);
// ADT BUG-ID=15 Sezione Ricerca / Export csv
if (Validator.isNotNull(provincia)) {
sb.append(provincia.getProvincia());
@ -548,7 +522,8 @@ public class FascicoloPortlet extends MVCPortlet {
}
sb.append(StringPool.SEMICOLON);
} catch (Throwable e) {
_log.error(method + " IntPraticaId: " + intPratica != null ? intPratica.getIntPraticaId() : "", e);
_log.error(method + " IntPraticaId: " + intPratica != null ? intPratica.getIntPraticaId()
: StringPool.BLANK, e);
} finally {
sb.append(StringPool.NEW_LINE);
}

43
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/GestioneAttivitaIstruttorePortlet.java

@ -123,32 +123,24 @@ public class GestioneAttivitaIstruttorePortlet extends MVCPortlet {
GetterUtil.getInteger(PropsUtil.get(PropsKeys.INDEX_FILTER_SEARCH_LIMIT)), isExport);
try {
for (Document doc : hits.toList()) {
String intPraticaId = doc.get("intPraticaId");
if (Validator.isNotNull(intPraticaId)) {
IntPratica intPratica;
intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(GetterUtil.getLong(intPraticaId));
IntPratica intPratica = IntPraticaLocalServiceUtil
.fetchIntPratica(GetterUtil.getLong(intPraticaId));
if (Validator.isNotNull(intPratica)) {
lista.add(intPratica);
}
}
}
} catch (PortalException | SystemException e) {
throw new IOException(e);
}
if (isExport && Validator.isNotNull(lista) && !lista.isEmpty()) {
StringBuilder sb = new StringBuilder();
for (String columnName : FIELD_NAMES) {
sb.append(columnName);
sb.append(StringPool.SEMICOLON);
sb.append(columnName).append(StringPool.SEMICOLON);
}
sb.append(CharPool.NEW_LINE);
sb.append(CharPool.NEW_LINE);
sb.append(CharPool.NEW_LINE).append(CharPool.NEW_LINE);
for (IntPratica pratica : lista) {
try {
DettPratica lastDettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(pratica
@ -175,31 +167,22 @@ public class GestioneAttivitaIstruttorePortlet extends MVCPortlet {
if (collaudatori != null && !collaudatori.isEmpty()) {
collaudoPrevisto = true;
}
sb.append(pratica.getTipoPratica());
sb.append(StringPool.SEMICOLON);
sb.append(pratica.getNumeroProgetto());
sb.append(StringPool.SEMICOLON);
sb.append(pratica.getTipoPratica()).append(StringPool.SEMICOLON)
.append(pratica.getNumeroProgetto()).append(StringPool.SEMICOLON);
if (Validator.isNotNull(pratica.getDtPratica())) {
sb.append(sdf.format(pratica.getDtPratica()));
}
sb.append(StringPool.SEMICOLON);
sb.append(comune.getDenominazione());
sb.append(StringPool.SEMICOLON);
sb.append(provincia.getProvincia());
sb.append(StringPool.SEMICOLON);
sb.append(pratica.getStatoPratica());
sb.append(StringPool.SEMICOLON);
sb.append(StringPool.SEMICOLON).append(comune.getDenominazione()).append(StringPool.SEMICOLON)
.append(provincia.getProvincia()).append(StringPool.SEMICOLON)
.append(pratica.getStatoPratica()).append(StringPool.SEMICOLON);
for (Soggetto soggetto : committenti) {
// ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV
// sb.append(soggetto.getCodiceFiscale().toUpperCase());
sb.append(soggetto.getDescrizioneCompleta().toUpperCase());
sb.append(StringPool.SPACE);
sb.append(soggetto.getDescrizioneCompleta().toUpperCase()).append(StringPool.SPACE);
}
sb.append(StringPool.SEMICOLON);
for (Soggetto soggetto : direttoreLavori) {
// ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV
sb.append(soggetto.getDescrizioneCompleta().toUpperCase());
sb.append(StringPool.SPACE);
sb.append(soggetto.getDescrizioneCompleta().toUpperCase()).append(StringPool.SPACE);
}
sb.append(StringPool.SEMICOLON);
if (Validator.isNotNull(lastDettPratica)) {
@ -278,13 +261,11 @@ public class GestioneAttivitaIstruttorePortlet extends MVCPortlet {
JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
jsonObject.put("comuneId", comune.getComuneId());
jsonObject.put("descLong", comune.getDenominazione());
jsonArray.put(jsonObject);
}
writeJSON(resourceRequest, resourceResponse, jsonArray);
}
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
}

101
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/HomeBOPortlet.java

@ -24,77 +24,58 @@ import com.liferay.portal.workflow.kaleo.model.KaleoTaskInstanceToken;
import com.liferay.portal.workflow.kaleo.service.KaleoTaskInstanceTokenLocalServiceUtil;
import com.liferay.util.bridges.mvc.MVCPortlet;
/**
* Portlet implementation class HomeBOPortlet
*/
public class HomeBOPortlet extends MVCPortlet {
private static final Log _log = LogFactoryUtil.getLog(HomeBOPortlet.class);
@Override
public void render(RenderRequest renderRequest, RenderResponse renderResponse)
throws PortletException, IOException {
public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException {
ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
try {
int countPraticheScaduteAutorizzazione = TempisticaLocalServiceUtil.countPraticheScaduteAutorizzazione(
themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId());
int countPraticheScaduteSorteggiate = TempisticaLocalServiceUtil.countPraticheScaduteSorteggiate(
themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId());
int countPraticheScaduteControlloObbligatorio = TempisticaLocalServiceUtil.countPraticheScaduteControlloObbligatorio(
themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId());
int countPraticheInScadenzaAutorizzazioni = TempisticaLocalServiceUtil.countPraticheInScadenzaAutorizzazioni(
themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId());
int countPraticheScaduteControlloObbligatorio = TempisticaLocalServiceUtil
.countPraticheScaduteControlloObbligatorio(themeDisplay.getCompanyId(),
themeDisplay.getScopeGroupId());
int countPraticheInScadenzaAutorizzazioni = TempisticaLocalServiceUtil
.countPraticheInScadenzaAutorizzazioni(themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId());
int countPraticheInScadenzaSorteggiate = TempisticaLocalServiceUtil.countPraticheInScadenzaSorteggiate(
themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId());
int countPraticheInScadenzaControlloObbligatorio = TempisticaLocalServiceUtil.countPraticheInScadenzaControlloObbligatorio(
themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId());
int countPraticheInScadenzaControlloObbligatorio = TempisticaLocalServiceUtil
.countPraticheInScadenzaControlloObbligatorio(themeDisplay.getCompanyId(),
themeDisplay.getScopeGroupId());
renderRequest.setAttribute("countPraticheScaduteAutorizzazione", countPraticheScaduteAutorizzazione);
renderRequest.setAttribute("countPraticheScaduteSorteggiate", countPraticheScaduteSorteggiate);
renderRequest.setAttribute("countPraticheScaduteControlloObbligatorio", countPraticheScaduteControlloObbligatorio);
renderRequest.setAttribute("countPraticheScaduteControlloObbligatorio",
countPraticheScaduteControlloObbligatorio);
renderRequest.setAttribute("countPraticheInScadenzaAutorizzazioni", countPraticheInScadenzaAutorizzazioni);
renderRequest.setAttribute("countPraticheInScadenzaSorteggiate", countPraticheInScadenzaSorteggiate);
renderRequest.setAttribute("countPraticheInScadenzaControlloObbligatorio", countPraticheInScadenzaControlloObbligatorio);
ClassLoader classLoader =
(ClassLoader) PortletBeanLocatorUtil.locate(com.liferay.portal.workflow.kaleo.service.ClpSerializer.getServletContextName(), "portletClassLoader");
renderRequest.setAttribute("countPraticheInScadenzaControlloObbligatorio",
countPraticheInScadenzaControlloObbligatorio);
ClassLoader classLoader = (ClassLoader) PortletBeanLocatorUtil.locate(
com.liferay.portal.workflow.kaleo.service.ClpSerializer.getServletContextName(),
"portletClassLoader");
List<Long> praticheAttiveAutorizzazioni = TempisticaLocalServiceUtil.praticheAttiveAutorizzazioni(
themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId());
int countAutorizzazioniDaAssegnare = 0;
int countAutorizzazioniOrdinarie = 0;
for (Long intPraticaId : praticheAttiveAutorizzazioni) {
DynamicQuery query = DynamicQueryFactoryUtil.forClass(ControlloPratica.class);
query.add(RestrictionsFactoryUtil.eq("intPraticaId", intPraticaId));
List<ControlloPratica> lista = ControlloPraticaLocalServiceUtil.dynamicQuery(query);
if (lista != null && !lista.isEmpty()) {
ControlloPratica controlloPratica = lista.get(0);
if (controlloPratica != null) {
DynamicQuery queryKaleo = DynamicQueryFactoryUtil.forClass(KaleoTaskInstanceToken.class,classLoader);
DynamicQuery queryKaleo = DynamicQueryFactoryUtil.forClass(KaleoTaskInstanceToken.class,
classLoader);
queryKaleo.add(RestrictionsFactoryUtil.eq("classPK", controlloPratica.getControlloPraticaId()));
queryKaleo.add(RestrictionsFactoryUtil.eq("kaleoTaskName", "Assegnazione"));
queryKaleo.add(RestrictionsFactoryUtil.eq("completed", false));
List<KaleoTaskInstanceToken> listaKaleo = KaleoTaskInstanceTokenLocalServiceUtil.dynamicQuery(queryKaleo);
List<KaleoTaskInstanceToken> listaKaleo = KaleoTaskInstanceTokenLocalServiceUtil
.dynamicQuery(queryKaleo);
if (listaKaleo != null && !listaKaleo.isEmpty()) {
countAutorizzazioniDaAssegnare++;
} else {
@ -103,34 +84,26 @@ public class HomeBOPortlet extends MVCPortlet {
}
}
}
renderRequest.setAttribute("countAutorizzazioniDaAssegnare", countAutorizzazioniDaAssegnare);
renderRequest.setAttribute("countAutorizzazioniOrdinarie", countAutorizzazioniOrdinarie);
List<Long> praticheAttiveSorteggiate = TempisticaLocalServiceUtil.praticheAttiveSorteggiate(
themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId());
int countSorteggiateDaAssegnare = 0;
int countSorteggiateOrdinarie = 0;
for (Long intPraticaId : praticheAttiveSorteggiate) {
DynamicQuery query = DynamicQueryFactoryUtil.forClass(ControlloPratica.class);
query.add(RestrictionsFactoryUtil.eq("intPraticaId", intPraticaId));
List<ControlloPratica> lista = ControlloPraticaLocalServiceUtil.dynamicQuery(query);
if (lista != null && !lista.isEmpty()) {
ControlloPratica controlloPratica = lista.get(0);
if (controlloPratica != null) {
DynamicQuery queryKaleo = DynamicQueryFactoryUtil.forClass(KaleoTaskInstanceToken.class,classLoader);
DynamicQuery queryKaleo = DynamicQueryFactoryUtil.forClass(KaleoTaskInstanceToken.class,
classLoader);
queryKaleo.add(RestrictionsFactoryUtil.eq("classPK", controlloPratica.getControlloPraticaId()));
queryKaleo.add(RestrictionsFactoryUtil.eq("kaleoTaskName", "Assegnazione"));
queryKaleo.add(RestrictionsFactoryUtil.eq("completed", false));
List<KaleoTaskInstanceToken> listaKaleo = KaleoTaskInstanceTokenLocalServiceUtil.dynamicQuery(queryKaleo);
List<KaleoTaskInstanceToken> listaKaleo = KaleoTaskInstanceTokenLocalServiceUtil
.dynamicQuery(queryKaleo);
if (listaKaleo != null && !listaKaleo.isEmpty()) {
countSorteggiateDaAssegnare++;
} else {
@ -139,54 +112,40 @@ public class HomeBOPortlet extends MVCPortlet {
}
}
}
renderRequest.setAttribute("countSorteggiateDaAssegnare", countSorteggiateDaAssegnare);
renderRequest.setAttribute("countSorteggiateOrdinarie", countSorteggiateOrdinarie);
List<Long> praticheAttiveControlloObbligatorio = TempisticaLocalServiceUtil.praticheAttiveControlloObbligatorio(
themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId());
List<Long> praticheAttiveControlloObbligatorio = TempisticaLocalServiceUtil
.praticheAttiveControlloObbligatorio(themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId());
int countControlloObbligatorioDaAssegnare = 0;
int countControlloObbligatorioOrdinarie = 0;
for (Long intPraticaId : praticheAttiveControlloObbligatorio) {
DynamicQuery query = DynamicQueryFactoryUtil.forClass(ControlloPratica.class);
query.add(RestrictionsFactoryUtil.eq("intPraticaId", intPraticaId));
List<ControlloPratica> lista = ControlloPraticaLocalServiceUtil.dynamicQuery(query);
if (lista != null && !lista.isEmpty()) {
ControlloPratica controlloPratica = lista.get(0);
if (controlloPratica != null) {
DynamicQuery queryKaleo = DynamicQueryFactoryUtil.forClass(KaleoTaskInstanceToken.class,classLoader);
DynamicQuery queryKaleo = DynamicQueryFactoryUtil.forClass(KaleoTaskInstanceToken.class,
classLoader);
queryKaleo.add(RestrictionsFactoryUtil.eq("classPK", controlloPratica.getControlloPraticaId()));
queryKaleo.add(RestrictionsFactoryUtil.eq("className", ControlloPratica.class.getName()));
queryKaleo.add(RestrictionsFactoryUtil.eq("kaleoTaskName", "Assegnazione"));
queryKaleo.add(RestrictionsFactoryUtil.eq("completed", false));
List<KaleoTaskInstanceToken> listaKaleo = KaleoTaskInstanceTokenLocalServiceUtil.dynamicQuery(queryKaleo);
List<KaleoTaskInstanceToken> listaKaleo = KaleoTaskInstanceTokenLocalServiceUtil
.dynamicQuery(queryKaleo);
if (listaKaleo != null && !listaKaleo.isEmpty()) {
countControlloObbligatorioDaAssegnare++;
} else {
countControlloObbligatorioOrdinarie++;
}
}
}
}
renderRequest.setAttribute("countControlloObbligatorioDaAssegnare", countControlloObbligatorioDaAssegnare);
renderRequest.setAttribute("countControlloObbligatorioOrdinarie", countControlloObbligatorioOrdinarie);
} catch (SystemException e) {
_log.error(e, e);
}
super.render(renderRequest, renderResponse);
}
}

7
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/RicercaProtocolloPortlet.java

@ -8,22 +8,15 @@ import javax.portlet.ActionResponse;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.util.bridges.mvc.MVCPortlet;
/**
* Portlet implementation class RicercaProtocolloPortlet
*/
public class RicercaProtocolloPortlet extends MVCPortlet {
public void search(ActionRequest actionRequest, ActionResponse actionResponse) {
String dataDa = ParamUtil.getString(actionRequest, "dataDa", StringPool.BLANK);
String dataA = ParamUtil.getString(actionRequest, "dataA", StringPool.BLANK);
String numeroProtocollo = ParamUtil.getString(actionRequest, "numeroProtocollo", StringPool.BLANK);
actionResponse.setRenderParameter("dataDa", dataDa);
actionResponse.setRenderParameter("dataA", dataA);
actionResponse.setRenderParameter("numeroProtocollo", numeroProtocollo);
}
}

26
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/SismicaAdministrationPortlet.java

@ -21,6 +21,7 @@ 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.util.ParamUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.service.ServiceContext;
@ -35,30 +36,28 @@ public class SismicaAdministrationPortlet extends MVCPortlet {
private static final Log _log = LogFactoryUtil.getLog(SismicaAdministrationPortlet.class);
public void mostraConfigurazione(ActionRequest actionRequest, ActionResponse actionResponse)
throws SystemException {
public void mostraConfigurazione(ActionRequest actionRequest, ActionResponse actionResponse) throws SystemException {
List<String> esito = new ArrayList<String>();
esito.add("<h3>Env</h3>");
for (Map.Entry<String, String> entry : System.getenv().entrySet()) {
esito.add(entry.getKey() + "=" + entry.getValue());
esito.add(entry.getKey() + StringPool.EQUAL + entry.getValue());
}
esito.add("<h3>Properties</h3>");
for (Map.Entry<Object, Object> entry : System.getProperties().entrySet()) {
esito.add(entry.getKey() + "=" + entry.getValue());
esito.add(entry.getKey() + StringPool.EQUAL + entry.getValue());
}
actionResponse.setRenderParameter("esito", esito.toArray(new String[esito.size()]));
}
public void generaDocumenti(ActionRequest actionRequest, ActionResponse actionResponse) {
ThemeDisplay td = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
// ThemeDisplay td = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
List<String> esito = new ArrayList<>();
try {
esito = SismicaUtil.fixInvio(td.getCompanyId());
} catch (PortalException | SystemException e) {
esito.add("Errore durante l'invio " + e.getMessage());
}
// try {
// } catch (PortalException | SystemException e) {
// esito.add("Errore durante l'invio " + e.getMessage());
// }
actionResponse.setRenderParameter("esito", esito.toArray(new String[esito.size()]));
}
@ -91,8 +90,8 @@ public class SismicaAdministrationPortlet extends MVCPortlet {
actionResponse.setRenderParameter("esito", esito.toArray(new String[esito.size()]));
}
public void reIndexFasciolo(ActionRequest actionRequest, ActionResponse actionResponse)
throws PortalException, SystemException {
public void reIndexFasciolo(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException,
SystemException {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
@ -137,8 +136,7 @@ public class SismicaAdministrationPortlet extends MVCPortlet {
actionResponse.setRenderParameter("esito", esito.toArray(new String[esito.size()]));
}
public void inviaAvviso(ActionRequest actionRequest, ActionResponse actionResponse)
throws SystemException {
public void inviaAvviso(ActionRequest actionRequest, ActionResponse actionResponse) throws SystemException {
SismicaUtil.inviaAvviso(actionRequest, actionResponse);
}

18
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/SorteggioPortlet.java

@ -17,9 +17,6 @@ import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil;
import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil;
import com.liferay.util.bridges.mvc.MVCPortlet;
/**
* Portlet implementation class SorteggioGenioCivilePortlet
*/
public class SorteggioPortlet extends MVCPortlet {
private final static Log _log = LogFactoryUtil.getLog(SorteggioPortlet.class);
@ -29,26 +26,17 @@ public class SorteggioPortlet extends MVCPortlet {
PortletException {
String resourceID = resourceRequest.getResourceID();
if ("downloadReport".equals(resourceID)) {
long fileEntryId = ParamUtil.getLong(resourceRequest, "fileEntryId");
try {
FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(fileEntryId);
String fileName = fileEntry.getTitle() + StringPool.PERIOD + fileEntry.getExtension();
byte[] data =
FileUtil.getBytes(DLFileEntryLocalServiceUtil.getFileAsStream(fileEntry.getUserId(), fileEntryId,
fileEntry.getVersion(), false));
byte[] data = FileUtil.getBytes(DLFileEntryLocalServiceUtil.getFileAsStream(fileEntry.getUserId(),
fileEntryId, fileEntry.getVersion(), false));
resourceResponse.setContentType(fileEntry.getMimeType());
resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate");
resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION, "filename=\"" + fileName + "\"");
resourceResponse.setContentLength(data.length);
resourceResponse.getPortletOutputStream().write(data);
resourceResponse.getPortletOutputStream().flush();
resourceResponse.getPortletOutputStream().close();
@ -56,10 +44,8 @@ public class SorteggioPortlet extends MVCPortlet {
_log.error(e, e);
throw new IOException(e);
}
} else {
super.serveResource(resourceRequest, resourceResponse);
}
}
}

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

@ -4,15 +4,13 @@ import it.tref.liferay.portos.bo.model.DocPratica;
import it.tref.liferay.portos.bo.service.ConfigurazioneLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.FileUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntityBuilder;
@ -31,7 +29,6 @@ import com.liferay.portal.kernel.messaging.Message;
import com.liferay.portal.kernel.messaging.MessageListener;
import com.liferay.portal.kernel.messaging.MessageListenerException;
import com.liferay.portal.kernel.util.FileUtil;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.UniqueList;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
@ -52,36 +49,30 @@ public class SchedulerEstrazioneFirme implements MessageListener {
private static final Lock lock = new ReentrantLock();
@Override
public void receive(Message message) throws MessageListenerException {
if (lock.tryLock()) {
try {
for (Company company : CompanyLocalServiceUtil.getCompanies()) {
// campo abilitazione scheduler
// TODO creare la configurazione aggiuntiva per lo scheduler
// estrazione firme
boolean condition = Boolean.parseBoolean(ConfigurazioneLocalServiceUtil
.findByC_ChiaveString(company.getCompanyId(),
ConfigurazioneConstants.SCHEDULER_FIRMA_DOCUMENTO));
// TODO creare la configurazione aggiuntiva per lo scheduler estrazione firme
boolean condition = Boolean.parseBoolean(ConfigurazioneLocalServiceUtil.findByC_ChiaveString(
company.getCompanyId(), ConfigurazioneConstants.SCHEDULER_FIRMA_DOCUMENTO));
if (condition) {
List<DocPratica> docPratiche = DocPraticaLocalServiceUtil.findByStaus(
WorkflowConstants.STATUS_PENDING, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
String urlPdfExtractor = (String) company.getExpandoBridge().getAttribute(
"url_pdf_extractor", false);
String urlPdfExtractor = (String) company.getExpandoBridge().getAttribute("url_pdf_extractor",
false);
for (DocPratica docPratica : docPratiche) {
DLFileEntry fileEntry = DLFileEntryLocalServiceUtil.getFileEntry(docPratica
.getDlFileEntryId());
User user = UserLocalServiceUtil.getRoleUsers(
RoleLocalServiceUtil.getRole(docPratica.getCompanyId(),
RoleConstants.ADMINISTRATOR).getRoleId()).get(0);
PermissionThreadLocal.setPermissionChecker(PermissionCheckerFactoryUtil
.create(user));
RoleLocalServiceUtil
.getRole(docPratica.getCompanyId(), RoleConstants.ADMINISTRATOR)
.getRoleId()).get(0);
PermissionThreadLocal.setPermissionChecker(PermissionCheckerFactoryUtil.create(user));
byte[] fileBytes = FileUtil.getBytes(fileEntry.getContentStream());
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
ContentBody body = new ByteArrayBody(fileBytes, fileEntry.getTitle());
builder.addPart("file", body);
@ -89,31 +80,23 @@ public class SchedulerEstrazioneFirme implements MessageListener {
request.setEntity(builder.build());
CloseableHttpClient client = HttpClientBuilder.create().build();
HttpResponse response = client.execute(request);
int statusCode = response.getStatusLine().getStatusCode();
String responseBody = EntityUtils.toString(response.getEntity(), StringPool.UTF8);
if (statusCode == HttpServletResponse.SC_OK
|| statusCode == HttpServletResponse.SC_CREATED) {
if (statusCode == HttpServletResponse.SC_OK || statusCode == HttpServletResponse.SC_CREATED) {
JSONArray arrayFirme = JSONFactoryUtil.createJSONObject(responseBody)
.getJSONArray("cf");
List<String> cf = new UniqueList<String>();
for (int i = 0; i < arrayFirme.length(); i++) {
cf.add(arrayFirme.getString(i));
}
DocPraticaLocalServiceUtil.addFirmeAndApprova(docPratica.getDocPraticaId(),
cf);
DocPraticaLocalServiceUtil.addFirmeAndApprova(docPratica.getDocPraticaId(), cf);
_log.info("risposta ws " + responseBody + " numero firme " + cf.size());
// if (cf.size() > 1)
// salvaCampione(fileEntry, fileBytes, cf.size()
// + "-firme");
} else {
String errorCode = JSONFactoryUtil.createJSONObject(responseBody).getString(
"errorCode");
DocPraticaLocalServiceUtil.addErrorAndApprova(docPratica.getDocPraticaId(),
errorCode);
_log.warn("P7M REST extractor error. Response: " + new String(responseBody)
+ " id=" + fileEntry.getFileEntryId());
salvaCampione(fileEntry, fileBytes, "0-firme");
String errorCode = JSONFactoryUtil.createJSONObject(responseBody)
.getString("errorCode");
DocPraticaLocalServiceUtil.addErrorAndApprova(docPratica.getDocPraticaId(), errorCode);
_log.warn("P7M REST extractor error. Response: " + new String(responseBody) + " id="
+ fileEntry.getFileEntryId());
}
}
}
@ -127,19 +110,5 @@ public class SchedulerEstrazioneFirme implements MessageListener {
lock.unlock();
}
}
}
private static void salvaCampione(DLFileEntry fileEntry, byte[] fileBytes, String prefisso) {
String debugPath = PropsUtil.get("liferay.home") + "/debug";
File debugFile = new File(debugPath);
if (!debugFile.exists())
debugFile.mkdirs();
debugFile = new File(debugPath + "/" + prefisso + "-" + fileEntry.getFileEntryId() + "."
+ fileEntry.getExtension());
try {
FileUtils.writeByteArrayToFile(debugFile, fileBytes);
} catch (IOException e) {
}
}
}

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

@ -54,43 +54,29 @@ public class SchedulerGeneraDocumento implements MessageListener {
public void receive(Message message) throws MessageListenerException {
if (lock.tryLock()) {
_log.debug("SchedulerGeneraDocumento - inizio");
try {
// campo abilitazione scheduler
for (Company company : CompanyLocalServiceUtil.getCompanies()) {
String condition = ConfigurazioneLocalServiceUtil.findByC_ChiaveString(
company.getCompanyId(), ConfigurazioneConstants.SCHEDULER_GENERA_DOCUMENTO);
_log.debug("SchedulerGeneraDocumento - per company " + company.getCompanyId()
+ " attivo? " + condition);
String condition = ConfigurazioneLocalServiceUtil.findByC_ChiaveString(company.getCompanyId(),
ConfigurazioneConstants.SCHEDULER_GENERA_DOCUMENTO);
if (Boolean.parseBoolean(condition)) {
int count = AvvisoLocalServiceUtil.countAvvisiGenerazioneDocumento();
_log.debug("SchedulerGeneraDocumento - numero avvisi " + count);
if (count > 0) {
for (int cursor = 0; cursor <= count; cursor += SIZE) {
List<Avviso> avvisi = AvvisoLocalServiceUtil.getAvvisiGenerazioneDocumento(
cursor, cursor + SIZE);
List<Avviso> avvisi = AvvisoLocalServiceUtil.getAvvisiGenerazioneDocumento(cursor,
cursor + SIZE);
for (Avviso avviso : avvisi) {
_log.debug("SchedulerGeneraDocumento - avviso " + avviso.getAvvisoId());
try {
FileEntry fileEntryTemplate = null;
try {
fileEntryTemplate = DLAppLocalServiceUtil.getFileEntry(avviso
.getFileEntryIdTemplate());
} catch (PortalException e) {
// bloccato, non esiste file di
// template
_log.debug("SchedulerGeneraDocumento - non esiste file template");
AvvisoLocalServiceUtil.updateAvvisoErrore(avviso.getAvvisoId(),
true);
// bloccato, non esiste file di template
AvvisoLocalServiceUtil.updateAvvisoErrore(avviso.getAvvisoId(), true);
}
if (fileEntryTemplate != null) {
_log.debug("SchedulerGeneraDocumento - inizio genera documento");
generaDocumento(avviso, fileEntryTemplate.getFileEntryId());
_log.debug("SchedulerGeneraDocumento - fine genera documento");
}
} catch (Exception e) {
_log.error("Error", e);
@ -112,63 +98,40 @@ public class SchedulerGeneraDocumento implements MessageListener {
private Long generaDocumento(Avviso avviso, long fileEntryIdTemplate) throws SystemException {
Long idFileEntry = null;
try {
long companyId = avviso.getCompanyId();
long groupId = avviso.getGroupId();
long userId = avviso.getUserId();
ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(companyId);
serviceContext.setScopeGroupId(groupId);
serviceContext.setUserId(userId);
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(avviso.getIntPraticaId());
long folderId = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(companyId, AvvisoUtil
.getAllTipoDocumentoFolderProps().get(avviso.getTipoDocumento()));
String fileName = AvvisoLocalServiceUtil.getFileNameAvviso(avviso.getClassPk(),
avviso.getTipoDocumento(), avviso.getAvvisoId(), "B");
String fileName = AvvisoLocalServiceUtil.getFileNameAvviso(avviso.getClassPk(), avviso.getTipoDocumento(),
avviso.getAvvisoId(), "B");
Map<String, Object> parameters = new HashMap<String, Object>();
if (Validator.isNotNull(avviso.getJsonParameters())) {
JSONDeserializer<Map<String, String>> deserializer = JSONFactoryUtil.createJSONDeserializer();
parameters.putAll(deserializer.deserialize(avviso.getJsonParameters()));
}
if (DettPratica.class.getName().equals(avviso.getClassName())) {
DettPratica dettPratica = DettPraticaLocalServiceUtil.fetchDettPratica(avviso.getClassPk());
if (dettPratica != null) {
if (intPratica != null && Validator.isNotNull(intPratica.getStatusByUserId())) {
User tecnico = UserLocalServiceUtil.fetchUserById(intPratica.getStatusByUserId());
if (tecnico != null) {
parameters.put(WorkflowConstants.WORKFLOW_PARAM_NAME_TECNICO,
tecnico.getFullName());
parameters.put(WorkflowConstants.WORKFLOW_PARAM_NAME_TECNICO, tecnico.getFullName());
parameters.put("delegato", tecnico.getFullName());
}
}
}
}
ReportAvvisoBean bean = ReportAvvisoBeanBuilder.build(avviso, parameters);
String resourcePath = getClass().getName().replaceAll("\\w+\\.", "../")
.replace(getClass().getSimpleName(), ReportConstants.PATH_LOGO_REGIONE);
parameters.put(ReportConstants.LOGO_REGIONE, getClass().getResource(resourcePath).getPath());
// avviso = gestioneProtocollazione(avviso, dettPratica);
/*
* Message messageReport = new Message();
* messageReport.put(ReportConstants.FILE_ENTRY_ID_TEMPLATE,
* fileEntryIdTemplate);
* messageReport.put(ReportConstants.FOLDER_ID_REPORT, folderId);
* messageReport.put(ReportConstants.REPORT_NAME, fileName);
* messageReport.put(ReportConstants.SERVICE_CONTEXT,
* serviceContext);
* messageReport.put(ReportConstants.REPORT_PARAMETERS, parameters);
* messageReport.put(ReportConstants.REPORT_DATASOURCE, bean);
*/
ReportDto reportDto = new ReportDto();
reportDto.setFileEntryIds(new long[] { fileEntryIdTemplate });
reportDto.setFolderId(folderId);
@ -176,18 +139,12 @@ public class SchedulerGeneraDocumento implements MessageListener {
reportDto.setParameters(parameters);
reportDto.setShowNumberOfPage(true);
reportDto.setType(ReportConstants.ReportType.JRXML_TO_PDF.toString());
ReportResultDto result = ReportUtil.generateReport(companyId, userId, reportDto, bean);
idFileEntry = result.getFileEntryIds()[0];
// idFileEntry = (Long)
// MessageBusUtil.sendSynchronousMessage(ReportDestinationNames.SYNC,
// messageReport, 1);
if (Validator.isNotNull(idFileEntry)) {
if (avviso.getTipoAvviso().equalsIgnoreCase(AvvisoUtil.TIPO_AVVISO_DIRETTO)) {
gestioneProtocollazione(avviso, idFileEntry);
}
if (AvvisoUtil.TIPO_AVVISO_DIRETTO.equals(avviso.getTipoAvviso())) {
AvvisoLocalServiceUtil.updateAvvisoDlFileEntryIdBase(avviso.getAvvisoId(), idFileEntry);
} else if (AvvisoUtil.TIPO_AVVISO_FIRMA.equals(avviso.getTipoAvviso())) {
@ -197,30 +154,18 @@ public class SchedulerGeneraDocumento implements MessageListener {
} catch (Exception e) {
_log.error("Error on AvvisoId = " + avviso.getAvvisoId(), e);
}
return idFileEntry;
}
private Avviso gestioneProtocollazione(Avviso avviso, long fileEntryId) throws Exception {
if (Validator.isNull(avviso.getProtocollo())) {
String protocollo = ProtocollazioneUtil.protocollaPartenza(avviso, fileEntryId);
if (Validator.isNull(protocollo)) {
throw new Exception("errore nella protocollazione avviso");
}
avviso = AvvisoLocalServiceUtil.updateAvvisoProtocollo(avviso.getAvvisoId(), protocollo);
}
return avviso;
}
// private void updateProtocollazione(Avviso avviso, DettPratica
// dettPratica, long fileEntryId)
// throws Exception {
//
// ProtocollazioneUtil.protocollaPartenza(dettPratica, avviso, fileEntryId);
// }
}

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

@ -37,22 +37,18 @@ public class SchedulerGeneraProtocollo implements MessageListener {
@Override
public void receive(Message message) throws MessageListenerException {
long avvisoId = 0L;
if (lock.tryLock()) {
_log.debug("SchedulerGeneraProtocollo - inizio");
try {
List<Avviso> avvisiList = AvvisoLocalServiceUtil.getAvvisiPerAggiuntaProtocollo(-1, SIZE);
if (Validator.isNotNull(avvisiList) && !avvisiList.isEmpty()) {
for (Avviso avviso : avvisiList) {
_log.info("SchedulerGeneraProtocollo - avviso " + avviso.getAvvisoId());
try {
avvisoId = avviso.getAvvisoId();
FileEntry fileEntryBase = DLAppLocalServiceUtil.getFileEntry(avviso.getFileEntryIdBase());
if (Validator.isNotNull(fileEntryBase)) {
generaProtocollo(avviso, fileEntryBase);
}
} catch (PortalException e) {
_log.debug("SchedulerGeneraProtocollo - non esiste file base | avvisoId=" + avvisoId);
}
}
}
@ -68,25 +64,20 @@ public class SchedulerGeneraProtocollo implements MessageListener {
long companyId = avviso.getCompanyId();
long userId = avviso.getUserId();
ReportDto reportDto = new ReportDto();
reportDto.setFileEntryIds(new long[] { fileEntry.getFileEntryId() });
reportDto.setFolderId(fileEntry.getFolderId());
reportDto.setFileName(fileEntry.getTitle() + "_protocollato");
reportDto.setType(ReportConstants.ReportType.JRXML_TO_PDF.toString());
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("protocollo", avviso.getProtocollo());
parameters.put("dtProtocollo", avviso.getDtProtocollo().getTime());
parameters.put("oggetto", avviso.getOggettoProtocollo());
reportDto.setParameters(parameters);
ReportResultDto result = ReportUtil.generateProtocollo(companyId, userId, reportDto);
long[] fileEntryIds = result.getFileEntryIds();
if (Validator.isNotNull(fileEntryIds) && (fileEntryIds.length > 0)) {
long idFileEntry = fileEntryIds[0];
Avviso avvisoModified = AvvisoLocalServiceUtil.fetchAvviso(avviso.getAvvisoId());
if (avvisoModified != null) {
avvisoModified.setFileEntryIdProtocollo(idFileEntry);

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

@ -83,20 +83,15 @@ public class SchedulerInvioDocumento implements MessageListener {
private static final int SIZE = 10;
// private static final String TECNICO_MITTENTE =
// "geniocivile.tecnico.mittente";
// private static final String TECNICO_OGGETTO =
// "geniocivile.tecnico.oggetto";
// private static final String TECNICO_CORPO = "geniocivile.tecnico.corpo";
@Override
public void receive(Message message) throws MessageListenerException {
if (lock.tryLock()) {
try {
// campo abilitazione scheduler
for (Company company : CompanyLocalServiceUtil.getCompanies()) {
String condition = ConfigurazioneLocalServiceUtil.findByC_ChiaveString(
company.getCompanyId(), ConfigurazioneConstants.SCHEDULER_INVIO_DOCUMENTO);
String condition = ConfigurazioneLocalServiceUtil.findByC_ChiaveString(company.getCompanyId(),
ConfigurazioneConstants.SCHEDULER_INVIO_DOCUMENTO);
if (Boolean.parseBoolean(condition)) {
processAvvisiInvioSuap();
processIntegrazioniInvioSignal();
@ -117,17 +112,11 @@ public class SchedulerInvioDocumento implements MessageListener {
private void processAvvisiInvioSuap() throws SystemException {
int count = AvvisoLocalServiceUtil.countAvvisiInvioDocumento();
if (count > 0) {
for (int cursor = 0; cursor <= count; cursor += SIZE) {
List<Avviso> avvisi = AvvisoLocalServiceUtil.getAvvisiInvioDocumento(cursor, cursor + SIZE);
for (Avviso avviso : avvisi) {
try {
FileEntry fileEntry = null;
try {
fileEntry = DLAppLocalServiceUtil.getFileEntry(avviso.getFileEntryIdInvio());
@ -135,7 +124,6 @@ public class SchedulerInvioDocumento implements MessageListener {
// bloccato
AvvisoLocalServiceUtil.updateAvvisoErrore(avviso.getAvvisoId(), true);
}
if (fileEntry != null) {
// xxx senza suap non serve inviare
String url = StringPool.BLANK;
@ -143,27 +131,22 @@ public class SchedulerInvioDocumento implements MessageListener {
if (Validator.isNotNull(avviso.getControlloPraticaId())) {
ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil
.getControlloPratica(avviso.getControlloPraticaId());
Avviso avvisoSignal = AvvisoLocalServiceUtil.getAvvisoInvioSignal(avviso
.getAvvisoId());
Avviso avvisoSignal = AvvisoLocalServiceUtil.getAvvisoInvioSignal(avviso.getAvvisoId());
if (avvisoSignal != null) {
invioSignal(avvisoSignal, controlloPratica);
}
Avviso avvisoTempistica = AvvisoLocalServiceUtil.getAvvisoTempistica(avviso
.getAvvisoId());
if (avvisoTempistica != null) {
gestioneTempistica(avvisoTempistica, controlloPratica);
}
Avviso avvisoInvioTecnico = AvvisoLocalServiceUtil
.getAvvisoInvioTecnico(avviso.getAvvisoId());
Avviso avvisoInvioTecnico = AvvisoLocalServiceUtil.getAvvisoInvioTecnico(avviso
.getAvvisoId());
if (avvisoInvioTecnico != null) {
sendToTecnico(avvisoInvioTecnico);
}
}
}
} catch (Exception e) {
_log.error("Error", e);
}
@ -175,13 +158,9 @@ public class SchedulerInvioDocumento implements MessageListener {
private void processAvvisiInvioSignal() throws SystemException {
int count = AvvisoLocalServiceUtil.countAvvisiInvioSignal();
if (count > 0) {
for (int cursor = 0; cursor <= count; cursor += SIZE) {
List<Avviso> avvisi = AvvisoLocalServiceUtil.getAvvisiInvioSignal(cursor, cursor + SIZE);
for (Avviso avviso : avvisi) {
long controlloPraticaId = avviso.getControlloPraticaId();
if (controlloPraticaId != 0) {
@ -190,7 +169,7 @@ public class SchedulerInvioDocumento implements MessageListener {
.getControlloPratica(avviso.getControlloPraticaId());
invioSignal(avviso, controlloPratica);
} catch (Exception e) {
_log.info(e.getMessage() + " " + avviso.getAvvisoId() + " "
_log.info(e.getMessage() + StringPool.SPACE + avviso.getAvvisoId() + StringPool.SPACE
+ avviso.getControlloPraticaId());
_log.debug("Error", e);
}
@ -203,26 +182,19 @@ public class SchedulerInvioDocumento implements MessageListener {
private void processIntegrazioniInvioSignal() throws SystemException {
int count = DettPraticaLocalServiceUtil.countInvioSignal();
if (count > 0) {
for (int cursor = 0; cursor <= count; cursor += SIZE) {
List<DettPratica> integrazioni = DettPraticaLocalServiceUtil.getInviiSignal(cursor, cursor
+ SIZE);
List<DettPratica> integrazioni = DettPraticaLocalServiceUtil.getInviiSignal(cursor, cursor + SIZE);
for (DettPratica integrazione : integrazioni) {
try {
ControlloPratica controlloPratica = null;
List<ControlloPratica> controlli = ControlloPraticaLocalServiceUtil
.findByIntPraticaId_Status(integrazione.getIntPraticaId(),
WorkflowConstants.STATUS_PENDING);
List<ControlloPratica> controlli = ControlloPraticaLocalServiceUtil.findByIntPraticaId_Status(
integrazione.getIntPraticaId(), WorkflowConstants.STATUS_PENDING);
if (controlli.isEmpty()) {
ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(integrazione.getCompanyId());
serviceContext.setScopeGroupId(integrazione.getGroupId());
serviceContext.setUserId(integrazione.getUserId());
controlloPratica = ControlloPraticaLocalServiceUtil.addControlloPratica(
integrazione.getGroupId(), integrazione.getUserId(),
integrazione.getIntPraticaId(), integrazione.getDettPraticaId(), false,
@ -230,8 +202,7 @@ public class SchedulerInvioDocumento implements MessageListener {
} else {
controlloPratica = controlli.get(0);
}
invioSignal(integrazione, controlloPratica,
WorkflowConstants.WORKFLOW_SIGNAL_INTEGRAZIONE);
invioSignal(integrazione, controlloPratica, WorkflowConstants.WORKFLOW_SIGNAL_INTEGRAZIONE);
} catch (Exception e) {
_log.error("Error", e);
}
@ -243,13 +214,9 @@ public class SchedulerInvioDocumento implements MessageListener {
private void processAvvisiTempistica() throws SystemException {
int count = AvvisoLocalServiceUtil.countAvvisiTempistica();
if (count > 0) {
for (int cursor = 0; cursor <= count; cursor += SIZE) {
List<Avviso> avvisi = AvvisoLocalServiceUtil.getAvvisiTempistica(cursor, cursor + SIZE);
for (Avviso avviso : avvisi) {
long controlloPraticaId = avviso.getControlloPraticaId();
if (controlloPraticaId > 0) {
@ -258,7 +225,7 @@ public class SchedulerInvioDocumento implements MessageListener {
.getControlloPratica(controlloPraticaId);
gestioneTempistica(avviso, controlloPratica);
} catch (Exception e) {
_log.debug(e.getMessage() + " " + avviso.getAvvisoId() + " "
_log.debug(e.getMessage() + StringPool.SPACE + avviso.getAvvisoId() + StringPool.SPACE
+ avviso.getControlloPraticaId());
_log.debug("Error", e);
}
@ -268,25 +235,18 @@ public class SchedulerInvioDocumento implements MessageListener {
}
}
/**
* ADT: gestione notifiche al tecnico istruttore. Al momento gestisce solo
* notifica di assegnazione/riassegnazione
*
* @throws SystemException
*/
// ADT: gestione notifiche al tecnico istruttore. Al momento gestisce solo notifica di assegnazione/riassegnazione
private void processAvvisiInvioTecnico() throws SystemException {
int count = AvvisoLocalServiceUtil.countAvvisiInvioTecnicoNew();
if (count > 0) {
_log.info("trovati avvisi per invio email notifiche al tecnico:" + count);
for (int cursor = 0; cursor <= count; cursor += SIZE) {
List<Avviso> avvisi = AvvisoLocalServiceUtil.getAvvisiInvioTecnicoNew(cursor, cursor + SIZE);
for (Avviso avviso : avvisi) {
try {
// trattandosi solo di avvisi con tipo documento CI
// oppure SP si tratta di assegnazione istruttore
// trattandosi solo di avvisi con tipo documento CI oppure SP si tratta di assegnazione
// istruttore
MailUtil.invioNotificaAssegnazioneIstruttore(avviso);
} catch (Exception e) {
_log.error("Error", e);
@ -298,13 +258,10 @@ public class SchedulerInvioDocumento implements MessageListener {
private void invioDocumento(Avviso avviso, FileEntry fileEntry, String url) throws Exception {
// xxx senza suap non serve inviare l'avviso se non metterlo come
// inviato per farlo vedere nel
// FE
// xxx senza suap non serve inviare l'avviso se non metterlo come inviato per farlo vedere nel FE
if (AvvisoUtil.DOCUMENTO_INVIATO.equalsIgnoreCase(avviso.getInviato())) {
return;
}
AvvisoLocalServiceUtil.updateAvvisoInvio(avviso.getAvvisoId());
inviaMailnotifica(avviso.getAvvisoId());
}
@ -312,27 +269,16 @@ public class SchedulerInvioDocumento implements MessageListener {
private void inviaMailnotifica(long avvisoId) throws SystemException, PortalException {
Avviso avviso = AvvisoLocalServiceUtil.getAvviso(avvisoId);
long intPraticaId = avviso.getIntPraticaId();
DettPratica dettPratica = null;
// String tipoDocumento =
// AvvisoUtil.getAllTipoDocumento().containsKey(avviso.getTipoDocumento())
// ?
// AvvisoUtil.getAllTipoDocumento().get(
// avviso.getTipoDocumento()) :
// "label.admingeniocivile.avviso.tipoDocumento.avvisomanuale";
String tipoDocumento = avviso.translateTipoDocumento();
String tipoAvviso = LanguageUtil.get(LocaleUtil.ITALIAN, tipoDocumento);
String tipoAllegato = StringPool.BLANK;
if (avviso.getTipoDocumento().equalsIgnoreCase(StatoPraticaConstants.VIDIMATA)) {
tipoAllegato = "accettazione istanza di ";
if (avviso.getClassName().equals(DettPratica.class.getName())) {
dettPratica = DettPraticaLocalServiceUtil.getDettPratica(avviso.getClassPk());
if (TipoIntegrazioneUtil.VARIAZIONE_SOGGETTO.equalsIgnoreCase(dettPratica
.getTipoIntegrazione())) {
if (TipoIntegrazioneUtil.VARIAZIONE_SOGGETTO.equalsIgnoreCase(dettPratica.getTipoIntegrazione())) {
tipoAllegato += LanguageUtil.get(LocaleUtil.ITALIAN, "label-integrazione-12");
} else if (TipoIntegrazioneUtil.RICHIESTA_INTEGRAZIONE.equalsIgnoreCase(dettPratica
.getTipoIntegrazione())) {
@ -341,8 +287,7 @@ public class SchedulerInvioDocumento implements MessageListener {
tipoAllegato += LanguageUtil.get(LocaleUtil.ITALIAN, "label-integrazione-13");
}
} else {
dettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(avviso
.getIntPraticaId());
dettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(avviso.getIntPraticaId());
if (avviso.getClassName().equals(FineLavori.class.getName())) {
FineLavori fineLavori = FineLavoriLocalServiceUtil.getFineLavori(avviso.getClassPk());
tipoAllegato += LanguageUtil.get(LocaleUtil.ITALIAN,
@ -357,71 +302,53 @@ public class SchedulerInvioDocumento implements MessageListener {
}
} else {
tipoAllegato = "documento di "
+ LanguageUtil.get(LocaleUtil.ITALIAN,
tipoDocumento.replace("tipoDocumento", "documento"));
+ LanguageUtil.get(LocaleUtil.ITALIAN, tipoDocumento.replace("tipoDocumento", "documento"));
dettPratica = DettPraticaLocalServiceUtil.fetchDettPratica(avviso.getClassPk());
if (Validator.isNull(dettPratica)) {
dettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(avviso
.getIntPraticaId());
dettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(avviso.getIntPraticaId());
}
}
List<Soggetto> soggetti = new ArrayList<Soggetto>(
SoggettoLocalServiceUtil.getValidByIntPratica(intPraticaId));
Soggetto committentePrincipale = SoggettoLocalServiceUtil
.getValidByIntPratica_CodiceFiscale_TipologiaSoggetto(intPraticaId,
dettPratica.getCodiceFiscalePrincipaleCommittente(), TipoSoggettoUtil.COMMITTENTE);
List<Soggetto> soggetti = new ArrayList<Soggetto>(SoggettoLocalServiceUtil.getValidByIntPratica(intPraticaId));
Soggetto committentePrincipale = SoggettoLocalServiceUtil.getValidByIntPratica_CodiceFiscale_TipologiaSoggetto(
intPraticaId, dettPratica.getCodiceFiscalePrincipaleCommittente(), TipoSoggettoUtil.COMMITTENTE);
if (null == committentePrincipale) {
_log.error("Il committente principale non esiste, intPraticaId = " + intPraticaId);
} else {
soggetti.remove(committentePrincipale);
}
Set<String> sTo = new HashSet<>();
for (Soggetto soggetto : soggetti) {
sTo.add(soggetto.getEmail());
}
String[] to = sTo.toArray(new String[sTo.size()]);
String[] cc = new String[0];
String[] ccn = new String[0];
String tipoPratica = StringPool.BLANK;
if (AzioniPraticheUtil.isDeposito(intPraticaId)) {
tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-01");
} else if (AzioniPraticheUtil.isAutorizzazione(intPraticaId)) {
tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-02");
}
String url = FascicoloURLUtil.getFascicoloFEViewURL(avviso.getCompanyId(), avviso.getIntPraticaId(),
"/html/fascicolofe/view_fascicolo.jsp", StringPool.BLANK);
JSONObject templateVariables = JSONFactoryUtil.createJSONObject();
templateVariables.put("tipoPratica", tipoPratica);
templateVariables.put("tipoAvviso", tipoAvviso);
templateVariables.put("tipoAllegato", tipoAllegato);
templateVariables.put("link", url);
ServiceContext serviceContext = new ServiceContext();
serviceContext.setScopeGroupId(avviso.getGroupId());
serviceContext.setCompanyId(avviso.getCompanyId());
serviceContext.setUserId(avviso.getUserId());
MailUtil.invioMailNotifica(intPraticaId, dettPratica.getDettPraticaId(), avvisoId,
Avviso.class.getName(), to, cc, ccn, "NOTIFICA-SOGGETTI-ATTIVI", templateVariables, null,
serviceContext);
MailUtil.invioMailNotifica(intPraticaId, dettPratica.getDettPraticaId(), avvisoId, Avviso.class.getName(), to,
cc, ccn, "NOTIFICA-SOGGETTI-ATTIVI", templateVariables, null, serviceContext);
if (null != committentePrincipale) {
to = new String[] { committentePrincipale.getEmail() };
List<FileAttachment> allegati = new ArrayList<FileAttachment>();
long fileEntryId = 0l;
long fileEntryId = 0L;
String[] pdfInvio = new String[] { StatoPraticaConstants.CAMBIO_ISTRUTTORE,
StatoPraticaConstants.SOTTOPOSTA_A_PARERE };
// se è avviso di Vidimazione o di Avvio procedimento o di Cambio
// Istruttore => file protocollato
// se è avviso di Vidimazione o di Avvio procedimento o di Cambio Istruttore => file protocollato
if (avviso.getTipoDocumento().equalsIgnoreCase(StatoPraticaConstants.VIDIMATA)
|| ArrayUtil.contains(pdfInvio, avviso.getTipoDocumento())) {
if (Validator.isNotNull(avviso.getFileEntryIdProtocollo())) {
@ -434,45 +361,34 @@ public class SchedulerInvioDocumento implements MessageListener {
fileEntryId = avviso.getFileEntryIdInvio();
}
}
if (Validator.isNotNull(fileEntryId)) {
FileAttachment fileAttachment = new FileAttachment();
fileAttachment.setFileEntryId(avviso.getFileEntryIdProtocollo());
fileAttachment.generateFile();
allegati.add(fileAttachment);
}
MailUtil.invioMailNotifica(intPraticaId, dettPratica.getDettPraticaId(), avvisoId,
Avviso.class.getName(), to, cc, ccn, "NOTIFICA-SOGGETTI-ATTIVI", templateVariables,
allegati, serviceContext);
String[] suapEnabled = new String[] { StatoPraticaConstants.CONFORME,
StatoPraticaConstants.NON_CONFORME };
MailUtil.invioMailNotifica(intPraticaId, dettPratica.getDettPraticaId(), avvisoId, Avviso.class.getName(),
to, cc, ccn, "NOTIFICA-SOGGETTI-ATTIVI", templateVariables, allegati, serviceContext);
String[] suapEnabled = new String[] { StatoPraticaConstants.CONFORME, StatoPraticaConstants.NON_CONFORME };
if ((AzioniPraticheUtil.isAutorizzazione(intPraticaId) && ArrayUtil.contains(suapEnabled,
avviso.getTipoDocumento()))
|| (StatoPraticaConstants.VIDIMATA.equals(avviso.getTipoDocumento()))) {
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId);
Territorio territorio = TerritorioLocalServiceUtil
.getTerritorio(intPratica.getTerritorioId());
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId());
Comune comune = ComuneLocalServiceUtil.getComune(territorio.getComuneId());
String eMail = StringPool.BLANK;
if (dettPratica.getSuap()) {
eMail = comune.getMailSuap();
} else {
eMail = comune.getMailSue();
}
to = new String[] { eMail };
templateVariables.put("cont", StringPool.BLANK);
templateVariables.put("anno", StringPool.BLANK);
templateVariables.put(
"dataVidimazione",
FastDateFormatFactoryUtil.getSimpleDateFormat("dd/MM/yyyy HH:mm").format(
intPratica.getDtPratica()));
if (to.length > 0 && to[0] != StringPool.BLANK) {
MailUtil.invioMailNotifica(intPraticaId, dettPratica.getDettPraticaId(), avvisoId,
Avviso.class.getName(), to, cc, ccn, "INVIO-SUAP", templateVariables, allegati,
@ -480,7 +396,6 @@ public class SchedulerInvioDocumento implements MessageListener {
}
}
}
}
private void invioSignal(DettPratica integrazione, ControlloPratica controlloPratica, String signalName)
@ -491,37 +406,23 @@ public class SchedulerInvioDocumento implements MessageListener {
long companyId = controlloPratica.getCompanyId();
long userId = WorkflowUtil.getWorkflowInstanceCreateUserId(controlloPratica);
try {
WorkflowInstance workflowInstance = WorkflowInstanceManagerUtil.getWorkflowInstance(companyId,
workflowInstanceId);
// Fix per errore su No KaleoTransition exists with the key
// {kaleoNodeId=xxx,
// name=signal_cittadino}
// Fix per errore su No KaleoTransition exists with the key {kaleoNodeId=xxx, name=signal_cittadino}
ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(companyId);
KaleoInstance kaleoInstance = KaleoInstanceLocalServiceUtil.getKaleoInstance(workflowInstanceId);
KaleoInstanceToken rootKaleoInstanceToken = kaleoInstance
.getRootKaleoInstanceToken(serviceContext);
KaleoInstanceToken rootKaleoInstanceToken = kaleoInstance.getRootKaleoInstanceToken(serviceContext);
// ADT:bug importazione portos1 in richiesta di integraione
this.checkPresenzaIstruttore(controlloPratica, integrazione, serviceContext, userId,
workflowInstanceId);
if (rootKaleoInstanceToken.getCurrentKaleoNodeName().equals(
WorkflowConstants.WORKFLOW_SIGNAL_INTEGRAZIONE)) {
WorkflowInstanceManagerUtil.signalWorkflowInstance(companyId, userId, workflowInstanceId,
signalName, workflowInstance.getWorkflowContext());
this.checkPresenzaIstruttore(controlloPratica, integrazione, serviceContext, userId, workflowInstanceId);
if (rootKaleoInstanceToken.getCurrentKaleoNodeName().equals(WorkflowConstants.WORKFLOW_SIGNAL_INTEGRAZIONE)) {
WorkflowInstanceManagerUtil.signalWorkflowInstance(companyId, userId, workflowInstanceId, signalName,
workflowInstance.getWorkflowContext());
}
DettPraticaLocalServiceUtil.updateSignal(integrazione.getDettPraticaId(), new Date());
} catch (WorkflowException e) {
_log.error("Error on controllo pratica id : " + controlloPratica.getControlloPraticaId(), e);
} catch (PortalException e) {
_log.error("Error on controllo pratica id : " + controlloPratica.getControlloPraticaId(), e);
}
}
private void invioSignal(Avviso avviso, ControlloPratica controlloPratica) throws SystemException,
@ -534,31 +435,18 @@ public class SchedulerInvioDocumento implements MessageListener {
long userId = WorkflowUtil.getWorkflowInstanceCreateUserId(controlloPratica);
String signalName = WorkflowUtil.getSignalByTipoDocumento(avviso.getTipoDocumento());
try {
WorkflowInstance workflowInstance = WorkflowInstanceManagerUtil.getWorkflowInstance(
companyId, workflowInstanceId);
// Fix per errore su No KaleoTransition exists with the key
// {kaleoNodeId=xxx, name=signal_ff}
WorkflowInstance workflowInstance = WorkflowInstanceManagerUtil.getWorkflowInstance(companyId,
workflowInstanceId);
// Fix per errore su No KaleoTransition exists with the key {kaleoNodeId=xxx, name=signal_ff}
ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(companyId);
KaleoInstance kaleoInstance = KaleoInstanceLocalServiceUtil
.getKaleoInstance(workflowInstanceId);
KaleoInstanceToken rootKaleoInstanceToken = kaleoInstance
.getRootKaleoInstanceToken(serviceContext);
KaleoInstance kaleoInstance = KaleoInstanceLocalServiceUtil.getKaleoInstance(workflowInstanceId);
KaleoInstanceToken rootKaleoInstanceToken = kaleoInstance.getRootKaleoInstanceToken(serviceContext);
if (rootKaleoInstanceToken.getCurrentKaleoNodeName().equals(signalName)) {
WorkflowInstanceManagerUtil.signalWorkflowInstance(companyId, userId, workflowInstanceId,
signalName, workflowInstance.getWorkflowContext());
}
AvvisoLocalServiceUtil.updateAvvisoSignal(avviso.getAvvisoId(), new Date());
// TODO capire se serve sempre
// if (signalName.equals(WorkflowConstants.JBPM_SIGNAL_INVIO)) {
// DettPraticaLocalServiceUtil.updateDettPraticaStatusTask(dettPratica.getDettPraticaId(),
// 0);
// }
} catch (WorkflowException e) {
_log.error("Error on controllo pratica id : " + controlloPratica.getControlloPraticaId(), e);
} catch (PortalException e) {
_log.error("Error on controllo pratica id : " + controlloPratica.getControlloPraticaId(), e);
}
@ -572,7 +460,6 @@ public class SchedulerInvioDocumento implements MessageListener {
// FIXME la tempistica non va bene mette le date sbagliate
String tipoDocumento = avviso.getTipoDocumento();
// String tipoDocumento = avviso.translateTipoDocumento();
Date dtInvio = avviso.getDtInvio();
if (tipoDocumento.equals(StatoPraticaConstants.SOTTOPOSTA_A_PARERE)) {
long intPraticaId = controlloPratica.getIntPraticaId();
@ -580,33 +467,25 @@ public class SchedulerInvioDocumento implements MessageListener {
try {
intPratica = IntPraticaLocalServiceUtil.getIntPratica(controlloPratica.getIntPraticaId());
} catch (PortalException e) {
_log.error(e, e);
}
// FIX prendo la data di vidimazione e non quella di sottoposto a
// parere per avvio dei tempi
// FIX prendo la data di vidimazione e non quella di sottoposto a parere per avvio dei tempi
Avviso avvisoExtra = null;
if (Validator.isNotNull(intPratica.getDtSorteggio())) {
dtInvio = intPratica.getDtSorteggio();
} else {
List<Avviso> documentiVid = AvvisoLocalServiceUtil.findByIntPraticaId_tipoDocumento(
intPraticaId, StatoPraticaConstants.VIDIMATA);
List<Avviso> documentiVid = AvvisoLocalServiceUtil.findByIntPraticaId_tipoDocumento(intPraticaId,
StatoPraticaConstants.VIDIMATA);
avvisoExtra = documentiVid.get(0);
dtInvio = avvisoExtra.getDtInvio();
}
// fino qui
// TempisticaLocalServiceUtil.addTempistica(intPraticaId,
// dettPraticaId, TempisticaConstants.TIPO_PRATICA, dtInvio,
// serviceContext);
Date now = new Date();
// FIX come sopra
if (avvisoExtra != null) {
AvvisoLocalServiceUtil.updateAvvisoTempistica(avvisoExtra.getAvvisoId(), now);
}
// fino qui
AvvisoLocalServiceUtil.updateAvvisoTempistica(avviso.getAvvisoId(), now);
} else if (tipoDocumento.equals(StatoPraticaConstants.INTEGRAZIONE)) {
long intPraticaId = controlloPratica.getIntPraticaId();
@ -614,8 +493,7 @@ public class SchedulerInvioDocumento implements MessageListener {
ServiceContext serviceContext = getServiceContext(controlloPratica);
Tempistica tempistica = TempisticaLocalServiceUtil.getTempistica(serviceContext.getCompanyId(),
intPraticaId, TempisticaConstants.TIPO_PRATICA, false);
// tempstica = null se pratica con cambio di stato forzato e no
// workflow
// tempstica = null se pratica con cambio di stato forzato e no workflow
if (tempistica != null) {
TempisticaLocalServiceUtil.stopTempistica(tempistica.getTempisticaId(), dtInvio);
}
@ -630,8 +508,7 @@ public class SchedulerInvioDocumento implements MessageListener {
ServiceContext serviceContext = getServiceContext(controlloPratica);
Tempistica tempistica = TempisticaLocalServiceUtil.getTempistica(serviceContext.getCompanyId(),
intPraticaId, TempisticaConstants.TIPO_PRATICA, false);
// tempstica = null se pratica con cambio di stato forzato e no
// workflow
// tempstica = null se pratica con cambio di stato forzato e no workflow
if (tempistica != null) {
TempisticaLocalServiceUtil.concludiTempistica(tempistica.getTempisticaId(), dtInvio);
AvvisoLocalServiceUtil.updateAvvisoTempistica(avviso.getAvvisoId(), new Date());
@ -644,87 +521,6 @@ public class SchedulerInvioDocumento implements MessageListener {
}
private void sendToTecnico(Avviso avviso) throws SystemException, PortalException {
// TODO inviare la mail con il nuovo sistema di mail.
// System.out.println("inviare la mail con il nuovo sistema di mail.");
// DettPratica dettPratica =
// DettPraticaLocalServiceUtil.getDettPratica(avviso.getDettPraticaId());
// IntPratica intPratica =
// IntPraticaLocalServiceUtil.getIntPratica(dettPratica.getIntPraticaId());
// Territorio territorio =
// TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId());
// Comune comune =
// ComuneLocalServiceUtil.getComune(territorio.getComuneId());
//
// // tecnico da workflow
// User user = null;
// if (intPratica.isVariante()) {
// IntPratica intPraticaVariata =
// IntPraticaLocalServiceUtil.findByPratica_da_variare(intPratica.getTerritorioId(),
// true,
// intPratica.getIntPraticaId(), intPratica.getNumeroProgetto()).get(0);
// user =
// UserLocalServiceUtil.fetchUser(intPraticaVariata.getStatusByUserId());
// } else {
// user =
// UserLocalServiceUtil.fetchUser(intPratica.getStatusByUserId());
// }
//
// if (user == null) {
// // pratica senza workflow o nuova domanda
// AvvisoLocalServiceUtil.updateAvvisoInviatoTecnico(avviso.getAvvisoId(),
// true);
// } else {
//
// String destinatario = user.getEmailAddress();
//
// String mittente = PortletProps.get(TECNICO_MITTENTE);
//
// String oggetto = PortletProps.get(TECNICO_OGGETTO);
//
// // variante o integrazione
// String tipoPratica = StringPool.BLANK;
// if (intPratica.isVariante()) {
// tipoPratica = LanguageUtil.get(Locale.ITALIAN,
// "label.admingeniocivile.statopratica.variante");
// } else {
// tipoPratica =
// LanguageUtil.get(Locale.ITALIAN,
// TipoIntegrazioneConstants.toLabel(dettPratica.getTipoIntegrazione()));
// }
// String tecnico = StringPool.BLANK;
// if (intPratica.getStatusByUserId() != 0l) {
// tecnico =
// UserLocalServiceUtil.getUser(intPratica.getStatusByUserId()).getFullName();
// }
// String corpo =
// StringUtil.replace(
// PortletProps.get(TECNICO_CORPO),
// new String[] {"[$NUMERO_PRATICA$]", "[$TIPO_PRATICA$]", "[$COMUNE$]",
// "[$DATA$]",
// "[$DESCRIZIONE_PROGETTO$]", "[$TECNICO$]"},
// new String[] {
// intPratica.getNumeroProgetto(),
// tipoPratica,
// comune.getDescLong(),
// FastDateFormatFactoryUtil.getSimpleDateFormat("dd/MM/yyyy",
// Locale.ITALY).format(
// avviso.getCreateDate()), intPratica.getDescLongIntervento(),
// tecnico});
//
// try {
//
// CustomMailEngine.send(new InternetAddress(mittente), new
// InternetAddress(destinatario),
// oggetto, corpo, true);
//
// AvvisoLocalServiceUtil.updateAvvisoInviatoTecnico(avviso.getAvvisoId(),
// true);
//
// } catch (Exception e) {
// _log.error("Error", e);
// }
// }
}
private ServiceContext getServiceContext(ControlloPratica controlloPratica) {
@ -736,25 +532,18 @@ public class SchedulerInvioDocumento implements MessageListener {
return serviceContext;
}
/**
* ADT: check congruenza WF - presenza dell'istruttore per pratiche
* importate da PORTOS1
*
*
* @param transitionName
* @param workflowTaskId
*/
// ADT: check congruenza WF - presenza dell'istruttore per pratiche importate da PORTOS1
private void checkPresenzaIstruttore(ControlloPratica controlloPratica, DettPratica integrazione,
ServiceContext serviceContext, long userId, long workflowInstanceId) {
try {
Map<String, Serializable> wfParameters = WorkflowUtil.getFormParameters(controlloPratica);
String istruttore = (String) wfParameters.get("istruttore");
_log.info("checkPresenzaIstruttore risposta integrazioni - istruttore presente sul workflow= "
+ istruttore + " - -controlloPratica=" + controlloPratica.getControlloPraticaId());
_log.info("checkPresenzaIstruttore risposta integrazioni - istruttore presente sul workflow= " + istruttore
+ " - -controlloPratica=" + controlloPratica.getControlloPraticaId());
if (istruttore == null) {
_log.info("checkPresenzaIstruttore gestione risposta integrazioni - rilevata incongrueza WF "
+ "- istruttore non presente per dettpraticaid= "
+ integrazione.getDettPraticaId()
+ "- istruttore non presente per dettpraticaid= " + integrazione.getDettPraticaId()
+ " -controlloPratica=" + controlloPratica.getControlloPraticaId());
long istruttoreId = IntPraticaLocalServiceUtil.getIntPratica(integrazione.getIntPraticaId())
.getStatusByUserId();
@ -765,8 +554,8 @@ public class SchedulerInvioDocumento implements MessageListener {
JSONSerializer jsonSerializer = JSONFactoryUtil.createJSONSerializer();
jsonFormParameters = jsonSerializer.serialize(parametri);
serviceContext.setUserId(userId);
FormLogLocalServiceUtil.addFormLog(workflowInstanceId, 0l, "cambio-istruttore",
jsonFormParameters, serviceContext);
FormLogLocalServiceUtil.addFormLog(workflowInstanceId, 0L, "cambio-istruttore", jsonFormParameters,
serviceContext);
_log.info("checkPresenzaIstruttore OK per controlloPratica = "
+ controlloPratica.getControlloPraticaId());
} else {
@ -774,15 +563,9 @@ public class SchedulerInvioDocumento implements MessageListener {
+ controlloPratica.getControlloPraticaId() + " - istruttore non calcolato - ");
}
}
} catch (Exception e) {
_log.error("checkPresenzaIstruttore KO per controlloPratica = "
+ controlloPratica.getControlloPraticaId() + " [" + e.getMessage() + " , " + e.getCause()
+ "]");
_log.error("checkPresenzaIstruttore KO per controlloPratica = " + controlloPratica.getControlloPraticaId()
+ " [" + e.getMessage() + StringPool.COMMA_AND_SPACE + e.getCause() + StringPool.CLOSE_BRACKET);
}
}
}

6
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/base/IntPraticaLocalServiceClpInvoker.java

@ -210,9 +210,7 @@ public class IntPraticaLocalServiceClpInvoker {
_methodName222 = "updateStatoPratica";
_methodParameterTypes222 = new String[] {
"long", "long", "java.lang.String"
};
_methodParameterTypes222 = new String[] { "long", "java.lang.String" };
_methodName224 = "updateIntPraticaSorteggio";
@ -690,7 +688,7 @@ public class IntPraticaLocalServiceClpInvoker {
if (_methodName222.equals(name) &&
Arrays.deepEquals(_methodParameterTypes222, parameterTypes)) {
return IntPraticaLocalServiceUtil.updateStatoPratica(((Long)arguments[0]).longValue(),
((Long)arguments[1]).longValue(), (java.lang.String)arguments[2]);
(java.lang.String)arguments[1]);
}
if (_methodName224.equals(name) &&

16
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/ControlloPraticaLocalServiceImpl.java

@ -144,7 +144,7 @@ public class ControlloPraticaLocalServiceImpl extends ControlloPraticaLocalServi
resourceLocalService.addModelResources(entry, serviceContext);
// aggiorno int e dett pratica per avvio workflow
IntPratica intPratica = intPraticaLocalService.updateStatoPratica(intPraticaId, dettPraticaId,
IntPratica intPratica = intPraticaLocalService.updateStatoPratica(intPraticaId,
StatoPraticaConstants.SOTTOPOSTA_A_PARERE);
if (updateFlagControlloObbligatorio && Constants.TIPO_PRATICA_DEPOSITO.equals(intPratica.getTipoPratica())) {
intPratica.setControlloObbligatorio(true);
@ -449,28 +449,21 @@ public class ControlloPraticaLocalServiceImpl extends ControlloPraticaLocalServi
default:
break;
}
if (updateIntPratica) {
intPraticaLocalService.updateStatoPratica(controlloPratica.getIntPraticaId(),
controlloPratica.getDettPraticaId(), esito);
intPraticaLocalService.updateStatoPratica(controlloPratica.getIntPraticaId(), esito);
}
}
Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class);
indexer.reindex(controlloPratica);
return ramoWorkflow;
}
private String getEsitoFinale(long controlloPraticaId, Map<String, Serializable> workflowContext)
throws PortalException, SystemException {
// Map<String, String> parametri = (Map<String, String>)
// workflowContext.get("CONTEXT_TASK_FORM_PARAMETERS");
ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil.getControlloPratica(controlloPraticaId);
Map<String, Serializable> parametri = WorkflowUtil.getFormParameters(controlloPratica);
String esitoScelta = (String) parametri.get(WorkflowConstants.WORKFLOW_TASKNAME_ESITO);
if (StatoPraticaConstants.CONFORME.equalsIgnoreCase(esitoScelta)
&& AzioniPraticheUtil.isAutorizzazione(controlloPratica.getIntPraticaId())) {
esitoScelta = StatoPraticaConstants.AUTORIZZATA;
@ -478,7 +471,6 @@ public class ControlloPraticaLocalServiceImpl extends ControlloPraticaLocalServi
&& AzioniPraticheUtil.isAutorizzazione(controlloPratica.getIntPraticaId())) {
esitoScelta = StatoPraticaConstants.NON_AUTORIZZATA;
}
return esitoScelta;
}
@ -497,13 +489,10 @@ public class ControlloPraticaLocalServiceImpl extends ControlloPraticaLocalServi
throws PortalException, SystemException {
ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil.getControlloPratica(controlloPraticaId);
JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
jsonObject.put("istruttore", jsonArray);
Role role = RoleLocalServiceUtil.getRole(controlloPratica.getCompanyId(), "portos_istruttore");
List<UserGroupRole> userGroupRoles = UserGroupRoleLocalServiceUtil.getUserGroupRolesByGroupAndRole(
controlloPratica.getGroupId(), role.getRoleId());
for (UserGroupRole userGroupRole : userGroupRoles) {
@ -513,7 +502,6 @@ public class ControlloPraticaLocalServiceImpl extends ControlloPraticaLocalServi
istruttore.put("default", false);
jsonArray.put(istruttore);
}
return jsonObject.toString();
}

903
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/DettPraticaLocalServiceImpl.java

File diff soppresso perché troppo grande Load Diff

9
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/IntPraticaLocalServiceImpl.java

@ -737,18 +737,14 @@ public class IntPraticaLocalServiceImpl extends IntPraticaLocalServiceBaseImpl {
}
// TODO rimuovere dettPraticaId
@Override
@Indexable(type = IndexableType.REINDEX)
public IntPratica updateStatoPratica(long intPraticaId, long dettPraticaId, String statoPratica)
throws PortalException, SystemException {
public IntPratica updateStatoPratica(long intPraticaId, String statoPratica) throws PortalException,
SystemException {
IntPratica intPratica = intPraticaLocalService.getIntPratica(intPraticaId);
intPratica.setModifiedDate(new Date());
intPratica.setStatoPratica(statoPratica);
return intPraticaLocalService.updateIntPratica(intPratica);
}
@ -760,6 +756,7 @@ public class IntPraticaLocalServiceImpl extends IntPraticaLocalServiceBaseImpl {
@Override
public IntPratica updateIntPraticaSorteggio(long intPraticaId, Date dtSorteggio) throws SystemException {
// TODO vedere se va cambiato lo stato
return updateIntPraticaSorteggio(intPraticaId, dtSorteggio, null);
}

66
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/IntPraticaServiceImpl.java

@ -1,13 +1,13 @@
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under the terms of the
* GNU Lesser General Public License as published by the Free Software Foundation; either version
* 2.1 of the License, or (at your option) any later version.
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library 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
* Lesser General Public License for more details.
* This library 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 Lesser General Public License for more
* details.
*/
package it.tref.liferay.portos.bo.service.impl;
@ -37,13 +37,12 @@ import com.liferay.portal.service.ServiceContext;
* The implementation of the int pratica 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.tref.liferay.portos.bo.service.IntPraticaService} 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.tref.liferay.portos.bo.service.IntPraticaService} 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 Davide Barbagallo, 3F Consulting
@ -53,16 +52,17 @@ import com.liferay.portal.service.ServiceContext;
public class IntPraticaServiceImpl extends IntPraticaServiceBaseImpl {
/*
* NOTE FOR DEVELOPERS: Never reference this interface directly. Always use {@link
* it.tref.liferay.portos.bo.service.IntPraticaServiceUtil} to access the int pratica remote
* service.
* it.tref.liferay.portos.bo.service.IntPraticaServiceUtil} to access the int pratica remote service.
*/
@Override
public IntPratica getIntPratica(long intPraticaId) throws PortalException, SystemException {
// TODO: Permessi
return intPraticaLocalService.getIntPratica(intPraticaId);
}
@Override
public void deleteIntPratica(long intPraticaId, long userId) throws PortalException, SystemException {
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId);
@ -89,7 +89,7 @@ public class IntPraticaServiceImpl extends IntPraticaServiceBaseImpl {
//
// }
@Override
public void sospendiPratica(long intPraticaId, boolean sospesa) throws PortalException, SystemException {
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId);
@ -100,8 +100,9 @@ public class IntPraticaServiceImpl extends IntPraticaServiceBaseImpl {
}
public void cambiaTitolare(long intPraticaId, long soggettoId, ServiceContext serviceContext) throws PortalException,
SystemException {
@Override
public void cambiaTitolare(long intPraticaId, long soggettoId, ServiceContext serviceContext)
throws PortalException, SystemException {
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId);
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId());
@ -110,95 +111,108 @@ public class IntPraticaServiceImpl extends IntPraticaServiceBaseImpl {
intPraticaLocalService.cambiaTitolare(intPraticaId, soggettoId, serviceContext);
}
@Override
public void updateStatoPratica(long intPraticaId, String statoPratica) throws PortalException, SystemException {
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId);
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId());
IntPraticaPermission.check(getPermissionChecker(), territorio.getGroupId(), ActionKeys.CAMBIO_STATO);
intPraticaLocalService.updateStatoPratica(intPraticaId, 0l, statoPratica);
intPraticaLocalService.updateStatoPratica(intPraticaId, statoPratica);
}
@Override
public List<IntPratica> search(List<Long> groupIds, int start, int end) throws SystemException {
// TODO Modificare tramite Indexer
// TODO Aggiungere controllo permessi
return intPraticaLocalService.search(groupIds, start, end);
}
@Override
public int countSearch(List<Long> groupIds) throws SystemException {
// TODO Modificare tramite Indexer
// TODO Aggiungere controllo permessi
return intPraticaLocalService.countSearch(groupIds);
}
@Override
public List<IntPratica> findByCompanyIdSoggettoProgetti(long companyId, long soggettoId) throws SystemException,
PortalException {
return intPraticaLocalService.findByCompanyIdSoggettoProgetti(companyId, soggettoId);
}
public int countByCompanyIdSoggettoProgetti(long companyId, long soggettoId) throws SystemException, PortalException {
@Override
public int countByCompanyIdSoggettoProgetti(long companyId, long soggettoId) throws SystemException,
PortalException {
return intPraticaLocalService.countByCompanyIdSoggettoProgetti(companyId, soggettoId);
}
@Override
public List<IntPratica> findByCompanyIdSoggettoArchivio(long companyId, long soggettoId) throws SystemException,
PortalException {
return intPraticaLocalService.findByCompanyIdSoggettoArchivio(companyId, soggettoId);
}
public int countByCompanyIdSoggettoArchivio(long companyId, long soggettoId) throws SystemException, PortalException {
@Override
public int countByCompanyIdSoggettoArchivio(long companyId, long soggettoId) throws SystemException,
PortalException {
return intPraticaLocalService.countByCompanyIdSoggettoArchivio(companyId, soggettoId);
}
@Override
public List<IntPratica> findByCompanyIdSoggettoAltriProgetti(long companyId, long soggettoId, int start, int end)
throws SystemException, PortalException {
return intPraticaLocalService.findByCompanyIdSoggettoAltriProgetti(companyId, soggettoId, start, end);
}
@Override
public int countByCompanyIdSoggettoAltriProgetti(long companyId, long soggettoId) throws SystemException,
PortalException {
return intPraticaLocalService.countByCompanyIdSoggettoAltriProgetti(companyId, soggettoId);
}
@Override
public List<IntPratica> findByCanAddFineLavori(long companyId, String codiceFiscale, int start, int end)
throws SystemException, PortalException {
return intPraticaLocalService.findByCanAddFineLavori(companyId, codiceFiscale, start, end);
}
@Override
public int countByCanAddFineLavori(long companyId, String codiceFiscale) throws SystemException, PortalException {
return intPraticaLocalService.countByCanAddFineLavori(companyId, codiceFiscale);
}
@Override
public List<IntPratica> findByCanAddCollaudo(long companyId, String codiceFiscale, int start, int end)
throws SystemException, PortalException {
return intPraticaLocalService.findByCanAddCollaudo(companyId, codiceFiscale, start, end);
}
@Override
public int countByCanAddCollaudo(long companyId, String codiceFiscale) throws SystemException, PortalException {
return intPraticaLocalService.countByCanAddCollaudo(companyId, codiceFiscale);
}
@Override
public FileEntry allegaFileAnnullamento(long intPraticaId, byte[] content, String sourceFileName,
String jsonFirmatari, ServiceContext serviceContext) throws SystemException, PortalException, IOException {
return intPraticaLocalService.allegaFileAnnullamento(intPraticaId, content, sourceFileName,jsonFirmatari, serviceContext);
return intPraticaLocalService.allegaFileAnnullamento(intPraticaId, content, sourceFileName, jsonFirmatari,
serviceContext);
}
@Override
public void completeAnnullamento(long intPraticaId, long userId) throws PortalException, SystemException {
if (!AzioniPraticheUtil.isAllowedAction(intPraticaId, AzioniPraticheUtil.ACTION_ANNULLA)
@ -208,12 +222,14 @@ public class IntPraticaServiceImpl extends IntPraticaServiceBaseImpl {
intPraticaLocalService.completeAnnullamento(intPraticaId);
}
@Override
public void cambiaIstruttore(long intPraticaId, long controlloPraticaId, long istruttoreId) throws PortalException,
SystemException {
intPraticaLocalService.cambiaIstruttore(intPraticaId, controlloPraticaId, istruttoreId);
}
@Override
public String geosisma(long intPraticaId) throws PortalException, SystemException {
JSONObject json = JSONFactoryUtil.createJSONObject();

53
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/util/ProtocollazioneUtil.java

@ -16,11 +16,11 @@ import it.tref.liferay.portos.bo.shared.protocollo.model.Protocollo;
import it.tref.liferay.portos.bo.shared.protocollo.model.Protocollo.TipoProtocollo;
import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.ParseException;
@ -39,6 +39,9 @@ import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSONObject;
import com.liferay.portal.kernel.repository.model.FileEntry;
import com.liferay.portal.kernel.servlet.HttpHeaders;
import com.liferay.portal.kernel.servlet.HttpMethods;
import com.liferay.portal.kernel.util.ContentTypes;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.StreamUtil;
@ -53,6 +56,7 @@ import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil;
public class ProtocollazioneUtil {
public static String protocollaPartenza(Avviso avviso, Long fileEntryId) throws Exception {
String protocollo = null;
InputStream inputStream = null;
try {
@ -72,8 +76,8 @@ public class ProtocollazioneUtil {
allegato.setFileId("0");
allegato.setFileSha256(sha256);
}
// utilizzato anche come discriminate tra la 1a e la 2a chiamata 1a recupero numero protocollo -> 1 allegato
// finto 2a aggiorno dati del documento prodotto -> 2 allegati, il 1o giusto e il 2o per recupero num
// utilizzato anche come discriminate tra la 1ª e la 2ª chiamata 1ª recupero numero protocollo -> 1 allegato
// finto 2ª aggiorno dati del documento prodotto -> 2 allegati, il 1º giusto e il 2º per recupero num
// protocollo
Protocollo protocolloBean = new Protocollo();
protocolloBean.setOggetto(generaOggettoProtocollo(avviso.getClassName(), avviso.getAvvisoId()));
@ -92,6 +96,7 @@ public class ProtocollazioneUtil {
}
public static String protocollaArrivo(Object praticaInstance, String title) throws Exception {
long groupId = 0L;
long praticaId = 0L;
long companyId = 0L;
@ -125,9 +130,6 @@ public class ProtocollazioneUtil {
if (Validator.isNull(sha256)) {
InputStream inputStream = null;
try {
if (docPratica.getDlFileEntryId() == 0L) {
FilesImporter.importaFile(docPratica.getDocPraticaId(), DocPratica.class.getName());
}
FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(docPratica.getDlFileEntryId());
inputStream = DLFileEntryLocalServiceUtil.getFileAsStream(fileEntry.getFileEntryId(),
fileEntry.getVersion());
@ -156,6 +158,7 @@ public class ProtocollazioneUtil {
public static String protocollaArrivoAccessoAtti(long groupId, long companyId, String userName, long accessoAttiId,
String className) throws Exception {
List<File> allegati = new ArrayList<File>();
File allegato = new File();
String doc = String.valueOf(accessoAttiId);
@ -176,6 +179,7 @@ public class ProtocollazioneUtil {
}
public static String generaOggettoProtocollo(String className, long classPk) {
try {
Avviso avviso = AvvisoLocalServiceUtil.fetchAvviso(classPk);
if (Validator.isNotNull(avviso)) {
@ -187,24 +191,28 @@ public class ProtocollazioneUtil {
return "Oggetto: " + className + StringPool.SPACE + classPk;
}
public static List<OggettoProtocollo> csvToOggettoProtocollo(java.io.File file) throws FileNotFoundException,
IOException, ParseException {
String[] FILE_PROTOCOLLO_HEADER = { "id", "mittente/destinatario id", "ufficio id", "oggetto",
private static final String[] FILE_PROTOCOLLO_HEADER = { "id", "mittente/destinatario id", "ufficio id", "oggetto",
"numero fascicolo", "data inserimento", "tipo" };
private static List<OggettoProtocollo> csvToOggettoProtocollo(byte[] bytes) throws IOException, ParseException {
CSVFormat format = CSVFormat.EXCEL.withTrailingDelimiter().withHeader(FILE_PROTOCOLLO_HEADER)
.withSkipHeaderRecord().withIgnoreEmptyLines().withIgnoreSurroundingSpaces();
Iterable<CSVRecord> records = format.parse(new FileReader(file));
Reader reader = new InputStreamReader(new ByteArrayInputStream(bytes));
Iterable<CSVRecord> records = format.parse(reader);
List<OggettoProtocollo> listaOggettoProtocollo = new ArrayList<>();
for (CSVRecord csvRecord : records) {
listaOggettoProtocollo.add(new OggettoProtocollo(csvRecord.get("id"), csvRecord
.get("mittente/destinatario id"), csvRecord.get("ufficio id"), csvRecord.get("oggetto"), csvRecord
.get("numero fascicolo"), csvRecord.get("data inserimento"), csvRecord.get("tipo")));
reader.close();
for (CSVRecord record : records) {
listaOggettoProtocollo.add(new OggettoProtocollo(record.get("id"), record.get("mittente/destinatario id"),
record.get("ufficio id"), record.get("oggetto"), record.get("numero fascicolo"), record
.get("data inserimento"), record.get("tipo")));
}
return listaOggettoProtocollo;
}
public static List<OggettoProtocollo> searchProtocolli(HttpServletRequest request, long companyId, long userId) {
List<OggettoProtocollo> result = Collections.emptyList();
List<OggettoProtocollo> result = Collections.<OggettoProtocollo> emptyList();
String ufficioIds = StringPool.BLANK;
String anno = ParamUtil.getString(request, "annoRiferimento");
String numeroProtocollo = ParamUtil.getString(request, "numeroProtocollo");
@ -239,19 +247,14 @@ public class ProtocollazioneUtil {
URL url = new URL(urlCSVService + data);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestMethod(HttpMethods.POST);
conn.setRequestProperty(HttpHeaders.CONTENT_TYPE, ContentTypes.APPLICATION_JSON);
if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
}
byte[] bytes = IOUtils.toByteArray(conn.getInputStream());
java.io.File tempFile = java.io.File.createTempFile("prefix", "suffix", null);
FileOutputStream fos = new FileOutputStream(tempFile);
fos.write(bytes);
fos.flush();
fos.close();
conn.disconnect();
return ProtocollazioneUtil.csvToOggettoProtocollo(tempFile);
return csvToOggettoProtocollo(bytes);
} catch (Exception e) {
}
return result;

11
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/portal.properties

@ -1,5 +1,3 @@
#
#Fri Sep 01 17:17:51 CEST 2017
application.startup.events=\
it.tref.liferay.portos.bo.startup.RoleUpdateAction,\
it.tref.liferay.portos.bo.startup.KaleoListenereStartupAction,\
@ -12,12 +10,3 @@ value.object.listener.it.tref.liferay.portos.bo.model.Soggetto=it.tref.liferay.p
value.object.listener.it.tref.liferay.portos.bo.model.DocPratica=it.tref.liferay.portos.bo.model.listener.DocPraticaModelListener
value.object.listener.it.tref.liferay.portos.bo.model.IntPratica=it.tref.liferay.portos.bo.model.listener.IntPraticaModelListener
value.object.listener.it.tref.liferay.portos.bo.model.ControlloPratica=it.tref.liferay.portos.bo.model.listener.ControlloPraticaModelListener
#
# Input a class name that implements
# com.liferay.portal.security.membershippolicy.OrganizationMembershipPolicy.
# This class will be called whenever a user is added or removed from an
# organization or when a user is assigned or unassigned to a organization
# role or when a new organization is added or updated.
#
#membership.policy.organizations=it.tref.liferay.portos.bo.hook.CfOrganizationMembershipPolicy

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

@ -13,8 +13,8 @@
##
build.namespace=portos_bo
build.number=2569
build.date=1618578205435
build.number=2574
build.date=1618926051044
build.auto.upgrade=true
##

183
liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/fe/portlet/AllegatiPraticaPortlet.java

@ -1,10 +1,34 @@
package it.tref.liferay.portos.fe.portlet;
import it.tref.liferay.portos.bo.model.DocPratica;
import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DocPraticaServiceUtil;
import it.tref.liferay.portos.bo.shared.bean.FirmeBean;
import it.tref.liferay.portos.bo.shared.util.Constants;
import it.tref.liferay.portos.bo.shared.util.DocumentiPraticaUtil;
import it.tref.liferay.portos.bo.shared.util.FirmeUtil;
import it.tref.liferay.portos.bo.util.DelegheUtil;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
import org.apache.commons.codec.digest.DigestUtils;
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.portlet.PortletResponseUtil;
import com.liferay.portal.kernel.repository.model.FileEntry;
import com.liferay.portal.kernel.servlet.HttpHeaders;
import com.liferay.portal.kernel.servlet.SessionErrors;
@ -13,6 +37,7 @@ import com.liferay.portal.kernel.util.ContentTypes;
import com.liferay.portal.kernel.util.FileUtil;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.StreamUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.zip.ZipWriter;
import com.liferay.portal.kernel.zip.ZipWriterFactoryUtil;
@ -27,38 +52,6 @@ import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil;
import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil;
import com.liferay.util.bridges.mvc.MVCPortlet;
import it.tref.liferay.portos.bo.model.DocPratica;
import it.tref.liferay.portos.bo.model.IntPratica;
import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DocPraticaServiceUtil;
import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.shared.bean.FirmeBean;
import it.tref.liferay.portos.bo.shared.util.Constants;
import it.tref.liferay.portos.bo.shared.util.DocumentiPraticaUtil;
import it.tref.liferay.portos.bo.shared.util.FirmeUtil;
import it.tref.liferay.portos.bo.shared.util.PortletKeys;
import it.tref.liferay.portos.bo.util.DelegheUtil;
import it.tref.liferay.portos.bo.util.FilesImporter;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
import org.apache.commons.codec.digest.DigestUtils;
/**
* Portlet implementation class FascicoloFePortlet
*/
public class AllegatiPraticaPortlet extends MVCPortlet {
private static Log _log = LogFactoryUtil.getLog(AllegatiPraticaPortlet.class);
@ -68,7 +61,6 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
long docPraticaId = ParamUtil.getLong(actionRequest, "docPraticaId");
String comingFrom = ParamUtil.getString(actionRequest, "comingFrom");
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
// TODO rivedere assolutamente il controllo
boolean controllo = false;
if (comingFrom.equalsIgnoreCase("page_fine_lavori") || comingFrom.equalsIgnoreCase("page_collaudo")) {
@ -77,7 +69,6 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
controllo = DelegheUtil.hasDelegaDeleteFile(serviceContext.getUserId(), docPraticaId,
"page_geologo".equalsIgnoreCase(comingFrom));
}
if (controllo) {
DocPraticaServiceUtil.deleteDocPratica(docPraticaId);
}
@ -86,90 +77,67 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
public void uploadAllegato(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest);
long classPk = ParamUtil.getLong(uploadRequest, "classPk");
String className = ParamUtil.getString(uploadRequest, "className");
long intPraticaId = ParamUtil.getLong(uploadRequest, "intPraticaId");
try {
User user = PortalUtil.getUser(actionRequest);
ServiceContext serviceContext = ServiceContextFactory.getInstance(uploadRequest);
String tipologia = ParamUtil.getString(uploadRequest, "tipologia");
String sourceFileName = uploadRequest.getFileName("docFile");
boolean applicaFirma = ParamUtil.getBoolean(uploadRequest, "applicaFirma");
File file = uploadRequest.getFile("docFile");
if (Validator.isNotNull(sourceFileName)) {
// validazione: solo alcune estensioni
String ext = FileUtil.getExtension(sourceFileName);
if (!ext.equalsIgnoreCase("p7m") && !ext.equalsIgnoreCase("pdf")
&& !ext.equalsIgnoreCase("dwg")) {
if (!ext.equalsIgnoreCase("p7m") && !ext.equalsIgnoreCase("pdf") && !ext.equalsIgnoreCase("dwg")) {
SessionErrors.add(actionRequest, "error.geniocivilefe.pratica.allegato.ext.valid");
}
// lunghezza fissata a 200
if (sourceFileName.length() > 200) {
SessionErrors.add(actionRequest, "error.geniocivilefe.pratica.allegato.length.valid");
}
// Manifattura Web Group, mofidica per rendere la dimensione
// massima degli allegati configurabile
// da pannello di controllo. In origine era hardcoded a 20971520
// byte.
// Manifattura Web Group, mofidica per rendere la dimensione massima degli allegati configurabile da
// pannello di controllo. In origine era hardcoded a 20971520 byte.
Company company = PortalUtil.getCompany(actionRequest);
int dimensioneMassimaAllegati = (int) ((Short) company.getExpandoBridge().getAttribute(
Constants.COMPANY_CUSTOM_FIELD_DIMENSIONE_MASSIMA_ALLEGATI_IN_MIB, false))
.shortValue();
int dimensioneMassimaAllegati = ((Short) company.getExpandoBridge().getAttribute(
Constants.COMPANY_CUSTOM_FIELD_DIMENSIONE_MASSIMA_ALLEGATI_IN_MIB, false)).shortValue();
if (file.length() > dimensioneMassimaAllegati * 1048576) {
SessionErrors.add(actionRequest, "error.geniocivilefe.pratica.allegato.dimension.valid");
}
} else {
SessionErrors.add(actionRequest, "error.geniocivilefe.pratica.allegato.is.request");
}
if (SessionErrors.isEmpty(actionRequest)) {
// Si controlla che il tipo allegato sia di quelli che prevedono
// un solo file
if (file != null && !sourceFileName.equals("")) {
// Si controlla che il tipo allegato sia di quelli che prevedono un solo file
if (file != null && !sourceFileName.equals(StringPool.BLANK)) {
byte[] bites = FileUtil.getBytes(file);
boolean praticaValidata = false;
String sha256 = DigestUtils.sha256Hex(bites);
String version = "0";
String descLong = sourceFileName;
boolean aggiornato = false;
String jsonFirmatari = "";
String jsonFirmatari = StringPool.BLANK;
FirmeBean firmeBean = new FirmeBean();
if (applicaFirma) {
jsonFirmatari = FirmeUtil.addFirma(firmeBean, user.getScreenName());
} else {
jsonFirmatari = FirmeUtil.serialize(firmeBean);
}
long intPraticaIdRimozione = 0;
long dettPraticaIdRimozione = 0;
long intPraticaIdRimozione = 0L;
long dettPraticaIdRimozione = 0L;
Date dtDataRimozione = null;
// TODO attenzione perche' questo controllo potrebbe non
// andare bene per integrazioni e
// varianti
// TODO attenzione perche' questo controllo potrebbe non andare bene per integrazioni e varianti
boolean isUnivoco = DocumentiPraticaUtil.getDocUnivoci().contains(tipologia);
if (isUnivoco
&& DocPraticaLocalServiceUtil.countByClassPk_Tipologia(classPk, tipologia) > 0) {
if (isUnivoco && DocPraticaLocalServiceUtil.countByClassPk_Tipologia(classPk, tipologia) > 0) {
SessionErrors.add(actionRequest, "error.geniocivilefe.allegato.univoco");
}
if (SessionErrors.isEmpty(actionRequest)) {
DocPraticaServiceUtil.addDocPratica(user.getUserId(), className, classPk,
intPraticaId, bites, sourceFileName, version, praticaValidata, descLong,
tipologia, sha256, aggiornato, jsonFirmatari, intPraticaIdRimozione,
dettPraticaIdRimozione, dtDataRimozione, serviceContext);
DocPraticaServiceUtil.addDocPratica(user.getUserId(), className, classPk, intPraticaId, bites,
sourceFileName, version, praticaValidata, descLong, tipologia, sha256, aggiornato,
jsonFirmatari, intPraticaIdRimozione, dettPraticaIdRimozione, dtDataRimozione,
serviceContext);
}
}
}
PortalUtil.copyRequestParameters(actionRequest, actionResponse);
@ -191,7 +159,6 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
long docPraticaId = ParamUtil.getLong(actionRequest, "docPraticaId");
String comingFrom = ParamUtil.getString(actionRequest, "comingFrom");
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
// TODO rivedere assolutamente il controllo
boolean controllo = false;
if (comingFrom.equalsIgnoreCase("page_fine_lavori") || comingFrom.equalsIgnoreCase("page_collaudo")
@ -201,7 +168,6 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
controllo = DelegheUtil.hasDelegaFirma(serviceContext.getUserId(), docPraticaId,
"page_geologica".equalsIgnoreCase(comingFrom));
}
if (controllo) {
User user = UserLocalServiceUtil.getUser(serviceContext.getUserId());
DocPraticaLocalServiceUtil.addFirma(docPraticaId, user.getScreenName());
@ -213,7 +179,6 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
long docPraticaId = ParamUtil.getLong(actionRequest, "docPraticaId");
String comingFrom = ParamUtil.getString(actionRequest, "comingFrom");
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
// TODO rivedere assolutamente il controllo
boolean controllo = false;
if (comingFrom.equalsIgnoreCase("page_fine_lavori") || comingFrom.equalsIgnoreCase("page_collaudo")) {
@ -222,12 +187,10 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
controllo = DelegheUtil.hasDelegaFirma(serviceContext.getUserId(), docPraticaId,
"page_geologica".equalsIgnoreCase(comingFrom));
}
if (controllo) {
User user = UserLocalServiceUtil.getUser(serviceContext.getUserId());
DocPraticaLocalServiceUtil.removeFirma(docPraticaId, user.getScreenName());
}
}
public void invalidaAllegato(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
@ -236,20 +199,9 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
long docPraticaId = ParamUtil.getLong(actionRequest, "docPraticaId");
DocPratica docPratica = DocPraticaServiceUtil.getDocPratica(docPraticaId);
long dettPraticaIdRimozione = ParamUtil.getLong(actionRequest, "classPk");
docPratica.setDettPraticaIdRimozione(dettPraticaIdRimozione); // setto
// solo
// il
// dettPraticaRimozione.
// La
// rimozione
// diventa
// definitiva
// al
// completamento
// della
// variante
// setto solo il dettPraticaRimozione. La rimozione diventa definitiva al completamento della variante
docPratica.setDettPraticaIdRimozione(dettPraticaIdRimozione);
DocPraticaLocalServiceUtil.updateDocPratica(docPratica);
} catch (PortalException | SystemException e) {
_log.error(e, e);
throw e;
@ -263,7 +215,6 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
DocPratica docPratica = DocPraticaServiceUtil.getDocPratica(docPraticaId);
docPratica.setDettPraticaIdRimozione(0l);
DocPraticaLocalServiceUtil.updateDocPratica(docPratica);
} catch (PortalException | SystemException e) {
_log.error(e, e);
throw e;
@ -271,13 +222,12 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
}
@Override
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
throws IOException, PortletException {
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException,
PortletException {
String id = resourceRequest.getResourceID();
try {
if ("downloadAllDocPratica".equals(id) || "downloadAllDocPraticas".equals(id)) {
long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId");
long classPk = ParamUtil.getLong(resourceRequest, "classPk");
String comingFrom = ParamUtil.getString(resourceRequest, "comingFrom");
@ -285,34 +235,26 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
List<DocPratica> docs = new ArrayList<>();
if (Validator.isNull(comingFrom)) {
docs = DocPraticaLocalServiceUtil.findByClassPk(classPk);
} else if ("page_in_allegati".equals(comingFrom) || "page_va_allegati".equals(comingFrom)) {
List<String> tipologieAllegati = DocumentiPraticaUtil.getDocDomanda();
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId);
docs = DocPraticaLocalServiceUtil.findByIntPratica_ClassPkEqual_Tipologie(intPraticaId,
classPk, tipologieAllegati);
docs = DocPraticaLocalServiceUtil.findByIntPratica_ClassPkEqual_Tipologie(intPraticaId, classPk,
tipologieAllegati);
} else {
List<String> tipologieAllegati = new ArrayList<String>();
if ("page_geologica".equals(comingFrom) || "ag".equals(type)) {
tipologieAllegati = DocumentiPraticaUtil.getDocGeologo();
} else if ("page_allegati".equals(comingFrom) || "ad".equals(type)) {
tipologieAllegati = DocumentiPraticaUtil.getDocDomanda();
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId);
} else if ("page_fine_lavori".equals(comingFrom)) {
tipologieAllegati = DocumentiPraticaUtil.getDocFineLavori();
} else if ("page_collaudo".equals(comingFrom)) {
tipologieAllegati = DocumentiPraticaUtil.getDocCollaudo();
}
docs = DocPraticaLocalServiceUtil.findByIntPratica_ClassPk_Tipologie(intPraticaId,
classPk, tipologieAllegati);
docs = DocPraticaLocalServiceUtil.findByIntPratica_ClassPk_Tipologie(intPraticaId, classPk,
tipologieAllegati);
}
ZipWriter zipWriter = ZipWriterFactoryUtil.getZipWriter();
for (DocPratica doc : docs) {
InputStream inputStream = null;
try {
if (Validator.isNull(doc.getDlFileEntryId())) {
@ -321,9 +263,6 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(doc.getDlFileEntryId());
inputStream = DLFileEntryLocalServiceUtil.getFileAsStream(fileEntry.getFileEntryId(),
fileEntry.getVersion(), false);
// String name = fileEntry.getTitle() +
// StringPool.PERIOD + fileEntry.getExtension();
String name = fileEntry.getTitle();
zipWriter.addEntry(name, inputStream);
} finally {
@ -332,34 +271,17 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
}
}
}
resourceResponse.reset();
File file = zipWriter.getFile();
byte[] data = Files.readAllBytes(file.toPath());
resourceResponse.setContentType(ContentTypes.APPLICATION_ZIP);
resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate");
resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\""
+ file.getName() + "\"");
resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"" + file.getName() + StringPool.QUOTE);
resourceResponse.setContentLength(data.length);
resourceResponse.getPortletOutputStream().write(data);
resourceResponse.getPortletOutputStream().flush();
resourceResponse.getPortletOutputStream().close();
} else if ("importFile".equals(id)) {
long classPk = ParamUtil.getLong(resourceRequest, "classPk");
String className = ParamUtil.getString(resourceRequest, "className");
FilesImporter.importaFile(classPk, className);
PortletResponseUtil
.write(resourceResponse,
"<p style='margin-bottom:20px'><strong>Completato</strong></p><a href='#' class='btn btn-success' onclick=\"Liferay.Portlet.refresh('#p_p_id_"
+ PortletKeys.FASCICOLOFE + "_')\">Refresh</a>");
} else {
super.serveResource(resourceRequest, resourceResponse);
}
@ -367,7 +289,6 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
_log.error(e, e);
throw new IOException(e);
}
}
}

173
liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/fe/portlet/FascicoloFePortlet.java

@ -6,7 +6,6 @@ import it.tref.liferay.portos.bo.model.Comune;
import it.tref.liferay.portos.bo.model.Delega;
import it.tref.liferay.portos.bo.model.DettPratica;
import it.tref.liferay.portos.bo.model.FineLavori;
import it.tref.liferay.portos.bo.model.InfoFascicolo;
import it.tref.liferay.portos.bo.model.IntPratica;
import it.tref.liferay.portos.bo.model.Pagamento;
import it.tref.liferay.portos.bo.model.Provincia;
@ -14,16 +13,13 @@ import it.tref.liferay.portos.bo.model.Soggetto;
import it.tref.liferay.portos.bo.model.Territorio;
import it.tref.liferay.portos.bo.service.AsseverazioneLocalServiceUtil;
import it.tref.liferay.portos.bo.service.AsseverazioneServiceUtil;
import it.tref.liferay.portos.bo.service.CollaudoLocalServiceUtil;
import it.tref.liferay.portos.bo.service.CollaudoServiceUtil;
import it.tref.liferay.portos.bo.service.ComuneLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DelegaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DelegaServiceUtil;
import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DettPraticaServiceUtil;
import it.tref.liferay.portos.bo.service.FineLavoriLocalServiceUtil;
import it.tref.liferay.portos.bo.service.FineLavoriServiceUtil;
import it.tref.liferay.portos.bo.service.InfoFascicoloLocalServiceUtil;
import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.IntPraticaServiceUtil;
import it.tref.liferay.portos.bo.service.PagamentoLocalServiceUtil;
@ -36,12 +32,10 @@ import it.tref.liferay.portos.bo.shared.bean.FirmeBean;
import it.tref.liferay.portos.bo.shared.util.Constants;
import it.tref.liferay.portos.bo.shared.util.FascicoloURLUtil;
import it.tref.liferay.portos.bo.shared.util.FirmeUtil;
import it.tref.liferay.portos.bo.shared.util.PortletKeys;
import it.tref.liferay.portos.bo.shared.util.TipoIntegrazioneUtil;
import it.tref.liferay.portos.bo.shared.util.TipoSoggettoUtil;
import it.tref.liferay.portos.bo.util.AsseverazioniUtil;
import it.tref.liferay.portos.bo.util.DelegheUtil;
import it.tref.liferay.portos.bo.util.FilesImporter;
import it.tref.liferay.portos.bo.util.MailUtil;
import it.tref.liferay.portos.bo.util.SoggettiUtil;
import it.tref.liferay.portos.bo.util.ValidazionePraticaUtil;
@ -91,7 +85,6 @@ import com.liferay.portal.kernel.json.JSONSerializer;
import com.liferay.portal.kernel.language.LanguageUtil;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.portlet.PortletResponseUtil;
import com.liferay.portal.kernel.repository.model.FileEntry;
import com.liferay.portal.kernel.servlet.ServletResponseUtil;
import com.liferay.portal.kernel.servlet.SessionErrors;
@ -158,7 +151,7 @@ public class FascicoloFePortlet extends MVCPortlet {
}
writeJSON(resourceRequest, resourceResponse, jsonArray);
} else if ("zoneFasce".equals(id)) {
long comuneId = ParamUtil.getLong(resourceRequest, "comuneId", 0l);
long comuneId = ParamUtil.getLong(resourceRequest, "comuneId", 0L);
JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
if (Validator.isNotNull(comuneId)) {
List<Territorio> territori = TerritorioLocalServiceUtil.getActiveTerritoriByComune(comuneId);
@ -177,7 +170,7 @@ public class FascicoloFePortlet extends MVCPortlet {
}
writeJSON(resourceRequest, resourceResponse, jsonArray);
} else if ("soggettiDelega".equals(id)) {
long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId", 0l);
long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId", 0L);
IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId);
JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
if (Validator.isNotNull(intPratica)) {
@ -194,8 +187,8 @@ public class FascicoloFePortlet extends MVCPortlet {
}
writeJSON(resourceRequest, resourceResponse, jsonArray);
} else if ("tipologiaDelega".equals(id)) {
long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId", 0l);
long soggettoId = ParamUtil.getLong(resourceRequest, "soggettoId", 0l);
long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId", 0L);
long soggettoId = ParamUtil.getLong(resourceRequest, "soggettoId", 0L);
IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId);
Soggetto soggetto = SoggettoLocalServiceUtil.fetchSoggetto(soggettoId);
JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
@ -232,54 +225,6 @@ public class FascicoloFePortlet extends MVCPortlet {
jsonArray.put(jsonObject);
}
writeJSON(resourceRequest, resourceResponse, jsonArray);
} else if ("importFile".equals(id)) {
long classPk = ParamUtil.getLong(resourceRequest, "classPk");
String className = ParamUtil.getString(resourceRequest, "className");
FilesImporter.importaFile(classPk, className);
PortletResponseUtil
.write(resourceResponse,
"<p style='margin-bottom:20px'><strong>Completato</strong></p><a href='#' class='btn btn-success' onclick=\"Liferay.Portlet.refresh('#p_p_id_"
+ PortletKeys.FASCICOLOFE + "_')\">Refresh</a>");
} else if ("importAllFascicoloFiles".equals(id)) {
long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId");
IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId);
if (Validator.isNull(intPratica)) {
_log.error("error.no.intpratica.exist with intpraticaid=" + intPraticaId);
}
String comingFrom = ParamUtil.getString(resourceRequest, "comingFrom", "bo");
InfoFascicolo infoFascicolo = InfoFascicoloLocalServiceUtil.fetchByIntPratica(intPratica
.getIntPraticaId());
if (Validator.isNull(infoFascicolo)) {
infoFascicolo = InfoFascicoloLocalServiceUtil.addInfoFascicolo(intPratica.getIntPraticaId(),
intPratica.getNumeroProgetto(), serviceContext);
} else {
if (infoFascicolo.getAlreadyImported() && comingFrom.equalsIgnoreCase("fe")) {
_log.error("intpratica.import.file.already-clicked with intpraticaid=" + intPraticaId);
return;
}
}
User user = UserLocalServiceUtil.fetchUser(serviceContext.getUserId());
_log.debug("************** START IMPORT FILES FASCICOLO : " + intPraticaId + " by user"
+ user.getFullName());
List<DettPratica> listaDet = DettPraticaLocalServiceUtil.findByIntPraticaId(intPraticaId);
for (DettPratica dettPratica : listaDet) {
FilesImporter.importaFilesFascicolo(dettPratica.getDettPraticaId(), DettPratica.class.getName());
}
List<FineLavori> listaFine = FineLavoriLocalServiceUtil.findByIntPraticaId(intPraticaId, -1, -1, null);
for (FineLavori fineLavori : listaFine) {
FilesImporter.importaFilesFascicolo(fineLavori.getFineLavoriId(), FineLavori.class.getName());
}
List<Collaudo> listaColl = CollaudoLocalServiceUtil.findByIntPraticaId(intPraticaId, -1, -1, null);
for (Collaudo collaudo : listaColl) {
FilesImporter.importaFilesFascicolo(collaudo.getCollaudoId(), Collaudo.class.getName());
}
_log.debug("************** END IMPORT FILES FASCICOLO : " + intPraticaId);
infoFascicolo.setAlreadyImported(true);
infoFascicolo = InfoFascicoloLocalServiceUtil.updateInfoFascicolo(infoFascicolo);
PortletResponseUtil
.write(resourceResponse,
"<p style='margin-bottom:20px'><strong>Completato</strong></p><a href='#' class='btn btn-success' onclick=\"Liferay.Portlet.refresh('#p_p_id_"
+ PortletKeys.FASCICOLOFE + "_')\">Refresh</a>");
} else if ("isCompletedDelegaGeologo".equals(id)) {
long classPk = ParamUtil.getLong(resourceRequest, "classPk");
JSONObject json = JSONFactoryUtil.createJSONObject();
@ -315,7 +260,8 @@ public class FascicoloFePortlet extends MVCPortlet {
JRDataSource dataSource = new JREmptyDataSource();
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource);
// Export to PDF.
String titleDoc = intPratica.getNumeroProgetto() + "_" + new Date().getTime() + ".pdf";
String titleDoc = intPratica.getNumeroProgetto() + StringPool.UNDERLINE + new Date().getTime()
+ ".pdf";
jasperPrint.setName(titleDoc);
HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest);
HttpServletResponse response = PortalUtil.getHttpServletResponse(resourceResponse);
@ -344,8 +290,8 @@ public class FascicoloFePortlet extends MVCPortlet {
JRDataSource dataSource = new JREmptyDataSource();
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource);
// Export to PDF.
String titleDoc = "variante_" + intPratica.getNumeroProgetto() + "_" + new Date().getTime()
+ ".pdf";
String titleDoc = "variante_" + intPratica.getNumeroProgetto() + StringPool.UNDERLINE
+ new Date().getTime() + ".pdf";
jasperPrint.setName(titleDoc);
HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest);
HttpServletResponse response = PortalUtil.getHttpServletResponse(resourceResponse);
@ -373,8 +319,8 @@ public class FascicoloFePortlet extends MVCPortlet {
JRDataSource dataSource = new JREmptyDataSource();
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource);
// Export to PDF.
String titleDoc = "fine_lavori_" + intPratica.getNumeroProgetto() + "_" + new Date().getTime()
+ ".pdf";
String titleDoc = "fine_lavori_" + intPratica.getNumeroProgetto() + StringPool.UNDERLINE
+ new Date().getTime() + ".pdf";
jasperPrint.setName(titleDoc);
HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest);
HttpServletResponse response = PortalUtil.getHttpServletResponse(resourceResponse);
@ -401,8 +347,8 @@ public class FascicoloFePortlet extends MVCPortlet {
JRDataSource dataSource = new JREmptyDataSource();
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource);
// Export to PDF.
String titleDoc = "collaudo_" + intPratica.getNumeroProgetto() + "_" + new Date().getTime()
+ ".pdf";
String titleDoc = "collaudo_" + intPratica.getNumeroProgetto() + StringPool.UNDERLINE
+ new Date().getTime() + ".pdf";
jasperPrint.setName(titleDoc);
HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest);
HttpServletResponse response = PortalUtil.getHttpServletResponse(resourceResponse);
@ -500,8 +446,8 @@ public class FascicoloFePortlet extends MVCPortlet {
successURL = HttpUtil.addParameter(successURL, actionResponse.getNamespace() + "dettPraticaId",
String.valueOf(lastDettPraticaEditableVS.getDettPraticaId()));
String fragmentURL = "_1_WAR_portosfeportlet_page_soggetti";
if (successURL.contains("#")) {
successURL = successURL.substring(0, successURL.lastIndexOf("#"));
if (successURL.contains(StringPool.POUND)) {
successURL = successURL.substring(0, successURL.lastIndexOf(StringPool.POUND));
}
successURL += "#_1_WAR_portosfeportlet_tab=" + fragmentURL;
actionResponse.sendRedirect(successURL);
@ -548,7 +494,7 @@ public class FascicoloFePortlet extends MVCPortlet {
successURL = HttpUtil.addParameter(successURL, actionResponse.getNamespace() + "dettPraticaId",
String.valueOf(dettPratica.getDettPraticaId()));
successURL = HttpUtil.addParameter(successURL, actionResponse.getNamespace() + "isNewVariante",
String.valueOf(true));
StringPool.TRUE);
actionResponse.sendRedirect(successURL);
} catch (PortalException | SystemException e) {
successURL = HttpUtil.setParameter(successURL, actionResponse.getNamespace() + "mvcPath",
@ -714,7 +660,7 @@ public class FascicoloFePortlet extends MVCPortlet {
ServiceContext serviceContext = ServiceContextFactory.getInstance(DettPratica.class.getName(), actionRequest);
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId");
DettPratica dettPratica = DettPraticaLocalServiceUtil.getDettPratica(dettPraticaId);
String cmd = ParamUtil.getString(actionRequest, "cmd");
String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
boolean bozza = ParamUtil.getBoolean(actionRequest, "bozza");
if (bozza) {
@ -733,7 +679,7 @@ public class FascicoloFePortlet extends MVCPortlet {
saveDatiDettPratica(dettPraticaId, actionRequest, actionResponse);
} else {
throw new SystemException("operazione non gestita (" + cmd + ")");
throw new SystemException("operazione non gestita (" + cmd + StringPool.CLOSE_PARENTHESIS);
}
}
@ -742,7 +688,7 @@ public class FascicoloFePortlet extends MVCPortlet {
ServiceContext serviceContext = ServiceContextFactory.getInstance(DettPratica.class.getName(), actionRequest);
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId");
DettPratica dettPratica = DettPraticaLocalServiceUtil.getDettPratica(dettPraticaId);
String cmd = ParamUtil.getString(actionRequest, "cmd");
String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
boolean bozza = ParamUtil.getBoolean(actionRequest, "bozza");
if (bozza) {
@ -885,7 +831,7 @@ public class FascicoloFePortlet extends MVCPortlet {
if (ParamUtil.getBoolean(actionRequest, "asPresenti", false)) {
Map<String, Serializable> parametri = new HashMap<>();
parametri.put("coniugio", ParamUtil.getBoolean(actionRequest, "asConiugio", false));
parametri.put("relazioni", ParamUtil.getString(actionRequest, "asRelazioni", ""));
parametri.put("relazioni", ParamUtil.getString(actionRequest, "asRelazioni", StringPool.BLANK));
JSONSerializer serializer = JSONFactoryUtil.createJSONSerializer();
dichiarazioni = serializer.serializeDeep(parametri);
@ -930,7 +876,7 @@ public class FascicoloFePortlet extends MVCPortlet {
Map<String, Serializable> parametri = new HashMap<>();
if (ParamUtil.getBoolean(actionRequest, "dgPresenti", false)) {
parametri.put("coniugio", ParamUtil.getBoolean(actionRequest, "dgConiugio", false));
parametri.put("relazioni", ParamUtil.getString(actionRequest, "dgRelazioni", ""));
parametri.put("relazioni", ParamUtil.getString(actionRequest, "dgRelazioni", StringPool.BLANK));
}
JSONSerializer serializer = JSONFactoryUtil.createJSONSerializer();
String dichiarazioni = serializer.serializeDeep(parametri);
@ -959,7 +905,7 @@ public class FascicoloFePortlet extends MVCPortlet {
ServiceContext serviceContext = ServiceContextFactory.getInstance(DettPratica.class.getName(), actionRequest);
DettPratica dettPratica = DettPraticaServiceUtil.getDettPratica(dettPraticaId);
boolean bozza = ParamUtil.getBoolean(actionRequest, "bozza", true);
String cmd = ParamUtil.getString(actionRequest, "cmd");
String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
long integrazione = ParamUtil.getLong(actionRequest, "integrazione");
boolean disabledSubmit = ParamUtil.getBoolean(actionRequest, "disabledSubmit", true);
boolean geoDisabledSubmit = ParamUtil.getBoolean(actionRequest, "geoDisabledSubmit", true);
@ -979,11 +925,11 @@ public class FascicoloFePortlet extends MVCPortlet {
boolean isCodiceFiscaleDelegatoFineLavoriAuthorized = ParamUtil.getBoolean(actionRequest,
"codiceFiscaleDelegatoFineLavoriEnabled");
String codiceFiscaleDelegatoFineLavori = isCodiceFiscaleDelegatoFineLavoriAuthorized ? ParamUtil.getString(
actionRequest, "codiceFiscaleDelegatoFineLavori") : "";
actionRequest, "codiceFiscaleDelegatoFineLavori") : StringPool.BLANK;
boolean isCodiceFiscaleDelegatoCollaudoAuthorized = ParamUtil.getBoolean(actionRequest,
"codiceFiscaleDelegatoCollaudoEnabled");
String codiceFiscaleDelegatoCollaudo = isCodiceFiscaleDelegatoCollaudoAuthorized ? ParamUtil.getString(
actionRequest, "codiceFiscaleDelegatoCollaudo") : "";
actionRequest, "codiceFiscaleDelegatoCollaudo") : StringPool.BLANK;
// FIXME A che serve???
String codiceRuoloDelegato = ParamUtil.getString(actionRequest, "codiceRuoloDelegato");
boolean inizioLavoriContestualeOpera = ParamUtil.getBoolean(actionRequest, "inizioLavoriContestualeOpera");
@ -1043,15 +989,22 @@ public class FascicoloFePortlet extends MVCPortlet {
String numeroCivico = ParamUtil.getString(actionRequest, "numeroCivico");
String dcFoglio = ParamUtil.getString(actionRequest, "dcFoglio");
String dcAllegato = ParamUtil.getString(actionRequest, "dcAllegato");
String particella1 = ParamUtil.getString(actionRequest, "particella1", "").replaceAll(Pattern.quote("|"), " ");
String particella2 = ParamUtil.getString(actionRequest, "particella2", "").replaceAll(Pattern.quote("|"), " ");
String particella3 = ParamUtil.getString(actionRequest, "particella3", "").replaceAll(Pattern.quote("|"), " ");
String particella4 = ParamUtil.getString(actionRequest, "particella4", "").replaceAll(Pattern.quote("|"), " ");
String particella1 = ParamUtil.getString(actionRequest, "particella1", StringPool.BLANK).replaceAll(
Pattern.quote(StringPool.PIPE), StringPool.SPACE);
String particella2 = ParamUtil.getString(actionRequest, "particella2", StringPool.BLANK).replaceAll(
Pattern.quote(StringPool.PIPE), StringPool.SPACE);
String particella3 = ParamUtil.getString(actionRequest, "particella3", StringPool.BLANK).replaceAll(
Pattern.quote(StringPool.PIPE), StringPool.SPACE);
String particella4 = ParamUtil.getString(actionRequest, "particella4", StringPool.BLANK).replaceAll(
Pattern.quote(StringPool.PIPE), StringPool.SPACE);
String dcParticelle = particella1 + StringPool.PIPE + particella2 + StringPool.PIPE + particella3
+ StringPool.PIPE + particella4;
String latitudine = ParamUtil.getString(actionRequest, "lat", "").replaceAll(Pattern.quote("|"), " ");
String longitudine = ParamUtil.getString(actionRequest, "long", "").replaceAll(Pattern.quote("|"), " ");
String zoom = ParamUtil.getString(actionRequest, "zoom", "").replaceAll(Pattern.quote("|"), " ");
String latitudine = ParamUtil.getString(actionRequest, "lat", StringPool.BLANK).replaceAll(
Pattern.quote(StringPool.PIPE), StringPool.SPACE);
String longitudine = ParamUtil.getString(actionRequest, "long", StringPool.BLANK).replaceAll(
Pattern.quote(StringPool.PIPE), StringPool.SPACE);
String zoom = ParamUtil.getString(actionRequest, "zoom", StringPool.BLANK).replaceAll(
Pattern.quote(StringPool.PIPE), StringPool.SPACE);
String localizzazioneGeografica = latitudine + StringPool.PIPE + longitudine + StringPool.PIPE + zoom;
boolean tcNuovaCostruzione = ParamUtil.getBoolean(actionRequest, "tcNuovaCostruzione");
boolean tcAdeguamentoSismico = ParamUtil.getBoolean(actionRequest, "tcAdeguamentoSismico");
@ -1296,8 +1249,8 @@ public class FascicoloFePortlet extends MVCPortlet {
successURL = HttpUtil.removeParameter(successURL, actionResponse.getNamespace() + "historyKey");
successURL = HttpUtil.addParameter(successURL, actionResponse.getNamespace() + "historyKey",
"_1_WAR_portosfeportlet_tab=" + fragmentURL);
if (successURL.contains("#")) {
successURL = successURL.substring(0, successURL.lastIndexOf("#"));
if (successURL.contains(StringPool.POUND)) {
successURL = successURL.substring(0, successURL.lastIndexOf(StringPool.POUND));
}
successURL += "#_1_WAR_portosfeportlet_tab=" + fragmentURL;
}
@ -1355,11 +1308,11 @@ public class FascicoloFePortlet extends MVCPortlet {
boolean isCodiceFiscaleDelegatoFineLavoriAuthorized = ParamUtil.getBoolean(actionRequest,
"codiceFiscaleDelegatoFineLavoriEnabled");
String codiceFiscaleDelegatoFineLavori = isCodiceFiscaleDelegatoFineLavoriAuthorized ? ParamUtil.getString(
actionRequest, "codiceFiscaleDelegatoFineLavori") : "";
actionRequest, "codiceFiscaleDelegatoFineLavori") : StringPool.BLANK;
boolean isCodiceFiscaleDelegatoCollaudoAuthorized = ParamUtil.getBoolean(actionRequest,
"codiceFiscaleDelegatoCollaudoEnabled");
String codiceFiscaleDelegatoCollaudo = isCodiceFiscaleDelegatoCollaudoAuthorized ? ParamUtil.getString(
actionRequest, "codiceFiscaleDelegatoCollaudo") : "";
actionRequest, "codiceFiscaleDelegatoCollaudo") : StringPool.BLANK;
boolean inizioLavoriContestualeOpera = ParamUtil.getBoolean(actionRequest, "inizioLavoriContestualeOpera");
long pagamentoId = ParamUtil.getLong(actionRequest, "pagamentoId");
Date dataEffettuazione = ParamUtil.getDate(actionRequest, "dataEffettuazione",
@ -1423,10 +1376,14 @@ public class FascicoloFePortlet extends MVCPortlet {
String numeroCivico = ParamUtil.getString(actionRequest, "numeroCivico");
String dcFoglio = ParamUtil.getString(actionRequest, "dcFoglio");
String dcAllegato = ParamUtil.getString(actionRequest, "dcAllegato");
String particella1 = ParamUtil.getString(actionRequest, "particella1", "").replaceAll(Pattern.quote("|"), " ");
String particella2 = ParamUtil.getString(actionRequest, "particella2", "").replaceAll(Pattern.quote("|"), " ");
String particella3 = ParamUtil.getString(actionRequest, "particella3", "").replaceAll(Pattern.quote("|"), " ");
String particella4 = ParamUtil.getString(actionRequest, "particella4", "").replaceAll(Pattern.quote("|"), " ");
String particella1 = ParamUtil.getString(actionRequest, "particella1", StringPool.BLANK).replaceAll(
Pattern.quote(StringPool.PIPE), StringPool.SPACE);
String particella2 = ParamUtil.getString(actionRequest, "particella2", StringPool.BLANK).replaceAll(
Pattern.quote(StringPool.PIPE), StringPool.SPACE);
String particella3 = ParamUtil.getString(actionRequest, "particella3", StringPool.BLANK).replaceAll(
Pattern.quote(StringPool.PIPE), StringPool.SPACE);
String particella4 = ParamUtil.getString(actionRequest, "particella4", StringPool.BLANK).replaceAll(
Pattern.quote(StringPool.PIPE), StringPool.SPACE);
String dcParticelle = particella1 + StringPool.PIPE + particella2 + StringPool.PIPE + particella3
+ StringPool.PIPE + particella4;
boolean tcNuovaCostruzione = ParamUtil.getBoolean(actionRequest, "tcNuovaCostruzione");
@ -1686,8 +1643,8 @@ public class FascicoloFePortlet extends MVCPortlet {
successURL = HttpUtil.addParameter(successURL, actionResponse.getNamespace() + "historyKey",
"_1_WAR_portosfeportlet_tab=" + fragmentURL);
if (successURL.contains("#")) {
successURL = successURL.substring(0, successURL.lastIndexOf("#"));
if (successURL.contains(StringPool.POUND)) {
successURL = successURL.substring(0, successURL.lastIndexOf(StringPool.POUND));
}
successURL += "#_1_WAR_portosfeportlet_tab=" + fragmentURL;
}
@ -1747,8 +1704,8 @@ public class FascicoloFePortlet extends MVCPortlet {
successURL = HttpUtil.addParameter(successURL, actionResponse.getNamespace() + "verifyArea",
String.valueOf(verifyArea));
String fragmentURL = "_1_WAR_portosfeportlet_page_soggetti";
if (successURL.contains("#")) {
successURL = successURL.substring(0, successURL.lastIndexOf("#"));
if (successURL.contains(StringPool.POUND)) {
successURL = successURL.substring(0, successURL.lastIndexOf(StringPool.POUND));
}
successURL += "#_1_WAR_portosfeportlet_tab=" + fragmentURL;
actionResponse.sendRedirect(successURL);
@ -1942,10 +1899,10 @@ public class FascicoloFePortlet extends MVCPortlet {
SessionErrors.add(actionRequest, "error.geniocivilefe.asseverazione.allegato.firma.valid");
// Impostazione parametri di rendering per messaggio di errore.
List<String> firmatari = ValidazionePraticaUtil.gatherSignatures(sourceFileName, content,
serviceContext.getCompanyId(), "");
String firme = StringUtils.join(firmatari, ", ").toLowerCase();
serviceContext.getCompanyId(), StringPool.BLANK);
String firme = StringUtils.join(firmatari, StringPool.COMMA_AND_SPACE).toLowerCase();
dettagliFirme = "<br>Firma richiesta [" + asseverazione.getCodiceFiscale() + "]<br>Firme trovate ["
+ firme + "]";
+ firme + StringPool.CLOSE_BRACKET;
}
}
if (!SessionErrors.isEmpty(actionRequest)) {
@ -1973,6 +1930,7 @@ public class FascicoloFePortlet extends MVCPortlet {
public void confermaAsseverazione(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException,
PortalException, SystemException {
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
long asseverazioneId = ParamUtil.getLong(actionRequest, "asseverazioneId");
if (AsseverazioniUtil.hasCambioStatoAsseverazione(serviceContext.getUserId(), asseverazioneId)) {
@ -2129,11 +2087,12 @@ public class FascicoloFePortlet extends MVCPortlet {
long delegaId = ParamUtil.getLong(actionRequest, "delegaId");
Delega delega = DelegaLocalServiceUtil.getDelega(delegaId);
List<Soggetto> soggetti = SoggettoLocalServiceUtil.getValidTmpByIntPratica_CodiceFiscale(
delega.getIntPraticaId(), delega.getCodiceFiscale(), 0l);
delega.getIntPraticaId(), delega.getCodiceFiscale(), 0L);
Soggetto soggetto = soggetti.get(0);
String roles = StringPool.BLANK;
for (Soggetto role : soggetti) {
roles += LanguageUtil.get(LocaleUtil.ITALIAN, "gc-soggetto-" + role.getTipologiaSoggetto()) + " ";
roles += LanguageUtil.get(LocaleUtil.ITALIAN, "gc-soggetto-" + role.getTipologiaSoggetto())
+ StringPool.SPACE;
}
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(delega.getIntPraticaId());
String[] to = { soggetto.getEmail() };
@ -2181,7 +2140,7 @@ public class FascicoloFePortlet extends MVCPortlet {
long asseverazioneId = ParamUtil.getLong(actionRequest, "asseverazioneId");
Asseverazione asseverazione = AsseverazioneLocalServiceUtil.getAsseverazione(asseverazioneId);
Soggetto soggetto = SoggettoLocalServiceUtil.getValidTmpByIntPratica_CodiceFiscale(
asseverazione.getIntPraticaId(), asseverazione.getCodiceFiscale(), 0l).get(0);
asseverazione.getIntPraticaId(), asseverazione.getCodiceFiscale(), 0L).get(0);
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(asseverazione.getIntPraticaId());
_log.debug("Sending asseverazione mail to " + soggetto.getEmail());
String[] to = { soggetto.getEmail() };
@ -2241,13 +2200,8 @@ public class FascicoloFePortlet extends MVCPortlet {
PortalUtil.copyRequestParameters(actionRequest, actionResponse);
} else {
byte[] content = FileUtil.getBytes(file);
// DettPraticaServiceUtil.updatePagamentoManuale(pagamentoId,
// pagamento.getDettPraticaId(),
// content,
// sourceFileName, serviceContext);
PagamentoServiceUtil.updatePagamentoManuale(pagamentoId, content, sourceFileName, serviceContext);
}
} catch (Exception e) {
PortalUtil.copyRequestParameters(actionRequest, actionResponse);
_log.error("Error", e);
@ -2261,7 +2215,6 @@ public class FascicoloFePortlet extends MVCPortlet {
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId");
long fineLavoriId = ParamUtil.getLong(actionRequest, "fineLavoriId");
long collaudoId = ParamUtil.getLong(actionRequest, "collaudoId");
if (Validator.isNotNull(dettPraticaId)) {
DettPraticaServiceUtil.updateEsito(dettPraticaId, WorkflowConstants.STATUS_APPROVED);
} else if (Validator.isNotNull(fineLavoriId)) {
@ -2277,7 +2230,6 @@ public class FascicoloFePortlet extends MVCPortlet {
PortalException, SystemException {
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId");
if (Validator.isNotNull(dettPraticaId)) {
DettPraticaServiceUtil.updateEsitoIntegrazione(dettPraticaId, WorkflowConstants.STATUS_APPROVED);
} else {
@ -2289,14 +2241,11 @@ public class FascicoloFePortlet extends MVCPortlet {
PortalException, SystemException {
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId");
if (Validator.isNotNull(dettPraticaId)) {
DettPraticaServiceUtil.updateEsito(dettPraticaId, WorkflowConstants.STATUS_APPROVED);
} else {
SessionErrors.add(actionRequest, "completamento-cambio-soggetti-non-possibile");
}
}
public void completeAnnullamento(ActionRequest actionRequest, ActionResponse actionResponse)

8
liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/fe/portlet/SoggettiPraticaPortlet.java

@ -63,6 +63,7 @@ public class SoggettiPraticaPortlet extends MVCPortlet {
private static Log _log = LogFactoryUtil.getLog(SoggettiPraticaPortlet.class);
public void deleteSoggetto(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
try {
long soggettoId = ParamUtil.getLong(actionRequest, "soggettoId");
SoggettoServiceUtil.deleteSoggetto(soggettoId);
@ -73,6 +74,7 @@ public class SoggettiPraticaPortlet extends MVCPortlet {
}
public void invalidaSoggetto(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
try {
long soggettoId = ParamUtil.getLong(actionRequest, "soggettoId");
long dettPraticaIdRimozione = ParamUtil.getLong(actionRequest, "dettPraticaId");
@ -84,6 +86,7 @@ public class SoggettiPraticaPortlet extends MVCPortlet {
}
public void validaSoggetto(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
try {
long soggettoId = ParamUtil.getLong(actionRequest, "soggettoId");
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId");
@ -95,6 +98,7 @@ public class SoggettiPraticaPortlet extends MVCPortlet {
}
public void makePrincipale(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
try {
long soggettoId = ParamUtil.getLong(actionRequest, "soggettoId");
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId");
@ -108,6 +112,7 @@ public class SoggettiPraticaPortlet extends MVCPortlet {
}
public void removePrincipale(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
try {
long soggettoId = ParamUtil.getLong(actionRequest, "soggettoId");
Soggetto soggetto = SoggettoServiceUtil.getSoggetto(soggettoId);
@ -120,6 +125,7 @@ public class SoggettiPraticaPortlet extends MVCPortlet {
}
public void updateSoggetto(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
boolean requiredDoc = ParamUtil.getBoolean(actionRequest, "requiredDoc");
long soggettoId = ParamUtil.getLong(actionRequest, "soggettoId");
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId");
@ -225,6 +231,7 @@ public class SoggettiPraticaPortlet extends MVCPortlet {
}
public void updateAllegatoSoggetto(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long soggettoId = ParamUtil.getLong(actionRequest, "soggettoId");
Soggetto soggetto = SoggettoLocalServiceUtil.getSoggetto(soggettoId);
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId");
@ -330,6 +337,7 @@ public class SoggettiPraticaPortlet extends MVCPortlet {
@Override
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException,
PortletException {
String id = resourceRequest.getResourceID();
try {
ServiceContext serviceContext = ServiceContextFactory.getInstance(resourceRequest);

3
liferay-plugins-sdk-6.2/portlets/portos-kaleo-controller-portlet/.settings/org.eclipse.wst.common.component

@ -5,9 +5,6 @@
<dependent-module archiveName="portos-bo-portlet-service.jar" deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/portos-bo-portlet/docroot/WEB-INF/lib/portos-bo-portlet-service.jar">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="portos-bo-portlet-service.jar" deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/portos-bo-portlet/docroot/WEB-INF/lib/portos-bo-portlet-service.jar">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="context-root" value="portos-kaleo-controller-portlet"/>
<property name="java-output-path" value="/portos-kaleo-controller-portlet/docroot/WEB-INF/classes"/>
</wb-module>

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

@ -28,56 +28,41 @@ public class StartupAction extends SimpleAction {
public void run(String[] ids) throws ActionException {
for (String id : ids) {
long companyId = GetterUtil.getLong(id);
try {
Company company = CompanyLocalServiceUtil.getCompany(companyId);
Group companyGroup = company.getGroup();
User userDefault = company.getDefaultUser();
// Folders
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);
}
}
}
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;
try {
dlFolder = DLFolderLocalServiceUtil.getFolder(groupId, parentFolderId, name);
} catch (PortalException e) {
ServiceContext serviceContext = new ServiceContext();
if (groupActions != null) {
serviceContext.setGroupPermissions(groupActions);
}
if (guestActions != null) {
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;
}
}

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

@ -14,8 +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();
}
@ -23,5 +23,4 @@ public class DLFileEntryListener extends BaseModelListener<DLFileEntry> {
throw new ModelListenerException(e);
}
}
}

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

@ -1,5 +1,12 @@
package it.tref.liferay.portos.mailmanager.messaging;
import it.tref.liferay.portos.mailmanager.model.Email;
import it.tref.liferay.portos.mailmanager.service.EmailLocalServiceUtil;
import it.tref.liferay.portos.mailmanager.service.persistence.EmailActionableDynamicQuery;
import it.tref.liferay.portos.mailmanager.util.MailSenderUtil;
import java.util.Date;
import com.liferay.portal.DuplicateLockException;
import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery;
import com.liferay.portal.kernel.dao.orm.DynamicQuery;
@ -16,13 +23,6 @@ import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
import com.liferay.portal.model.Lock;
import com.liferay.portal.service.LockLocalServiceUtil;
import it.tref.liferay.portos.mailmanager.model.Email;
import it.tref.liferay.portos.mailmanager.service.EmailLocalServiceUtil;
import it.tref.liferay.portos.mailmanager.service.persistence.EmailActionableDynamicQuery;
import it.tref.liferay.portos.mailmanager.util.MailSenderUtil;
import java.util.Date;
public class SendMailMessageListener implements MessageListener {
private static final String _LOCK_CLASS_NAME = SendMailMessageListener.class.getName();
@ -33,7 +33,6 @@ public class SendMailMessageListener implements MessageListener {
public void receive(Message message) throws MessageListenerException {
try {
ActionableDynamicQuery actionableDynamicQuery = new EmailActionableDynamicQuery() {
@Override
@ -46,26 +45,18 @@ public class SendMailMessageListener implements MessageListener {
protected void performAction(Object obj) throws PortalException, SystemException {
Email email = (Email) obj;
try {
MailSenderUtil.sendMail(email);
EmailLocalServiceUtil.markAsSent(email.getEmailId(), new Date(), StringPool.BLANK);
} catch (Exception e) {
EmailLocalServiceUtil.updateStatusMessage(email.getEmailId(), e.getMessage());
}
}
};
long count = actionableDynamicQuery.performCount();
if (count > 0) {
String owner = PortalUUIDUtil.generate();
if (tryLock(owner)) {
try {
actionableDynamicQuery.performActions();
} finally {
@ -73,7 +64,6 @@ public class SendMailMessageListener implements MessageListener {
}
}
}
} catch (Exception e) {
_log.error(e, e);
}
@ -82,31 +72,24 @@ public class SendMailMessageListener implements MessageListener {
private boolean tryLock(String owner) {
try {
Lock lock = null;
while (true) {
try {
lock = LockLocalServiceUtil.lock(_LOCK_CLASS_NAME, _LOCK_CLASS_NAME, owner);
break;
} catch (SystemException se) {
try {
Thread.sleep(50);
} catch (InterruptedException ie) {
}
}
}
if (!lock.isNew()) {
throw new DuplicateLockException(lock);
}
} catch (DuplicateLockException e) {
return false;
}
return true;
}

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

@ -1,5 +1,11 @@
package it.tref.liferay.portos.mailmanager.portlet;
import it.tref.liferay.portos.mailmanager.service.EmailServiceUtil;
import it.tref.liferay.portos.mailmanager.shared.util.StringUtil;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
@ -9,15 +15,6 @@ import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.service.ServiceContextFactory;
import com.liferay.util.bridges.mvc.MVCPortlet;
import it.tref.liferay.portos.mailmanager.service.EmailServiceUtil;
import it.tref.liferay.portos.mailmanager.shared.util.StringUtil;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
/**
* Portlet implementation class Email
*/
public class EmailPortlet extends MVCPortlet {
private static Log _log = LogFactoryUtil.getLog(EmailPortlet.class);
@ -25,28 +22,21 @@ public class EmailPortlet extends MVCPortlet {
public void editEmail(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
_log.debug("editEmail - Inizio metodo");
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
long emailId = ParamUtil.getLong(actionRequest, "emailId");
String from = ParamUtil.getString(actionRequest, "from");
String[] to = StringUtil.splitAndTrim(ParamUtil.getString(actionRequest, "to"));
String[] cc = StringUtil.splitAndTrim(ParamUtil.getString(actionRequest, "cc"));
String[] ccn = StringUtil.splitAndTrim(ParamUtil.getString(actionRequest, "ccn"));
String subject = ParamUtil.getString(actionRequest, "subject");
String body = ParamUtil.getString(actionRequest, "body");
EmailServiceUtil.updateEmail(emailId, from, to, cc, ccn, subject, body, serviceContext);
}
public void annullaEmail(ActionRequest actionRequest, ActionResponse actionResponse)
throws PortalException, SystemException {
_log.debug("annullaEmail - inizio metodo");
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
long emailId = ParamUtil.getLong(actionRequest, "emailId");
EmailServiceUtil.cancelEmail(emailId, serviceContext);
@ -55,10 +45,8 @@ public class EmailPortlet extends MVCPortlet {
public void resendEmail(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
_log.debug("reinviaEmail - Inizio metodo");
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
long emailId = ParamUtil.getLong(actionRequest, "emailId");
EmailServiceUtil.resendEmail(emailId, serviceContext);
}
}

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

@ -1,5 +1,20 @@
package it.tref.liferay.portos.mailmanager.portlet;
import it.tref.liferay.portos.mailmanager.model.EmailTemplate;
import it.tref.liferay.portos.mailmanager.service.EmailLocalServiceUtil;
import it.tref.liferay.portos.mailmanager.service.EmailTemplateLocalServiceUtil;
import it.tref.liferay.portos.mailmanager.service.EmailTemplateServiceUtil;
import it.tref.liferay.portos.mailmanager.shared.util.MailManagerConstants.SendTemplateMode;
import it.tref.liferay.portos.mailmanager.shared.util.MailUtil;
import it.tref.liferay.portos.mailmanager.shared.util.StringUtil;
import it.tref.liferay.portos.mailmanager.shared.util.UploadPortletRequestUtil;
import it.tref.liferay.portos.mailmanager.util.MailManagerUtil;
import java.util.List;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSONFactoryUtil;
@ -16,21 +31,6 @@ import com.liferay.portal.service.ServiceContextFactory;
import com.liferay.portal.util.PortalUtil;
import com.liferay.util.bridges.mvc.MVCPortlet;
import it.tref.liferay.portos.mailmanager.model.EmailTemplate;
import it.tref.liferay.portos.mailmanager.service.EmailLocalServiceUtil;
import it.tref.liferay.portos.mailmanager.service.EmailTemplateLocalServiceUtil;
import it.tref.liferay.portos.mailmanager.service.EmailTemplateServiceUtil;
import it.tref.liferay.portos.mailmanager.shared.util.MailManagerConstants.SendTemplateMode;
import it.tref.liferay.portos.mailmanager.shared.util.MailUtil;
import it.tref.liferay.portos.mailmanager.shared.util.StringUtil;
import it.tref.liferay.portos.mailmanager.shared.util.UploadPortletRequestUtil;
import it.tref.liferay.portos.mailmanager.util.MailManagerUtil;
import java.util.List;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
/**
* Portlet implementation class EmailTemplates
*/
@ -38,43 +38,34 @@ 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);
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
long emailTemplateId = ParamUtil.getLong(actionRequest, "emailTemplateId");
String templateName = ParamUtil.getString(actionRequest, "templateName");
String from = ParamUtil.getString(actionRequest, "from");
String[] to = StringUtil.splitAndTrim(ParamUtil.getString(actionRequest, "to"));
String[] cc = StringUtil.splitAndTrim(ParamUtil.getString(actionRequest, "cc"));
String[] ccn = StringUtil.splitAndTrim(ParamUtil.getString(actionRequest, "ccn"));
String subject = ParamUtil.getString(actionRequest, "subject");
String body = ParamUtil.getString(actionRequest, "body");
Boolean attachmentPermitted = ParamUtil.getBoolean(actionRequest, "attachmentPermitted");
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();
} catch (PortalException e) {
SessionErrors.add(actionRequest, e.getClass());
}
if (SessionErrors.isEmpty(actionRequest)) {
actionResponse.setRenderParameter("emailTemplateId", String.valueOf(emailTemplateId));
actionResponse.setRenderParameter("mvcPath", "/html/email_templates/edit.jsp");
@ -82,60 +73,47 @@ public class EmailTemplatesPortlet extends MVCPortlet {
actionResponse.setRenderParameter("mvcPath", "/html/email_templates/edit.jsp");
PortalUtil.copyRequestParameters(actionRequest, actionResponse);
}
}
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);
long emailTemplateId = ParamUtil.getLong(actionRequest, "emailTemplateId");
EmailTemplate emailTemplate = EmailTemplateLocalServiceUtil.getEmailTemplate(emailTemplateId);
String sendModeStr = ParamUtil.getString(actionRequest, "sendMode");
SendTemplateMode sendMode = SendTemplateMode.parse(sendModeStr);
String className = ParamUtil.getString(actionRequest, "className");
long classPK = ParamUtil.getLong(actionRequest, "classPK");
try {
// eventuali allegati email
List<com.liferay.mail.model.FileAttachment> fileAttachments = null;
if (emailTemplate.getAttachmentPermitted()) {
fileAttachments = MailUtil.getEmailFileAttachments(uploadPortletRequest);
}
if (sendMode == SendTemplateMode.REVIEW) {
String templateParamJSON = ParamUtil.getString(actionRequest, "templateParamJSON");
JSONObject templateParamJSONObj = JSONFactoryUtil.createJSONObject(templateParamJSON);
MailManagerUtil.addEmailByTemplate(className, classPK, emailTemplateId, templateParamJSONObj,
fileAttachments, serviceContext);
} else if (sendMode == SendTemplateMode.EDIT) {
String from = ParamUtil.getString(actionRequest, "from");
String to = ParamUtil.getString(actionRequest, "to");
String cc = ParamUtil.getString(actionRequest, "cc");
String ccn = ParamUtil.getString(actionRequest, "ccn");
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");
@ -143,7 +121,5 @@ public class EmailTemplatesPortlet extends MVCPortlet {
UploadPortletRequestUtil.copyRequestParameters(uploadPortletRequest, actionResponse);
throw new SystemException("Error add email by template.", ex);
}
}
}

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

@ -1,11 +1,10 @@
/**
* 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.
* 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.
*
*
*
@ -13,6 +12,16 @@
package it.tref.liferay.portos.mailmanager.service.impl;
import it.tref.liferay.portos.mailmanager.EmailAttachmentFileException;
import it.tref.liferay.portos.mailmanager.EmailAttachmentTitleException;
import it.tref.liferay.portos.mailmanager.NoSuchEmailException;
import it.tref.liferay.portos.mailmanager.model.EmailAttachment;
import it.tref.liferay.portos.mailmanager.service.base.EmailAttachmentLocalServiceBaseImpl;
import it.tref.liferay.portos.mailmanager.service.persistence.EmailAttachmentPK;
import java.io.File;
import java.util.List;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.repository.model.FileEntry;
@ -26,29 +35,16 @@ import com.liferay.portal.model.User;
import com.liferay.portal.security.permission.ActionKeys;
import com.liferay.portal.service.ServiceContext;
import it.tref.liferay.portos.mailmanager.EmailAttachmentFileException;
import it.tref.liferay.portos.mailmanager.EmailAttachmentTitleException;
import it.tref.liferay.portos.mailmanager.NoSuchEmailException;
import it.tref.liferay.portos.mailmanager.model.EmailAttachment;
import it.tref.liferay.portos.mailmanager.service.base.EmailAttachmentLocalServiceBaseImpl;
import it.tref.liferay.portos.mailmanager.service.persistence.EmailAttachmentPK;
import java.io.File;
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
@ -57,54 +53,46 @@ import java.util.List;
*/
public class EmailAttachmentLocalServiceImpl extends EmailAttachmentLocalServiceBaseImpl {
/*
* 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.
* 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.
*/
public EmailAttachment addEmailAttachment(long companyId, long emailId, long folderId, String fileName,
File file) throws PortalException, SystemException {
@Override
public EmailAttachment addEmailAttachment(long companyId, long emailId, long folderId, String fileName, File file)
throws PortalException, SystemException {
Company company = companyLocalService.getCompany(companyId);
User defaultUser = company.getDefaultUser();
validate(emailId, fileName, file);
Folder folder = dlAppLocalService.getFolder(folderId);
String sourceFileName = file.getName();
String mimeType = MimeTypesUtil.getContentType(sourceFileName);
String title = fileName;
if (Validator.isNull(title)) {
title = file.getName();
}
ServiceContext serviceContext = new ServiceContext();
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);
EmailAttachment emailAttachment = emailAttachmentLocalService
.createEmailAttachment(new EmailAttachmentPK(emailId, fileEntry.getFileEntryId()));
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()));
return emailAttachmentLocalService.addEmailAttachment(emailAttachment);
}
@Override
public EmailAttachment deleteEmailAttachment(EmailAttachmentPK emailAttachmentPK) throws PortalException,
SystemException {
EmailAttachment emailAttachment = emailAttachmentLocalService.getEmailAttachment(emailAttachmentPK);
return deleteEmailAttachment(emailAttachment);
}
@Override
public EmailAttachment deleteEmailAttachment(EmailAttachment emailAttachment) throws SystemException {
try {
dlAppLocalService.deleteFileEntry(emailAttachment.getFileEntryId());
} catch (PortalException e) {
@ -113,19 +101,27 @@ public class EmailAttachmentLocalServiceImpl extends EmailAttachmentLocalService
return emailAttachment;
}
@Override
public List<EmailAttachment> findByEmailId(long emailId) throws SystemException {
return emailAttachmentPersistence.findByEmailId(emailId);
}
@Override
public List<EmailAttachment> findByEmailId(long emailId, int start, int end) throws SystemException {
return emailAttachmentPersistence.findByEmailId(emailId);
}
@Override
public int countByEmailId(long emailId) throws SystemException {
return emailAttachmentPersistence.countByEmailId(emailId);
}
@Override
public EmailAttachment fetchByFileEntryId(long fileEntryId) throws SystemException {
return emailAttachmentPersistence.fetchByFileEntryId(fileEntryId);
}
@ -134,11 +130,9 @@ public class EmailAttachmentLocalServiceImpl extends EmailAttachmentLocalService
if (Validator.isNull(emailId)) {
throw new NoSuchEmailException();
}
if (Validator.isNull(fileName) && Validator.isNull(file)) {
throw new EmailAttachmentTitleException();
}
if (Validator.isNull(file) || (Validator.isNotNull(file) && !FileUtil.exists(file))) {
throw new EmailAttachmentFileException();
}

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

@ -1,11 +1,10 @@
/**
* 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.
* 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.
*
*
*
@ -13,24 +12,6 @@
package it.tref.liferay.portos.mailmanager.service.impl;
import com.liferay.mail.model.FileAttachment;
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.Folder;
import com.liferay.portal.kernel.util.FileUtil;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.model.Company;
import com.liferay.portal.model.Group;
import com.liferay.portal.model.User;
import com.liferay.portal.security.permission.ActionKeys;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portlet.documentlibrary.model.DLFolderConstants;
import it.tref.liferay.portos.mailmanager.EmailBccException;
import it.tref.liferay.portos.mailmanager.EmailBulkAddressesException;
import it.tref.liferay.portos.mailmanager.EmailCcException;
@ -51,18 +32,34 @@ import java.util.Collections;
import java.util.Date;
import java.util.List;
import com.liferay.mail.model.FileAttachment;
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.Folder;
import com.liferay.portal.kernel.util.FileUtil;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.model.Company;
import com.liferay.portal.model.Group;
import com.liferay.portal.model.User;
import com.liferay.portal.security.permission.ActionKeys;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portlet.documentlibrary.model.DLFolderConstants;
/**
* The implementation of the email 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.EmailLocalService} 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.EmailLocalService} 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
@ -71,70 +68,69 @@ import java.util.List;
*/
public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
/*
* NOTE FOR DEVELOPERS:
*
* Never reference this interface directly. Always use {@link
* it.noovle.azimut.icf.mailmanager.service.EmailLocalServiceUtil} to access
* the email local service.
* NOTE FOR DEVELOPERS: Never reference this interface directly. Always use {@link
* it.noovle.azimut.icf.mailmanager.service.EmailLocalServiceUtil} to access the email local service.
*/
private final static Log _log = LogFactoryUtil.getLog(EmailLocalServiceImpl.class);
public Email addEmail(String className, long classPK, String from, String to[], String cc[],
String bcc[], String subject, String body, boolean htmlFormat, ServiceContext serviceContext)
throws Exception {
return addEmail(className, classPK, from, to, cc, bcc, null, subject, body, htmlFormat, null, null,
null, null, 0, false, null, null, Collections.<FileAttachment> emptyList(), serviceContext);
}
@Override
public Email addEmail(String className, long classPK, String from, String to[], String cc[], String bcc[],
String subject, String body, boolean htmlFormat, ServiceContext serviceContext) throws Exception {
public Email addEmail(String className, long classPK, String from, String to[], String cc[],
String bcc[], String subject, String body, boolean htmlFormat,
List<FileAttachment> fileAttachments, ServiceContext serviceContext) throws Exception {
return addEmail(className, classPK, from, to, cc, bcc, null, subject, body, htmlFormat, null, null,
null, null, 0, false, null, null, fileAttachments, false, null, serviceContext);
return addEmail(className, classPK, from, to, cc, bcc, null, subject, body, htmlFormat, null, null, null, null,
0, false, null, null, Collections.<FileAttachment> emptyList(), serviceContext);
}
public Email addEmail(String className, long classPK, String from, String to[], String cc[],
String bcc[], String[] bulkAddresses, String subject, String body, boolean htmlFormat,
String[] replyTo, String messageId, String inReplyTo, String smtpHost, int smtpPort,
boolean smtpSecure, String smtpUsername, String smtpPassword,
List<FileAttachment> fileAttachments, ServiceContext serviceContext) throws Exception {
return addEmail(className, classPK, from, to, cc, bcc, bulkAddresses, subject, body, htmlFormat,
replyTo, messageId, inReplyTo, smtpHost, smtpPort, smtpSecure, smtpUsername, smtpPassword,
fileAttachments, false, null, serviceContext);
@Override
public Email addEmail(String className, long classPK, String from, String to[], String cc[], String bcc[],
String subject, String body, boolean htmlFormat, List<FileAttachment> fileAttachments,
ServiceContext serviceContext) throws Exception {
return addEmail(className, classPK, from, to, cc, bcc, null, subject, body, htmlFormat, null, null, null, null,
0, false, null, null, fileAttachments, false, null, serviceContext);
}
public Email addEmail(String className, long classPK, String from, String to[], String cc[],
String bcc[], String subject, String body, boolean htmlFormat,
List<FileAttachment> fileAttachments, boolean sendSync, ServiceContext serviceContext)
throws Exception {
return addEmail(className, classPK, from, to, cc, bcc, null, subject, body, htmlFormat, null, null,
null, null, 0, false, null, null, fileAttachments, sendSync, null, serviceContext);
@Override
public Email addEmail(String className, long classPK, String from, String to[], String cc[], String bcc[],
String[] bulkAddresses, String subject, String body, boolean htmlFormat, String[] replyTo,
String messageId, String inReplyTo, String smtpHost, int smtpPort, boolean smtpSecure, String smtpUsername,
String smtpPassword, List<FileAttachment> fileAttachments, ServiceContext serviceContext) throws Exception {
return addEmail(className, classPK, from, to, cc, bcc, bulkAddresses, subject, body, htmlFormat, replyTo,
messageId, inReplyTo, smtpHost, smtpPort, smtpSecure, smtpUsername, smtpPassword, fileAttachments,
false, null, serviceContext);
}
public Email addEmail(String className, long classPK, String from, String to[], String cc[],
String bcc[], String subject, String body, boolean htmlFormat,
List<FileAttachment> fileAttachments, boolean sendSync, String templateName,
@Override
public Email addEmail(String className, long classPK, String from, String to[], String cc[], String bcc[],
String subject, String body, boolean htmlFormat, List<FileAttachment> fileAttachments, boolean sendSync,
ServiceContext serviceContext) throws Exception {
return addEmail(className, classPK, from, to, cc, bcc, null, subject, body, htmlFormat, null, null,
null, null, 0, false, null, null, fileAttachments, sendSync, templateName, serviceContext);
return addEmail(className, classPK, from, to, cc, bcc, null, subject, body, htmlFormat, null, null, null, null,
0, false, null, null, fileAttachments, sendSync, null, serviceContext);
}
public Email addEmail(String className, long classPK, String from, String to[], String cc[],
String bcc[], String[] bulkAddresses, String subject, String body, boolean htmlFormat,
String[] replyTo, String messageId, String inReplyTo, String smtpHost, int smtpPort,
boolean smtpSecure, String smtpUsername, String smtpPassword,
List<FileAttachment> fileAttachments, boolean sendSync, String templateName,
@Override
public Email addEmail(String className, long classPK, String from, String to[], String cc[], String bcc[],
String subject, String body, boolean htmlFormat, List<FileAttachment> fileAttachments, boolean sendSync,
String templateName, ServiceContext serviceContext) throws Exception {
return addEmail(className, classPK, from, to, cc, bcc, null, subject, body, htmlFormat, null, null, null, null,
0, false, null, null, fileAttachments, sendSync, templateName, serviceContext);
}
@Override
public Email addEmail(String className, long classPK, String from, String to[], String cc[], String bcc[],
String[] bulkAddresses, String subject, String body, boolean htmlFormat, String[] replyTo,
String messageId, String inReplyTo, String smtpHost, int smtpPort, boolean smtpSecure, String smtpUsername,
String smtpPassword, List<FileAttachment> fileAttachments, boolean sendSync, String templateName,
ServiceContext serviceContext) throws Exception {
User user = userLocalService.getUser(serviceContext.getUserId());
Date now = new Date();
validate(from, to, cc, bcc, bulkAddresses, subject, body, replyTo);
Email email = emailLocalService.createEmail(counterLocalService.increment(Email.class.getName()));
email.setGroupId(serviceContext.getScopeGroupId());
email.setCompanyId(serviceContext.getCompanyId());
email.setCreateDate(serviceContext.getCreateDate(now));
@ -143,7 +139,6 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
email.setClassPK(classPK);
email.setUserId(user.getUserId());
email.setUserName(user.getFullName());
email.setFrom(from);
email.setTo(StringUtil.merge(to, StringPool.COMMA));
email.setCc(StringUtil.merge(cc, StringPool.COMMA));
@ -151,12 +146,10 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
email.setBulkAddresses(StringUtil.merge(bulkAddresses, StringPool.COMMA));
email.setSubject(subject);
email.setBody(body);
email.setHtmlFormat(htmlFormat);
email.setReplyTo(StringUtil.merge(replyTo, StringPool.COMMA));
email.setMessageId(messageId);
email.setInReplyTo(inReplyTo);
email.setSmtpHost(smtpHost);
email.setSmtpPort(smtpPort);
email.setSmtpSecure(smtpSecure);
@ -164,47 +157,33 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
email.setSmtpPassword(smtpPassword);
email.setCancel(false);
email.setTemplateName(templateName);
email = addEmail(email);
// Email Attachments
if (fileAttachments != null && !fileAttachments.isEmpty()) {
Folder folder = addEmailAttachmentsFolder(serviceContext.getCompanyId(), email.getEmailId());
for (FileAttachment fileAttachment : fileAttachments) {
if (fileAttachment instanceof FileAttachment) {
((it.tref.liferay.portos.mailmanager.shared.model.FileAttachment) fileAttachment)
.generateFile();
((it.tref.liferay.portos.mailmanager.shared.model.FileAttachment) fileAttachment).generateFile();
}
emailAttachmentLocalService.addEmailAttachment(serviceContext.getCompanyId(),
email.getEmailId(), folder.getFolderId(), fileAttachment.getFileName(),
fileAttachment.getFile());
emailAttachmentLocalService.addEmailAttachment(serviceContext.getCompanyId(), email.getEmailId(),
folder.getFolderId(), fileAttachment.getFileName(), fileAttachment.getFile());
FileUtil.delete(fileAttachment.getFile());
}
}
// Manifattura Web Group per Regione Siciliana
// Il valore di ritorno viene ignorato da SchedulerInvioDocumenti, le
// mail impostate per l'invio asincrono si perdono nell'abisso
// dell'oblio. Siccome questo è già un task asincrono, inviamo in
// maniera sincrona e festeggiamo.
sendSync = true;
if (sendSync) {
MailSenderUtil.sendMail(email);
markAsSent(email.getEmailId(), new Date(), StringPool.BLANK);
}
return email;
}
public Email updateEmail(long emailId, String from, String to[], String cc[], String bcc[],
String subject, String body, ServiceContext serviceContext) throws Exception {
@Override
public Email updateEmail(long emailId, String from, String to[], String cc[], String bcc[], String subject,
String body, ServiceContext serviceContext) throws Exception {
Email email = emailLocalService.getEmail(emailId);
validate(from, to, cc, bcc, null, subject, body, null);
email.setModifiedDate(new Date());
email.setFrom(from);
email.setTo(StringUtil.merge(to, StringPool.COMMA));
@ -212,59 +191,53 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
email.setBcc(StringUtil.merge(bcc, StringPool.COMMA));
email.setSubject(subject);
email.setBody(body);
return updateEmail(email);
}
public Email markAsSent(long emailId, Date sentDate, String statusMessage) throws PortalException,
SystemException {
@Override
public Email markAsSent(long emailId, Date sentDate, String statusMessage) throws PortalException, SystemException {
Email email = emailLocalService.getEmail(emailId);
email.setModifiedDate(new Date());
email.setSent(true);
email.setSentDate(sentDate);
email.setStatusMessage(statusMessage);
return updateEmail(email);
}
public Email updateStatusMessage(long emailId, String statusMessage) throws PortalException,
SystemException {
@Override
public Email updateStatusMessage(long emailId, String statusMessage) throws PortalException, SystemException {
Email email = emailLocalService.getEmail(emailId);
email.setModifiedDate(new Date());
email.setStatusMessage(statusMessage);
return updateEmail(email);
}
@Override
public Email resendEmail(long emailId) throws PortalException, SystemException {
Email email = emailLocalService.getEmail(emailId);
email.setModifiedDate(new Date());
email.setStatusMessage("");
email.setStatusMessage(StringPool.BLANK);
email.setSent(false);
email.setSentDate(null);
email.setCancel(false);
return updateEmail(email);
}
@Override
public Email cancelEmail(long emailId) throws PortalException, SystemException {
Email email = emailLocalService.getEmail(emailId);
email.setModifiedDate(new Date());
email.setCancel(true);
return updateEmail(email);
}
@Override
public Email deleteEmail(long emailId) throws PortalException, SystemException {
Email email = emailLocalService.getEmail(emailId);
return deleteEmail(email);
}
@ -273,108 +246,125 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
public Email deleteEmail(Email email) throws SystemException {
super.deleteEmail(email);
// Email Attachments
List<EmailAttachment> emailAttachments = emailAttachmentLocalService
.findByEmailId(email.getEmailId());
List<EmailAttachment> emailAttachments = emailAttachmentLocalService.findByEmailId(email.getEmailId());
for (EmailAttachment emailAttachment : emailAttachments) {
emailAttachmentLocalService.deleteEmailAttachment(emailAttachment);
}
return email;
}
@Override
public List<Email> findByCompany(long companyId) throws SystemException {
return emailPersistence.findByCompany(companyId);
}
@Override
public List<Email> findByCompany(long companyId, int start, int end) throws SystemException {
return emailPersistence.findByCompany(companyId, start, end);
}
@Override
public List<Email> findByCompany(long companyId, int start, int end, OrderByComparator orderByComparator)
throws SystemException {
return emailPersistence.findByCompany(companyId, start, end, orderByComparator);
}
@Override
public int countByCompany(long companyId) throws SystemException {
return emailPersistence.countByCompany(companyId);
}
@Override
public List<Email> findByC_G(long companyId, long groupId) throws SystemException {
return emailPersistence.findByC_G(companyId, groupId);
}
@Override
public List<Email> findByC_G(long companyId, long groupId, int start, int end) throws SystemException {
return emailPersistence.findByC_G(companyId, groupId, start, end);
}
public List<Email> findByC_G(long companyId, long groupId, int start, int end,
OrderByComparator orderByComparator) throws SystemException {
@Override
public List<Email> findByC_G(long companyId, long groupId, int start, int end, OrderByComparator orderByComparator)
throws SystemException {
return emailPersistence.findByC_G(companyId, groupId, start, end, orderByComparator);
}
@Override
public int countByC_G(long companyId, long groupId) throws SystemException {
return emailPersistence.countByC_G(companyId, groupId);
}
@Override
public List<Email> findByC_G_T(long companyId, long groupId, String templateName) throws SystemException {
return emailPersistence.findByC_G_T(companyId, groupId, templateName);
}
@Override
public List<Email> findByC_G_T(long companyId, long groupId, String templateName, int start, int end)
throws SystemException {
return emailPersistence.findByC_G_T(companyId, groupId, templateName, start, end);
}
@Override
public int countByC_G_T(long companyId, long groupId, String templateName) throws SystemException {
return emailPersistence.countByC_G_T(companyId, groupId, templateName);
}
@Override
public List<Email> findByC_G_C_C(long companyId, long groupId, long classNameId, long classPK)
throws SystemException {
return emailPersistence.findByC_G_C_C(companyId, groupId, classNameId, classPK);
}
public List<Email> findByC_G_C_C(long companyId, long groupId, long classNameId, long classPK, int start,
int end) throws SystemException {
@Override
public List<Email> findByC_G_C_C(long companyId, long groupId, long classNameId, long classPK, int start, int end)
throws SystemException {
return emailPersistence.findByC_G_C_C(companyId, groupId, classNameId, classPK, start, end);
}
public int countByC_G_C_C(long companyId, long groupId, long classNameId, long classPK)
throws SystemException {
@Override
public int countByC_G_C_C(long companyId, long groupId, long classNameId, long classPK) throws SystemException {
return emailPersistence.countByC_G_C_C(companyId, groupId, classNameId, classPK);
}
private Folder addEmailAttachmentsFolder(long companyId, long emailId) throws PortalException,
SystemException {
private Folder addEmailAttachmentsFolder(long companyId, long emailId) throws PortalException, SystemException {
Company company = companyLocalService.getCompany(companyId);
Group companyGroup = company.getGroup();
User defaultUser = company.getDefaultUser();
Folder folder = dlAppLocalService.getFolder(companyGroup.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, EmailConstants.DEFAULT_ATTACHMENTS_FOLDER_NAME);
ServiceContext serviceContext = new ServiceContext();
serviceContext.setGroupPermissions(new String[] { ActionKeys.VIEW });
serviceContext.setGuestPermissions(new String[] { ActionKeys.VIEW });
return dlAppLocalService.addFolder(defaultUser.getUserId(), folder.getRepositoryId(),
folder.getFolderId(), String.valueOf(emailId), StringPool.BLANK, serviceContext);
return dlAppLocalService.addFolder(defaultUser.getUserId(), folder.getRepositoryId(), folder.getFolderId(),
String.valueOf(emailId), StringPool.BLANK, serviceContext);
}
private void validate(String from, String to[], String cc[], String bcc[], String[] bulkAddresses,
String subject, String body, String[] replyTo) throws PortalException {
private void validate(String from, String to[], String cc[], String bcc[], String[] bulkAddresses, String subject,
String body, String[] replyTo) throws PortalException {
if (Validator.isNull(from)) {
throw new RequiredEmailFromException();
} else if (!Validator.isEmailAddress(from)) {
throw new EmailFromException();
}
if (to == null || (to != null && to.length == 0)) {
throw new RequiredEmailToException();
} else {
@ -384,7 +374,6 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
}
}
}
if (cc != null && cc.length > 0) {
for (String emailAddress : cc) {
if (!Validator.isEmailAddress(emailAddress)) {
@ -392,7 +381,6 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
}
}
}
if (bcc != null && bcc.length > 0) {
for (String emailAddress : bcc) {
if (!Validator.isEmailAddress(emailAddress)) {
@ -400,7 +388,6 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
}
}
}
if (bulkAddresses != null && bulkAddresses.length > 0) {
for (String emailAddress : bulkAddresses) {
if (!Validator.isEmailAddress(emailAddress)) {
@ -408,15 +395,12 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
}
}
}
if (Validator.isNull(subject)) {
throw new RequiredEmailSubjectException();
}
if (Validator.isNull(body)) {
throw new RequiredEmailBodyException();
}
if (replyTo != null && replyTo.length == 0) {
for (String emailAddress : replyTo) {
if (!Validator.isEmailAddress(emailAddress)) {

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

@ -1,11 +1,10 @@
/**
* 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.
* 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.
*
*
*
@ -13,26 +12,25 @@
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.service.ServiceContext;
import it.tref.liferay.portos.mailmanager.model.Email;
import it.tref.liferay.portos.mailmanager.permission.ActionKeys;
import it.tref.liferay.portos.mailmanager.permission.EmailPermission;
import it.tref.liferay.portos.mailmanager.service.base.EmailServiceBaseImpl;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.service.ServiceContext;
/**
* The implementation of the email 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.tref.liferay.portos.mailmanager.service.EmailService} 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.tref.liferay.portos.mailmanager.service.EmailService} 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
@ -41,25 +39,28 @@ import it.tref.liferay.portos.mailmanager.service.base.EmailServiceBaseImpl;
*/
public class EmailServiceImpl extends EmailServiceBaseImpl {
/*
* NOTE FOR DEVELOPERS:
*
* Never reference this interface directly. Always use {@link
* it.tref.liferay.portos.mailmanager.service.EmailServiceUtil} to access the email remote
* service.
* NOTE FOR DEVELOPERS: Never reference this interface directly. Always use {@link
* it.tref.liferay.portos.mailmanager.service.EmailServiceUtil} to access the email remote service.
*/
@Override
public Email updateEmail(long emailId, String from, String to[], String cc[], String bcc[], String subject,
String body, ServiceContext serviceContext) throws Exception {
EmailPermission.check(getPermissionChecker(), serviceContext.getScopeGroupId(), ActionKeys.ADMIN_EMAIL);
return emailLocalService.updateEmail(emailId, from, to, cc, bcc, subject, body, serviceContext);
}
@Override
public Email resendEmail(long emailId, ServiceContext serviceContext) throws PortalException, SystemException {
EmailPermission.check(getPermissionChecker(), serviceContext.getScopeGroupId(), ActionKeys.ADMIN_EMAIL);
return emailLocalService.resendEmail(emailId);
}
@Override
public Email cancelEmail(long emailId, ServiceContext serviceContext) throws PortalException, SystemException {
EmailPermission.check(getPermissionChecker(), serviceContext.getScopeGroupId(), ActionKeys.ADMIN_EMAIL);
return emailLocalService.cancelEmail(emailId);
}

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

@ -1,27 +1,17 @@
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under the terms of the
* GNU Lesser General Public License as published by the Free Software Foundation; either version
* 2.1 of the License, or (at your option) any later version.
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library 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
* Lesser General Public License for more details.
* This library 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 Lesser General Public License for more
* details.
*/
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.util.OrderByComparator;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.model.ResourceConstants;
import com.liferay.portal.model.User;
import com.liferay.portal.service.ServiceContext;
import it.tref.liferay.portos.mailmanager.EmailTemplateCcException;
import it.tref.liferay.portos.mailmanager.EmailTemplateCcnException;
import it.tref.liferay.portos.mailmanager.EmailTemplateFromException;
@ -37,17 +27,26 @@ import it.tref.liferay.portos.mailmanager.service.base.EmailTemplateLocalService
import java.util.Date;
import java.util.List;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.model.ResourceConstants;
import com.liferay.portal.model.User;
import com.liferay.portal.service.ServiceContext;
/**
* The implementation of the email template 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.EmailTemplateLocalService} 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.EmailTemplateLocalService} 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
@ -56,82 +55,65 @@ import java.util.List;
*/
public class EmailTemplateLocalServiceImpl extends EmailTemplateLocalServiceBaseImpl {
/*
* NOTE FOR DEVELOPERS:
*
* Never reference this interface directly. Always use {@link
* it.noovle.azimut.icf.mailmanager.service.EmailTemplateLocalServiceUtil} to access the email
* template local service.
* NOTE FOR DEVELOPERS: Never reference this interface directly. Always use {@link
* it.noovle.azimut.icf.mailmanager.service.EmailTemplateLocalServiceUtil} to access the email template local
* service.
*/
@Override
public EmailTemplate addEmailTemplate(String templateName, String from, String[] to, String[] cc, String[] ccn,
String subject, String body, boolean attachmentPermitted, ServiceContext serviceContext) throws SystemException,
PortalException {
String subject, String body, boolean attachmentPermitted, ServiceContext serviceContext)
throws SystemException, PortalException {
User user = userLocalService.getUser(serviceContext.getUserId());
Date now = new Date();
validate(templateName, from, to, cc, ccn, subject, body);
EmailTemplate emailTemplate =
emailTemplateLocalService.createEmailTemplate(counterLocalService.increment(EmailTemplate.class.getName()));
EmailTemplate emailTemplate = emailTemplateLocalService.createEmailTemplate(counterLocalService
.increment(EmailTemplate.class.getName()));
emailTemplate.setCompanyId(serviceContext.getCompanyId());
emailTemplate.setUserId(user.getUserId());
emailTemplate.setUserName(user.getFullName());
emailTemplate.setCreateDate(serviceContext.getCreateDate(now));
emailTemplate.setModifiedDate(serviceContext.getModifiedDate(now));
emailTemplate.setGroupId(serviceContext.getScopeGroupId());
emailTemplate.setTemplateName(templateName);
emailTemplate.setFrom(from);
emailTemplate.setTo(StringUtil.merge(to, StringPool.COMMA));
emailTemplate.setCc(StringUtil.merge(cc, StringPool.COMMA));
emailTemplate.setCcn(StringUtil.merge(ccn, StringPool.COMMA));
emailTemplate.setSubject(subject);
emailTemplate.setBody(body);
emailTemplate.setAttachmentPermitted(attachmentPermitted);
emailTemplate = emailTemplateLocalService.addEmailTemplate(emailTemplate);
// Resource
resourceLocalService.addResources(emailTemplate.getCompanyId(), emailTemplate.getGroupId(),
emailTemplate.getUserId(), EmailTemplate.class.getName(), emailTemplate.getPrimaryKey(), false, true, true);
emailTemplate.getUserId(), EmailTemplate.class.getName(), emailTemplate.getPrimaryKey(), false, true,
true);
return emailTemplate;
}
@Override
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 {
String[] cc, String[] ccn, String subject, String body, boolean attachmentPermitted,
ServiceContext serviceContext) throws SystemException, PortalException {
EmailTemplate emailTemplate = emailTemplateLocalService.getEmailTemplate(emailTemplateId);
validate(templateName, from, to, cc, ccn, subject, body);
emailTemplate.setModifiedDate(serviceContext.getModifiedDate(new Date()));
emailTemplate.setFrom(from);
emailTemplate.setTo(StringUtil.merge(to, StringPool.COMMA));
emailTemplate.setCc(StringUtil.merge(cc, StringPool.COMMA));
emailTemplate.setCcn(StringUtil.merge(ccn, StringPool.COMMA));
emailTemplate.setSubject(subject);
emailTemplate.setBody(body);
emailTemplate.setAttachmentPermitted(attachmentPermitted);
emailTemplate = emailTemplateLocalService.updateEmailTemplate(emailTemplate);
return emailTemplate;
}
@Override
public EmailTemplate deleteEmailTemplate(long emailTemplateId) throws PortalException, SystemException {
EmailTemplate emailTemplate = emailTemplateLocalService.getEmailTemplate(emailTemplateId);
return deleteEmailTemplate(emailTemplate);
}
@ -140,59 +122,65 @@ public class EmailTemplateLocalServiceImpl extends EmailTemplateLocalServiceBase
public EmailTemplate deleteEmailTemplate(EmailTemplate emailTemplate) throws SystemException {
super.deleteEmailTemplate(emailTemplate);
// Resource
try {
resourceLocalService.deleteResource(emailTemplate.getCompanyId(), EmailTemplate.class.getName(),
ResourceConstants.SCOPE_INDIVIDUAL, emailTemplate.getPrimaryKey());
} catch (PortalException e) {
}
return emailTemplate;
}
@Override
public int countByC_GroupId(long companyId, long groupId) throws SystemException {
return emailTemplatePersistence.countByC_GroupId(companyId, groupId);
}
@Override
public List<EmailTemplate> findByC_GroupId(long companyId, long groupId, int start, int end, OrderByComparator orderBy)
throws SystemException {
public List<EmailTemplate> findByC_GroupId(long companyId, long groupId, int start, int end,
OrderByComparator orderBy) throws SystemException {
return emailTemplatePersistence.findByC_GroupId(companyId, groupId, start, end, orderBy);
}
@Override
public EmailTemplate findByC_GroupId_Name(long companyId, long groupId, String templateName)
throws NoSuchEmailTemplateException, SystemException {
return emailTemplatePersistence.findByC_GroupId_Name(companyId, groupId, templateName);
}
@Override
public EmailTemplate fetchByC_GroupId_Name(long companyId, long groupId, String templateName) throws SystemException {
public EmailTemplate fetchByC_GroupId_Name(long companyId, long groupId, String templateName)
throws SystemException {
return emailTemplatePersistence.fetchByC_GroupId_Name(companyId, groupId, templateName);
}
@Override
public int countByCompany(long companyId) throws SystemException {
return emailTemplatePersistence.countByCompany(companyId);
}
@Override
public List<EmailTemplate> findByCompany(long companyId, int start, int end, OrderByComparator orderBy)
throws SystemException {
return emailTemplatePersistence.findByCompany(companyId, start, end, orderBy);
}
@Override
public int countByC_Name(long companyId, String name) throws SystemException {
return emailTemplatePersistence.countByC_Name(companyId, name);
}
@Override
public EmailTemplate findByC_Name(long companyId, String templateName) throws SystemException,
NoSuchEmailTemplateException {
return emailTemplatePersistence.findByC_Name(companyId, templateName);
}
@ -202,13 +190,11 @@ public class EmailTemplateLocalServiceImpl extends EmailTemplateLocalServiceBase
if (Validator.isNull(templateName)) {
throw new RequiredEmailTemplateNameException();
}
if (Validator.isNull(from)) {
throw new RequiredEmailTemplateFromException();
} else if (!Validator.isEmailAddress(from)) {
throw new EmailTemplateFromException();
}
if (to != null && to.length > 0) {
for (String emailAddress : to) {
if (!Validator.isEmailAddress(emailAddress)) {
@ -216,7 +202,6 @@ public class EmailTemplateLocalServiceImpl extends EmailTemplateLocalServiceBase
}
}
}
if (cc != null && cc.length > 0) {
for (String emailAddress : cc) {
if (!Validator.isEmailAddress(emailAddress)) {
@ -224,7 +209,6 @@ public class EmailTemplateLocalServiceImpl extends EmailTemplateLocalServiceBase
}
}
}
if (ccn != null && ccn.length > 0) {
for (String emailAddress : ccn) {
if (!Validator.isEmailAddress(emailAddress)) {
@ -232,14 +216,11 @@ public class EmailTemplateLocalServiceImpl extends EmailTemplateLocalServiceBase
}
}
}
if (Validator.isNull(subject)) {
throw new RequiredEmailTemplateSubjectException();
}
if (Validator.isNull(body)) {
throw new RequiredEmailTemplateBodyException();
}
}
}

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

@ -1,40 +1,37 @@
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under the terms of the
* GNU Lesser General Public License as published by the Free Software Foundation; either version
* 2.1 of the License, or (at your option) any later version.
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library 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
* Lesser General Public License for more details.
* This library 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 Lesser General Public License for more
* details.
*/
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.security.permission.ActionKeys;
import com.liferay.portal.service.ServiceContext;
import it.tref.liferay.portos.mailmanager.model.EmailTemplate;
import it.tref.liferay.portos.mailmanager.permission.EmailTemplateEntryPermission;
import it.tref.liferay.portos.mailmanager.permission.EmailTemplatePermission;
import it.tref.liferay.portos.mailmanager.service.base.EmailTemplateServiceBaseImpl;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.security.permission.ActionKeys;
import com.liferay.portal.service.ServiceContext;
/**
* 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
@ -43,39 +40,34 @@ import it.tref.liferay.portos.mailmanager.service.base.EmailTemplateServiceBaseI
*/
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.
* 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.
*/
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);
@Override
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);
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,
@Override
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);
}
@Override
public EmailTemplate deleteEmailTemplate(long emailTemplateId) throws PortalException, SystemException {
EmailTemplateEntryPermission.check(getPermissionChecker(), emailTemplateId, ActionKeys.DELETE);
return emailTemplateLocalService.deleteEmailTemplate(emailTemplateId);
}
}

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

@ -97,6 +97,7 @@ public class MailEngine {
}
public static void send(byte[] bytes) throws MailEngineException {
try {
Session session = getSession();
Message message = new MimeMessage(session, new UnsyncByteArrayInputStream(bytes));
@ -359,6 +360,7 @@ public class MailEngine {
private static void _send(Session session, Message message, InternetAddress[] bulkAddresses, int batchSize)
throws MailEngineException {
try {
boolean smtpAuth = GetterUtil.getBoolean(_getSMTPProperty(session, "auth"), false);
String smtpHost = _getSMTPProperty(session, "host");

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

@ -33,7 +33,8 @@ public class MailSenderUtil {
private static final Log _log = LogFactoryUtil.getLog(MailSenderUtil.class);
public static void sendMail(Email email) throws Exception {
_log.info("sendMail to: " + StringUtils.join(email.getToArray(), ", "));
_log.info("sendMail to: " + StringUtils.join(email.getToArray(), StringPool.COMMA_AND_SPACE));
InternetAddress from = toInternetAddress(email.getFrom());
InternetAddress[] to = toInternetAddresses(email.getToArray());
InternetAddress[] cc = toInternetAddresses(email.getCcArray());
@ -70,6 +71,7 @@ public class MailSenderUtil {
}
private static InternetAddress toInternetAddress(String address) throws AddressException {
if (Validator.isNull(address)) {
return null;
}
@ -77,6 +79,7 @@ public class MailSenderUtil {
}
private static InternetAddress[] toInternetAddresses(String[] addresses) throws AddressException {
if (addresses == null || addresses.length == 0) {
return null;
}
@ -89,6 +92,7 @@ public class MailSenderUtil {
private static List<FileAttachment> toFileAttachments(List<EmailAttachment> emailAttachments)
throws PortalException, SystemException, IOException {
List<FileAttachment> fileAttachments = new ArrayList<>(emailAttachments.size());
for (EmailAttachment emailAttachment : emailAttachments) {
InputStream inputStream = null;

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

@ -1,56 +1,44 @@
package it.tref.liferay.portos.mailmanager.util;
import com.liferay.portal.kernel.io.unsync.UnsyncStringWriter;
import com.liferay.portal.kernel.json.JSONObject;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.Validator;
import java.util.Iterator;
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.json.JSONObject;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.Validator;
public class VelocityUtil {
public static VelocityContext fromJSONObjectOneLevelDepth(JSONObject jsonObject) {
VelocityContext velocityContext = new VelocityContext();
while (jsonObject.keys().hasNext()) {
String key = jsonObject.keys().next();
velocityContext.put(key, jsonObject.getString(key));
}
return velocityContext;
}
public static String evaluate(String input) throws Exception {
return evaluate(input, null);
}
public static String evaluate(String input, JSONObject 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) {
Iterator<String> iteratiorKeys = variables.keys();
while (iteratiorKeys.hasNext()) {
String key = iteratiorKeys.next();
if (Validator.isNotNull(key)) {
@ -58,12 +46,8 @@ public class VelocityUtil {
}
}
}
UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter();
velocityEngine.evaluate(velocityContext, unsyncStringWriter, VelocityUtil.class.getName(), input);
return unsyncStringWriter.toString();
}
}

3
liferay-plugins-sdk-6.2/portlets/portos-report-engine-portlet/.settings/org.eclipse.wst.common.component

@ -5,9 +5,6 @@
<dependent-module archiveName="portos-bo-portlet-service.jar" deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/portos-bo-portlet/docroot/WEB-INF/lib/portos-bo-portlet-service.jar">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="portos-bo-portlet-service.jar" deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/portos-bo-portlet/docroot/WEB-INF/lib/portos-bo-portlet-service.jar">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="context-root" value="portos-report-engine-portlet"/>
<property name="java-output-path" value="/portos-report-engine-portlet/docroot/WEB-INF/classes"/>
</wb-module>

61
liferay-plugins-sdk-6.2/shared/portos-mail-manager-shared/src/it/tref/liferay/portos/mailmanager/shared/messaging/util/MailManagerUtil.java

@ -1,19 +1,5 @@
package it.tref.liferay.portos.mailmanager.shared.messaging.util;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSONFactoryUtil;
import com.liferay.portal.kernel.json.JSONObject;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.mail.MailMessage;
import com.liferay.portal.kernel.messaging.Message;
import com.liferay.portal.kernel.messaging.MessageBusException;
import com.liferay.portal.kernel.messaging.MessageBusUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.service.ServiceContext;
import it.tref.liferay.portos.mailmanager.shared.messaging.dto.MailTemplateMessage;
import it.tref.liferay.portos.mailmanager.shared.messaging.dto.TemplateMessage;
import it.tref.liferay.portos.mailmanager.shared.model.FileAttachment;
@ -27,33 +13,36 @@ import java.util.concurrent.TimeUnit;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
public class MailManagerUtil {
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSONFactoryUtil;
import com.liferay.portal.kernel.json.JSONObject;
import com.liferay.portal.kernel.mail.MailMessage;
import com.liferay.portal.kernel.messaging.Message;
import com.liferay.portal.kernel.messaging.MessageBusException;
import com.liferay.portal.kernel.messaging.MessageBusUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.service.ServiceContext;
private final static Log _log = LogFactoryUtil.getLog(MailManagerUtil.class);
public class MailManagerUtil {
public static boolean sendMail(String messageId, String inReplyTo, String from, String[] to, String[] cc,
String[] bcc, String subject, String body, boolean htmlFormat, boolean async,
boolean checkPermission, ServiceContext serviceContext) throws AddressException, SystemException {
InternetAddress fromInternetAddress = new InternetAddress(from, true);
InternetAddress[] toInternetAddress = MailUtil.fromStringAddress(to);
InternetAddress[] ccInternetAddress = MailUtil.fromStringAddress(cc);
InternetAddress[] bccInternetAddress = MailUtil.fromStringAddress(bcc);
MailMessage mailMessage = new MailMessage(fromInternetAddress, subject, body, htmlFormat);
mailMessage.setTo(toInternetAddress);
mailMessage.setCC(ccInternetAddress);
mailMessage.setBCC(bccInternetAddress);
Message message = new Message();
message.put("serviceContext", serviceContext);
message.setPayload(JSONFactoryUtil.looseSerializeDeep(mailMessage));
try {
if (async) {
message.put("mode", MailManagerConstants.MESSAGING_SEND_MODE_ASYNC);
MessageBusUtil.sendMessage(DestinationNames.SEND_MAIL, message);
@ -63,15 +52,14 @@ public class MailManagerUtil {
return GetterUtil.getBoolean(MessageBusUtil.sendSynchronousMessage(
DestinationNames.SEND_MAIL_SYNC, message, TimeUnit.SECONDS.toMillis(30)));
}
} catch (MessageBusException e) {
throw new SystemException(e);
}
}
public static boolean sendMailByTemplateId(String className, long classPK, long templateId,
JSONObject templateVariables, ServiceContext serviceContext) throws SystemException {
return sendMailByTemplate(className, classPK, templateId, StringPool.BLANK, null, null, null,
templateVariables, Collections.<FileAttachment> emptyList(), true, true, serviceContext);
}
@ -79,6 +67,7 @@ public class MailManagerUtil {
public static boolean sendMailByTemplateId(String className, long classPK, long templateId,
JSONObject templateVariables, List<FileAttachment> fileAttachments, ServiceContext serviceContext)
throws SystemException {
return sendMailByTemplate(className, classPK, templateId, StringPool.BLANK, null, null, null,
templateVariables, fileAttachments, true, true, serviceContext);
}
@ -86,27 +75,31 @@ public class MailManagerUtil {
public static boolean sendMailByTemplateId(String className, long classPK, long templateId, String[] to,
String[] cc, String[] ccn, JSONObject templateVariables, List<FileAttachment> fileAttachments,
ServiceContext serviceContext) throws SystemException {
return sendMailByTemplate(className, classPK, templateId, StringPool.BLANK, to, cc, ccn,
templateVariables, fileAttachments, true, true, serviceContext);
}
public static boolean sendMailByTemplateName(String className, long classPK, String templateName,
JSONObject templateVariables, ServiceContext serviceContext) throws SystemException {
return sendMailByTemplate(className, classPK, 0l, templateName, null, null, null, templateVariables,
return sendMailByTemplate(className, classPK, 0L, templateName, null, null, null, templateVariables,
Collections.<FileAttachment> emptyList(), true, true, serviceContext);
}
public static boolean sendMailByTemplateName(String className, long classPK, String templateName,
JSONObject templateVariables, List<FileAttachment> fileAttachments, ServiceContext serviceContext)
throws SystemException {
return sendMailByTemplate(className, classPK, 0l, templateName, null, null, null, templateVariables,
return sendMailByTemplate(className, classPK, 0L, templateName, null, null, null, templateVariables,
fileAttachments, true, true, serviceContext);
}
public static boolean sendMailByTemplatName(String className, long classPK, String templateName,
String[] to, String[] cc, String[] ccn, JSONObject templateVariables,
List<FileAttachment> fileAttachments, ServiceContext serviceContext) throws SystemException {
return sendMailByTemplate(className, classPK, 0l, templateName, to, cc, ccn, templateVariables,
return sendMailByTemplate(className, classPK, 0L, templateName, to, cc, ccn, templateVariables,
fileAttachments, true, true, serviceContext);
}
@ -117,7 +110,6 @@ public class MailManagerUtil {
JSONObject templateParam = JSONFactoryUtil.createJSONObject();
templateParam.put(MailManagerConstants.TEMPLATE_PARAMETER_VARIABLES_KEY, templateVariables);
if (to != null && to.length > 0) {
templateParam.put(MailManagerConstants.TEMPLATE_PARAMETER_TO_KEY,
StringUtil.merge(to, StringPool.COMMA));
@ -130,21 +122,17 @@ public class MailManagerUtil {
templateParam.put(MailManagerConstants.TEMPLATE_PARAMETER_CCN_KEY,
StringUtil.merge(ccn, StringPool.COMMA));
}
MailTemplateMessage mailTemplateMessage = new MailTemplateMessage();
mailTemplateMessage.setTemplateId(templateId);
mailTemplateMessage.setTemplateName(templateName);
mailTemplateMessage.setTemplateParam(templateParam.toString());
mailTemplateMessage.setFileAttachments(fileAttachments);
Message message = new Message();
message.put("serviceContext", serviceContext);
message.put("className", className);
message.put("classPK", classPK);
message.setPayload(JSONFactoryUtil.looseSerializeDeep(mailTemplateMessage));
try {
if (async) {
message.put("mode", MailManagerConstants.MESSAGING_SEND_MODE_ASYNC);
MessageBusUtil.sendMessage(DestinationNames.SEND_TEMPLATE_MAIL, message);
@ -154,7 +142,6 @@ public class MailManagerUtil {
return GetterUtil.getBoolean(MessageBusUtil.sendSynchronousMessage(
DestinationNames.SEND_TEMPLATE_MAIL_SYNC, message, TimeUnit.SECONDS.toMillis(30)));
}
} catch (MessageBusException e) {
throw new SystemException(e);
}
@ -163,7 +150,8 @@ public class MailManagerUtil {
public static boolean addMailTemplate(String templateName, String from, String[] to, String[] cc,
String[] ccn, String subject, String body, boolean attachmentPermitted,
ServiceContext serviceContext) throws SystemException {
return updateMailTemplate(0l, templateName, from, to, cc, ccn, subject, body, attachmentPermitted,
return updateMailTemplate(0L, templateName, from, to, cc, ccn, subject, body, attachmentPermitted,
serviceContext);
}
@ -181,11 +169,9 @@ public class MailManagerUtil {
templateMessage.setCcn(ccn);
templateMessage.setSubject(subject);
templateMessage.setBody(body);
Message message = new Message();
message.put("serviceContext", serviceContext);
message.setPayload(JSONFactoryUtil.looseSerializeDeep(templateMessage));
try {
return GetterUtil.getBoolean(MessageBusUtil.sendSynchronousMessage(
DestinationNames.EDIT_EMAIL_TEMPLATE, message, TimeUnit.SECONDS.toMillis(30)));
@ -193,5 +179,4 @@ public class MailManagerUtil {
throw new SystemException(e);
}
}
}

24
liferay-plugins-sdk-6.2/shared/portos-mail-manager-shared/src/it/tref/liferay/portos/mailmanager/shared/model/FileAttachment.java

@ -1,5 +1,8 @@
package it.tref.liferay.portos.mailmanager.shared.model;
import java.io.File;
import java.io.InputStream;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.repository.model.FileEntry;
@ -9,9 +12,6 @@ import com.liferay.portal.kernel.util.Validator;
import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil;
import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil;
import java.io.File;
import java.io.InputStream;
public class FileAttachment extends com.liferay.mail.model.FileAttachment {
public static final Log _log = LogFactoryUtil.getLog(FileAttachment.class);
@ -22,61 +22,71 @@ public class FileAttachment extends com.liferay.mail.model.FileAttachment {
private String fileName;
public FileAttachment() {
super();
}
public FileAttachment(File file, String fileName, String tipologia, long fileEntryId, byte[] bytes) {
super(file, fileName);
this.setTipologia(tipologia);
this.fileEntryId = fileEntryId;
this.setBytes(bytes);
}
@Override
public String getFileName() {
return fileName;
}
@Override
public void setFileName(String fileName) {
this.fileName = fileName;
super.setFileName(fileName);
}
public long getFileEntryId() {
return fileEntryId;
}
public void setFileEntryId(long fileEntryId) {
this.fileEntryId = fileEntryId;
}
public byte[] getBytes() {
return bytes;
}
public void setBytes(byte[] bytes) {
this.bytes = bytes;
}
public String getTipologia() {
return tipologia;
}
public void setTipologia(String tipologia) {
this.tipologia = tipologia;
}
public File generateFile() {
File result = null;
try {
if (Validator.isNotNull(super.getFile())) {
result = super.getFile();
} else if (Validator.isNotNull(fileEntryId)) {
FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(fileEntryId);
setFileName(fileEntry.getTitle()
+ (Validator.isNotNull(fileEntry.getExtension()) ? "." + fileEntry.getExtension()
+ (Validator.isNotNull(fileEntry.getExtension()) ? StringPool.PERIOD + fileEntry.getExtension()
: StringPool.BLANK));
InputStream is = DLFileEntryLocalServiceUtil.getFileAsStream(fileEntry.getFileEntryId(),
fileEntry.getVersion(), false);
@ -87,12 +97,10 @@ public class FileAttachment extends com.liferay.mail.model.FileAttachment {
result = FileUtil.createTempFile(bytes);
result.deleteOnExit();
}
} catch (Exception e) {
_log.error("Error during getFile()", e);
}
setFile(result);
return result;
}
}

Caricamento…
Annulla
Salva