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.protocollo.model.Protocollo;
import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants; import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
@ -32,21 +34,20 @@ public class HttpServiceUtil {
JSONSerializer serializer = new JSONSerializer(); JSONSerializer serializer = new JSONSerializer();
serializer.exclude("*.class"); serializer.exclude("*.class");
String json = serializer.serialize(protocolloBean); String json = serializer.serialize(protocolloBean);
String url = ConfigurazioneLocalServiceUtil.findByC_ChiaveString(companyId, String url = ConfigurazioneLocalServiceUtil.findByC_ChiaveString(companyId,
ConfigurazioneConstants.PROTOCOLLAZIONE_SERVICE_URL); ConfigurazioneConstants.PROTOCOLLAZIONE_SERVICE_URL);
JSONObject risposta = null; JSONObject risposta = null;
HttpPost request = new HttpPost(url); HttpPost request = new HttpPost(url);
request.addHeader("Content-type", ContentTypes.APPLICATION_JSON); request.addHeader("Content-type", ContentTypes.APPLICATION_JSON);
request.setEntity(new StringEntity(json, StringPool.UTF8)); request.setEntity(new StringEntity(json, StringPool.UTF8));
CloseableHttpClient client = HttpClientBuilder.create().build(); CloseableHttpClient client = HttpClientBuilder.create().build();
HttpResponse response = client.execute(request); HttpResponse response = client.execute(request);
int statusCode = response.getStatusLine().getStatusCode(); int statusCode = response.getStatusLine().getStatusCode();
String responseBody = EntityUtils.toString(response.getEntity(), StringPool.UTF8); String responseBody = EntityUtils.toString(response.getEntity(), StringPool.UTF8);
try {
client.close(); client.close();
} catch (IOException e) {
}
if (statusCode == HttpServletResponse.SC_OK || statusCode == HttpServletResponse.SC_CREATED) { if (statusCode == HttpServletResponse.SC_OK || statusCode == HttpServletResponse.SC_CREATED) {
risposta = JSONFactoryUtil.createJSONObject(responseBody); risposta = JSONFactoryUtil.createJSONObject(responseBody);
} }
@ -54,6 +55,7 @@ public class HttpServiceUtil {
} }
public static JSONObject postJson(String url, String json) throws Exception { public static JSONObject postJson(String url, String json) throws Exception {
JSONObject risposta = null; JSONObject risposta = null;
Options options = new Options(); Options options = new Options();
options.setLocation(url); options.setLocation(url);
@ -72,16 +74,16 @@ public class HttpServiceUtil {
} }
public static String getUrl(String url) throws Exception { public static String getUrl(String url) throws Exception {
return getUrl(url, StringPool.BLANK); return getUrl(url, StringPool.BLANK);
} }
public static String getUrl(String url, String defaultValue) throws Exception { public static String getUrl(String url, String defaultValue) throws Exception {
Options options = new Options(); Options options = new Options();
options.setLocation(url); options.setLocation(url);
options.setPost(false); options.setPost(false);
String responseBody = HttpUtil.URLtoString(options); String responseBody = HttpUtil.URLtoString(options);
if (options.getResponse().getResponseCode() != HttpServletResponse.SC_OK) { if (options.getResponse().getResponseCode() != HttpServletResponse.SC_OK) {
throw new Exception(url + ": " + options.getResponse().getResponseCode()); throw new Exception(url + ": " + options.getResponse().getResponseCode());
// responseBody = defaultValue; // 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) @com.liferay.portal.kernel.search.Indexable(type = IndexableType.REINDEX)
public it.tref.liferay.portos.bo.model.IntPratica updateStatoPratica( 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, throws com.liferay.portal.kernel.exception.PortalException,
com.liferay.portal.kernel.exception.SystemException; 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"; _methodName36 = "updateStatoPratica";
_methodParameterTypes36 = new String[] { _methodParameterTypes36 = new String[] { "long", "java.lang.String" };
"long", "long", "java.lang.String"
};
_methodName37 = "updateIntPraticaSorteggio"; _methodName37 = "updateIntPraticaSorteggio";
@ -1658,7 +1656,7 @@ public class IntPraticaLocalServiceClp implements IntPraticaLocalService {
@Override @Override
public it.tref.liferay.portos.bo.model.IntPratica updateStatoPratica( 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, throws com.liferay.portal.kernel.exception.PortalException,
com.liferay.portal.kernel.exception.SystemException { com.liferay.portal.kernel.exception.SystemException {
Object returnObj = null; Object returnObj = null;
@ -1669,8 +1667,6 @@ public class IntPraticaLocalServiceClp implements IntPraticaLocalService {
new Object[] { new Object[] {
intPraticaId, intPraticaId,
dettPraticaId,
ClpSerializer.translateInput(statoPratica) 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( 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, throws com.liferay.portal.kernel.exception.PortalException,
com.liferay.portal.kernel.exception.SystemException { com.liferay.portal.kernel.exception.SystemException {
return getService() return getService().updateStatoPratica(intPraticaId, statoPratica);
.updateStatoPratica(intPraticaId, dettPraticaId, statoPratica);
} }
public static it.tref.liferay.portos.bo.model.IntPratica updateIntPraticaSorteggio( 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 @Override
public it.tref.liferay.portos.bo.model.IntPratica updateStatoPratica( 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, throws com.liferay.portal.kernel.exception.PortalException,
com.liferay.portal.kernel.exception.SystemException { com.liferay.portal.kernel.exception.SystemException {
return _intPraticaLocalService.updateStatoPratica(intPraticaId, return _intPraticaLocalService.updateStatoPratica(intPraticaId,
dettPraticaId, statoPratica); statoPratica);
} }
@Override @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; package it.tref.liferay.portos.bo.util;
import it.tref.liferay.portos.bo.model.Avviso; 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.Comune;
import it.tref.liferay.portos.bo.model.ControlloPratica; import it.tref.liferay.portos.bo.model.ControlloPratica;
import it.tref.liferay.portos.bo.model.DettPratica; import it.tref.liferay.portos.bo.model.DettPratica;
@ -43,24 +42,19 @@ import com.liferay.portal.service.UserLocalServiceUtil;
public class MailUtil { public class MailUtil {
public static void invioMailNotifica(long intPraticaId, long dettPraticaId, long classPk, String className, public static void invioMailNotifica(long intPraticaId, long dettPraticaId, long classPk, String className,
String[] to, String[] cc, String[] ccn, String templateName, JSONObject templateVariables, String[] to, String[] cc, String[] ccn, String templateName, JSONObject templateVariables,
List<FileAttachment> allegati, ServiceContext serviceContext) throws PortalException, SystemException { List<FileAttachment> allegati, ServiceContext serviceContext) throws PortalException, SystemException {
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId); IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId);
DettPratica dettPratica = DettPraticaLocalServiceUtil.fetchDettPratica(dettPraticaId); DettPratica dettPratica = DettPraticaLocalServiceUtil.fetchDettPratica(dettPraticaId);
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()); Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId());
Comune comune = ComuneLocalServiceUtil.getComune(territorio.getComuneId()); Comune comune = ComuneLocalServiceUtil.getComune(territorio.getComuneId());
Provincia provincia = Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(),
ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(), territorio.getCodiceProvincia()); territorio.getCodiceProvincia());
User titolaredigitaleUser = UserLocalServiceUtil.getUser(intPratica.getUserId()); User titolaredigitaleUser = UserLocalServiceUtil.getUser(intPratica.getUserId());
List<Soggetto> titolari = List<Soggetto> titolari = SoggettoLocalServiceUtil.getValidByIntPratica_CodiceFiscale(
SoggettoLocalServiceUtil.getValidByIntPratica_CodiceFiscale(intPratica.getIntPraticaId(), intPratica.getIntPraticaId(), titolaredigitaleUser.getScreenName());
titolaredigitaleUser.getScreenName());
String titolareDigitale = StringPool.BLANK; String titolareDigitale = StringPool.BLANK;
String titolareDigitaleMail = StringPool.BLANK; String titolareDigitaleMail = StringPool.BLANK;
String titolareDigitaleRoles = StringPool.BLANK; String titolareDigitaleRoles = StringPool.BLANK;
@ -68,27 +62,24 @@ public class MailUtil {
titolareDigitale = titolari.get(0).getTitle(); titolareDigitale = titolari.get(0).getTitle();
titolareDigitaleMail = titolari.get(0).getEmail(); titolareDigitaleMail = titolari.get(0).getEmail();
for (Soggetto titolare : titolari) { for (Soggetto titolare : titolari) {
titolareDigitaleRoles += titolareDigitaleRoles += LanguageUtil.get(LocaleUtil.ITALIAN,
LanguageUtil.get(LocaleUtil.ITALIAN, "gc-soggetto-" + titolare.getTipologiaSoggetto()) + " "; "gc-soggetto-" + titolare.getTipologiaSoggetto())
+ " ";
} }
} }
String committenteTitle = StringPool.BLANK; String committenteTitle = StringPool.BLANK;
String descIntervento = StringPool.BLANK; String descIntervento = StringPool.BLANK;
String tempId = StringPool.BLANK; String tempId = StringPool.BLANK;
if (Validator.isNotNull(dettPratica)) { if (Validator.isNotNull(dettPratica)) {
tempId = dettPratica.getTitle(); tempId = dettPratica.getTitle();
descIntervento = dettPratica.getDescLongIntervento(); descIntervento = dettPratica.getDescLongIntervento();
Soggetto committentePrincipale = SoggettoLocalServiceUtil
Soggetto committentePrincipale = .getValidByIntPratica_CodiceFiscale_TipologiaSoggetto(intPratica.getIntPraticaId(),
SoggettoLocalServiceUtil.getValidByIntPratica_CodiceFiscale_TipologiaSoggetto(intPratica.getIntPraticaId(),
dettPratica.getCodiceFiscalePrincipaleCommittente(), TipoSoggettoUtil.COMMITTENTE); dettPratica.getCodiceFiscalePrincipaleCommittente(), TipoSoggettoUtil.COMMITTENTE);
if (Validator.isNotNull(committentePrincipale)) { if (Validator.isNotNull(committentePrincipale)) {
committenteTitle = committentePrincipale.getTitle(); committenteTitle = committentePrincipale.getTitle();
} }
} }
// JSONObject templateVariables = JSONFactoryUtil.createJSONObject();
templateVariables.put("tempId", tempId); templateVariables.put("tempId", tempId);
templateVariables.put("praticaNum", intPratica.getNumeroProgetto()); templateVariables.put("praticaNum", intPratica.getNumeroProgetto());
templateVariables.put("titolareDigitale", titolareDigitale); templateVariables.put("titolareDigitale", titolareDigitale);
@ -98,204 +89,169 @@ public class MailUtil {
templateVariables.put("provincia", provincia.getProvincia()); templateVariables.put("provincia", provincia.getProvincia());
templateVariables.put("comune", comune.getDenominazione()); templateVariables.put("comune", comune.getDenominazione());
templateVariables.put("committente", committenteTitle); templateVariables.put("committente", committenteTitle);
MailManagerUtil.sendMailByTemplatName(className, classPk, templateName, to, cc, ccn, templateVariables,
// Iterator<String> iterator = templateVariablesExtra.keys(); allegati, serviceContext);
// while (iterator.hasNext()) {
// String key = iterator.next();
// templateVariables.put(key, templateVariablesExtra.getString(key));
// }
MailManagerUtil.sendMailByTemplatName(className, classPk, templateName, to, cc, ccn, templateVariables, allegati,
serviceContext);
} }
/** // ADT
* ADT
*
* @throws SystemException
* @throws PortalException
*/
public static void invioNotificaAssegnazioneIstruttore(Avviso avviso) throws PortalException, SystemException { 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()); DettPratica dettPratica = DettPraticaLocalServiceUtil.getDettPratica(avviso.getClassPk());
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(dettPratica.getIntPraticaId()); IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(dettPratica.getIntPraticaId());
if (avviso.getControlloPraticaId() == 0) { 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); AvvisoLocalServiceUtil.updateAvvisoInviatoTecnico(avviso.getAvvisoId(), true);
return; return;
} }
ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil.getControlloPratica(avviso
ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil.getControlloPratica(avviso.getControlloPraticaId()); .getControlloPraticaId());
ServiceContext serviceContext = new ServiceContext(); ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(controlloPratica.getCompanyId()); serviceContext.setCompanyId(controlloPratica.getCompanyId());
serviceContext.setScopeGroupId(controlloPratica.getGroupId()); serviceContext.setScopeGroupId(controlloPratica.getGroupId());
serviceContext.setUserId(controlloPratica.getUserId()); serviceContext.setUserId(controlloPratica.getUserId());
User tecnicoIstruttore = recuperaTecnicoIstruttore(intPratica); User tecnicoIstruttore = recuperaTecnicoIstruttore(intPratica);
/////////////////////////////////////////////////////
if (tecnicoIstruttore == null) { 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); AvvisoLocalServiceUtil.updateAvvisoInviatoTecnico(avviso.getAvvisoId(), true);
return; return;
} }
///////////////////////////////////////////////
String[] to = { tecnicoIstruttore.getEmailAddress() }; String[] to = { tecnicoIstruttore.getEmailAddress() };
String[] cc = new String[0]; String[] cc = new String[0];
String[] ccn = new String[0]; String[] ccn = new String[0];
// recupero dati // recupero dati
String tipoPratica = ""; String tipoPratica = StringPool.BLANK;
if (AzioniPraticheUtil.isDeposito(intPratica.getIntPraticaId())) { if (AzioniPraticheUtil.isDeposito(intPratica.getIntPraticaId())) {
tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-01"); tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-01");
} else if (AzioniPraticheUtil.isAutorizzazione(intPratica.getIntPraticaId())) { } else if (AzioniPraticheUtil.isAutorizzazione(intPratica.getIntPraticaId())) {
tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-02"); tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-02");
} }
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()); Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId());
Comune comune = ComuneLocalServiceUtil.getComune(territorio.getComuneId()); 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(); JSONObject templateVariables = JSONFactoryUtil.createJSONObject();
templateVariables.put("receiver", tecnicoIstruttore.getFullName()); templateVariables.put("receiver", tecnicoIstruttore.getFullName());
templateVariables.put("tipoPratica", tipoPratica); templateVariables.put("tipoPratica", tipoPratica);
templateVariables.put("tipoOggetto", "Assegnazione Istruttoria"); 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("praticaNum", intPratica.getNumeroProgetto());
templateVariables.put("provincia", provincia.getProvincia()); templateVariables.put("provincia", provincia.getProvincia());
templateVariables.put("comune", comune.getDenominazione()); templateVariables.put("comune", comune.getDenominazione());
String className = IntPratica.class.getName(); String className = IntPratica.class.getName();
long classPk = intPratica.getIntPraticaId(); long classPk = intPratica.getIntPraticaId();
MailManagerUtil.sendMailByTemplatName(className, classPk, "NOTIFICA-BO", to, cc, ccn, templateVariables, null,
MailManagerUtil.sendMailByTemplatName(className, classPk, "NOTIFICA-BO", to, cc, ccn, templateVariables, null, serviceContext); serviceContext);
AvvisoLocalServiceUtil.updateAvvisoInviatoTecnico(avviso.getAvvisoId(), true); AvvisoLocalServiceUtil.updateAvvisoInviatoTecnico(avviso.getAvvisoId(), true);
} }
/** // Invio notifica istruttore dopo inserimento parere geologo
* Invio notifica istruttore dopo inserimento parere geologo
*
* @param parereGeologoId
* @param serviceContext
*/
public static void invioNotificaIstruttoreByGeologo(long parereGeologoId, ServiceContext serviceContext) { public static void invioNotificaIstruttoreByGeologo(long parereGeologoId, ServiceContext serviceContext) {
_log.info("start invioNotificaIstruttoreByGeologo parereGeologoId=" + parereGeologoId);
_log.info("start invioNotificaIstruttoreByGeologo parereGeologoId=" + parereGeologoId);
long intPraticaId = 0L; long intPraticaId = 0L;
try { try {
ParereGeologo parereGeologo = ParereGeologoLocalServiceUtil.getParereGeologo(parereGeologoId); ParereGeologo parereGeologo = ParereGeologoLocalServiceUtil.getParereGeologo(parereGeologoId);
intPraticaId = parereGeologo.getIntPraticaId(); intPraticaId = parereGeologo.getIntPraticaId();
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId); IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId);
User tecnicoIstruttore = recuperaTecnicoIstruttore(intPratica); User tecnicoIstruttore = recuperaTecnicoIstruttore(intPratica);
_log.info("email tecnico istruttore=" + tecnicoIstruttore.getEmailAddress()); _log.info("email tecnico istruttore=" + tecnicoIstruttore.getEmailAddress());
String[] to = { tecnicoIstruttore.getEmailAddress() }; String[] to = { tecnicoIstruttore.getEmailAddress() };
String[] cc = new String[0]; String[] cc = new String[0];
String[] ccn = new String[0]; String[] ccn = new String[0];
// recupero dati // recupero dati
String tipoPratica = ""; String tipoPratica = StringPool.BLANK;
if (AzioniPraticheUtil.isDeposito(intPratica.getIntPraticaId())) { if (AzioniPraticheUtil.isDeposito(intPratica.getIntPraticaId())) {
tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-01"); tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-01");
} else if (AzioniPraticheUtil.isAutorizzazione(intPratica.getIntPraticaId())) { } else if (AzioniPraticheUtil.isAutorizzazione(intPratica.getIntPraticaId())) {
tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-02"); tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-02");
} }
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()); Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId());
Comune comune = ComuneLocalServiceUtil.getComune(territorio.getComuneId()); 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(); JSONObject templateVariables = JSONFactoryUtil.createJSONObject();
templateVariables.put("receiver", tecnicoIstruttore.getFullName()); templateVariables.put("receiver", tecnicoIstruttore.getFullName());
templateVariables.put("tipoPratica", tipoPratica); templateVariables.put("tipoPratica", tipoPratica);
templateVariables.put("tipoOggetto", "Risposta a Richiesta Parere Geologo"); 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("praticaNum", intPratica.getNumeroProgetto());
templateVariables.put("provincia", provincia.getProvincia()); templateVariables.put("provincia", provincia.getProvincia());
templateVariables.put("comune", comune.getDenominazione()); templateVariables.put("comune", comune.getDenominazione());
String className = ParereGeologo.class.getName(); String className = ParereGeologo.class.getName();
long classPk = parereGeologoId; long classPk = parereGeologoId;
MailManagerUtil.sendMailByTemplatName(className, classPk, "NOTIFICA-BO", to, cc, ccn, templateVariables,
MailManagerUtil.sendMailByTemplatName(className, classPk, "NOTIFICA-BO", to, cc, ccn, templateVariables, null, serviceContext); null, serviceContext);
} catch (Exception e) { } 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) { public static void invioNotificaGeologo(ParereGeologo parereGeologo, ServiceContext serviceContext) {
_log.info("start invioNotificaGeologo parereGeologo=" + parereGeologo.getParereGeologoId()); _log.info("start invioNotificaGeologo parereGeologo=" + parereGeologo.getParereGeologoId());
try { try {
User geologo = UserLocalServiceUtil.getUser(parereGeologo.getGeologoUserId()); User geologo = UserLocalServiceUtil.getUser(parereGeologo.getGeologoUserId());
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(parereGeologo.getIntPraticaId()); IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(parereGeologo.getIntPraticaId());
//DettPratica dettPratica = DettPraticaLocalServiceUtil.fetchDettPratica(parereGeologo.getDettPraticaId());
_log.info("email geologo = " + geologo.getEmailAddress()); _log.info("email geologo = " + geologo.getEmailAddress());
String[] to = { geologo.getEmailAddress() }; String[] to = { geologo.getEmailAddress() };
String[] cc = new String[0]; String[] cc = new String[0];
String[] ccn = new String[0]; String[] ccn = new String[0];
// recupero dati // recupero dati
String tipoPratica = ""; String tipoPratica = StringPool.BLANK;
if (AzioniPraticheUtil.isDeposito(intPratica.getIntPraticaId())) { if (AzioniPraticheUtil.isDeposito(intPratica.getIntPraticaId())) {
tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-01"); tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-01");
} else if (AzioniPraticheUtil.isAutorizzazione(intPratica.getIntPraticaId())) { } else if (AzioniPraticheUtil.isAutorizzazione(intPratica.getIntPraticaId())) {
tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-02"); tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-02");
} }
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()); Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId());
Comune comune = ComuneLocalServiceUtil.getComune(territorio.getComuneId()); 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(); JSONObject templateVariables = JSONFactoryUtil.createJSONObject();
templateVariables.put("receiver", geologo.getFullName()); templateVariables.put("receiver", geologo.getFullName());
templateVariables.put("tipoPratica", tipoPratica); templateVariables.put("tipoPratica", tipoPratica);
templateVariables.put("tipoOggetto", "Richiesta Parere"); 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("praticaNum", intPratica.getNumeroProgetto());
templateVariables.put("provincia", provincia.getProvincia()); templateVariables.put("provincia", provincia.getProvincia());
templateVariables.put("comune", comune.getDenominazione()); templateVariables.put("comune", comune.getDenominazione());
String className = ParereGeologo.class.getName(); String className = ParereGeologo.class.getName();
long classPk = parereGeologo.getParereGeologoId(); long classPk = parereGeologo.getParereGeologoId();
MailManagerUtil.sendMailByTemplatName(className, classPk, "NOTIFICA-GEOLOGO", to, cc, ccn,
MailManagerUtil.sendMailByTemplatName(className, classPk, "NOTIFICA-GEOLOGO", to, cc, ccn, templateVariables, null, serviceContext); templateVariables, null, serviceContext);
} catch (Exception e) { } 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 { public static User recuperaTecnicoIstruttore(IntPratica intPratica) throws PortalException, SystemException {
long statusByUserId = intPratica.getStatusByUserId(); long statusByUserId = intPratica.getStatusByUserId();
User istruttoreUser = null; User istruttoreUser = null;
if (Validator.isNotNull(statusByUserId) && intPratica.getStatus() != WorkflowConstants.STATUS_DRAFT) { if (Validator.isNotNull(statusByUserId) && intPratica.getStatus() != WorkflowConstants.STATUS_DRAFT) {
istruttoreUser = UserLocalServiceUtil.getUser(statusByUserId); 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; return istruttoreUser;
} }
private static final Log _log = LogFactoryUtil.getLog(MailUtil.class); 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; import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil;
public class AllegatiUtil { public class AllegatiUtil {
private final static Log _log = LogFactoryUtil.getLog(AllegatiUtil.class); private final static Log _log = LogFactoryUtil.getLog(AllegatiUtil.class);
public static void sostituisciDL(ActionRequest actionRequest, ActionResponse actionResponse) public static void sostituisciDL(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
throws Exception {
List<String> esito = new ArrayList<>(); List<String> esito = new ArrayList<>();
String className = ParamUtil.getString(actionRequest, "className"); String className = ParamUtil.getString(actionRequest, "className");
actionResponse.setRenderParameter("className", className); actionResponse.setRenderParameter("className", className);
long classPK = ParamUtil.getLong(actionRequest, "classPK"); long classPK = ParamUtil.getLong(actionRequest, "classPK");
actionResponse.setRenderParameter("classPK", String.valueOf(classPK)); actionResponse.setRenderParameter("classPK", String.valueOf(classPK));
UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest); UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest);
String sourceFileName = uploadRequest.getFileName("file"); String sourceFileName = uploadRequest.getFileName("file");
File file = uploadRequest.getFile("file"); File file = uploadRequest.getFile("file");
byte[] bytes = FileUtil.getBytes(file); byte[] bytes = FileUtil.getBytes(file);
if (Validator.isNull(bytes)) { if (Validator.isNull(bytes)) {
esito.add("Nessun file allegato"); esito.add("Nessun file allegato");
} else { } else {
@ -85,8 +83,8 @@ public class AllegatiUtil {
actionResponse.setRenderParameter("esito", esito.toArray(new String[esito.size()])); actionResponse.setRenderParameter("esito", esito.toArray(new String[esito.size()]));
} }
private static List<String> sostituisciAllegatoSoggetto(long soggettoId, String sourceFileName, private static List<String> sostituisciAllegatoSoggetto(long soggettoId, String sourceFileName, byte[] bytes,
byte[] bytes, Date date) throws PortalException, SystemException, IOException { Date date) throws PortalException, SystemException, IOException {
List<String> esito = new ArrayList<>(); List<String> esito = new ArrayList<>();
Soggetto soggetto = null; Soggetto soggetto = null;
@ -101,10 +99,8 @@ public class AllegatiUtil {
esito.add("Il soggetto " + soggettoId + " non ha un'allegato da sostituire"); esito.add("Il soggetto " + soggettoId + " non ha un'allegato da sostituire");
return esito; return esito;
} }
long companyId = soggetto.getCompanyId(); long companyId = soggetto.getCompanyId();
long userId = soggetto.getUserId(); long userId = soggetto.getUserId();
DocPratica docPratica = null; DocPratica docPratica = null;
try { try {
docPratica = DocPraticaLocalServiceUtil.getDocPratica(docPraticaId); docPratica = DocPraticaLocalServiceUtil.getDocPratica(docPraticaId);
@ -112,10 +108,8 @@ public class AllegatiUtil {
} }
if (Validator.isNull(docPratica)) { if (Validator.isNull(docPratica)) {
esito.add("Ricreo docPratica " + docPraticaId); esito.add("Ricreo docPratica " + docPraticaId);
docPratica = DocPraticaLocalServiceUtil.createDocPratica(docPraticaId); docPratica = DocPraticaLocalServiceUtil.createDocPratica(docPraticaId);
User user = UserLocalServiceUtil.getUser(userId); User user = UserLocalServiceUtil.getUser(userId);
docPratica.setClassName(Soggetto.class.getName()); docPratica.setClassName(Soggetto.class.getName());
docPratica.setClassPk(soggettoId); docPratica.setClassPk(soggettoId);
docPratica.setCompanyId(companyId); docPratica.setCompanyId(companyId);
@ -135,28 +129,22 @@ public class AllegatiUtil {
return esito; return esito;
} }
private static List<String> sostituisciAllegatoDocPratica(long docPraticaId, String sourceFileName, private static List<String> sostituisciAllegatoDocPratica(long docPraticaId, String sourceFileName, byte[] bytes,
byte[] bytes, Date date) throws SystemException, PortalException, IOException { Date date) throws SystemException, PortalException, IOException {
List<String> esito = new ArrayList<>(); List<String> esito = new ArrayList<>();
DocPratica docPratica = DocPraticaLocalServiceUtil.getDocPratica(docPraticaId); DocPratica docPratica = DocPraticaLocalServiceUtil.getDocPratica(docPraticaId);
long companyId = docPratica.getCompanyId(); long companyId = docPratica.getCompanyId();
long userId = docPratica.getUserId(); long userId = docPratica.getUserId();
ServiceContext serviceContext = getServiceContext(companyId, docPratica.getGroupId(), userId); ServiceContext serviceContext = getServiceContext(companyId, docPratica.getGroupId(), userId);
long dettPraticaId = getDettPraticaId(docPratica.getIntPraticaId()); long dettPraticaId = getDettPraticaId(docPratica.getIntPraticaId());
Folder folder = getFolder(PraticaUtil.getFolderName(dettPraticaId), serviceContext); Folder folder = getFolder(PraticaUtil.getFolderName(dettPraticaId), serviceContext);
String title = getTitle(docPratica, sourceFileName, date); String title = getTitle(docPratica, sourceFileName, date);
FileEntry fileEntry = addOrUpdateFileEntry(docPratica.getDlFileEntryId(), folder, userId, FileEntry fileEntry = addOrUpdateFileEntry(docPratica.getDlFileEntryId(), folder, userId, sourceFileName,
sourceFileName, title, sourceFileName, bytes, serviceContext); title, sourceFileName, bytes, serviceContext);
docPratica.setDlFileEntryId(fileEntry.getFileEntryId()); docPratica.setDlFileEntryId(fileEntry.getFileEntryId());
String sha256 = DigestUtils.sha256Hex(bytes); String sha256 = DigestUtils.sha256Hex(bytes);
docPratica.setSha256(sha256); docPratica.setSha256(sha256);
// Sostituzione delle firme digitali con quelle presenti nel file // Sostituzione delle firme digitali con quelle presenti nel file
FirmeBean firmeBean = FirmeUtil.deserialize(docPratica.getJsonFirmatari()); FirmeBean firmeBean = FirmeUtil.deserialize(docPratica.getJsonFirmatari());
Set<String> firmeFile = new HashSet<>(); Set<String> firmeFile = new HashSet<>();
@ -168,43 +156,35 @@ public class AllegatiUtil {
} }
firmeBean.setFirmeDigitali(firmeDigitali); firmeBean.setFirmeDigitali(firmeDigitali);
docPratica.setJsonFirmatari(FirmeUtil.serialize(firmeBean)); docPratica.setJsonFirmatari(FirmeUtil.serialize(firmeBean));
DocPraticaLocalServiceUtil.updateDocPratica(docPratica); DocPraticaLocalServiceUtil.updateDocPratica(docPratica);
esito.add("DocPratica " + docPraticaId + ": aggiornato fileEntry " + fileEntry.getFileEntryId() esito.add("DocPratica " + docPraticaId + ": aggiornato fileEntry " + fileEntry.getFileEntryId() + ", sha256="
+ ", sha256=" + sha256); + sha256);
return esito; return esito;
} }
private static List<String> sostituisciAllegatoPagamento(long pagamentoId, String sourceFileName, private static List<String> sostituisciAllegatoPagamento(long pagamentoId, String sourceFileName, byte[] bytes)
byte[] bytes) throws SystemException, PortalException, IOException { throws SystemException, PortalException, IOException {
List<String> esito = new ArrayList<>(); List<String> esito = new ArrayList<>();
Pagamento pagamento = PagamentoLocalServiceUtil.getPagamento(pagamentoId); Pagamento pagamento = PagamentoLocalServiceUtil.getPagamento(pagamentoId);
Date now = new Date(); Date now = new Date();
long userId = pagamento.getUserId(); 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()); long dettPraticaId = getDettPraticaId(pagamento.getIntPraticaId());
Folder folder = getFolder(PraticaUtil.getFolderName(dettPraticaId), serviceContext); Folder folder = getFolder(PraticaUtil.getFolderName(dettPraticaId), serviceContext);
String title = now.getTime() + "_pagamento_manuale_" + pagamento.getPagamentoId() + StringPool.UNDERLINE
String title = now.getTime() + "_pagamento_manuale_" + pagamento.getPagamentoId() + sourceFileName;
+ StringPool.UNDERLINE + sourceFileName; FileEntry fileEntry = addOrUpdateFileEntry(pagamento.getFileEntryId(), folder, userId, sourceFileName, title,
StringPool.BLANK, bytes, serviceContext);
FileEntry fileEntry = addOrUpdateFileEntry(pagamento.getFileEntryId(), folder, userId,
sourceFileName, title, StringPool.BLANK, bytes, serviceContext);
pagamento.setFileEntryId(fileEntry.getFileEntryId()); pagamento.setFileEntryId(fileEntry.getFileEntryId());
PagamentoLocalServiceUtil.updatePagamento(pagamento); PagamentoLocalServiceUtil.updatePagamento(pagamento);
esito.add("Pagamento " + pagamentoId + ": aggiunto file " + fileEntry.getFileEntryId() esito.add("Pagamento " + pagamentoId + ": aggiunto file " + fileEntry.getFileEntryId() + StringPool.SPACE
+ StringPool.SPACE + title); + title);
return esito; return esito;
} }
private static long getDettPraticaId(long intPraticaId) throws SystemException { private static long getDettPraticaId(long intPraticaId) throws SystemException {
DettPratica dettPratica = DettPraticaLocalServiceUtil.getLastEditableByIntPratica(intPraticaId); DettPratica dettPratica = DettPraticaLocalServiceUtil.getLastEditableByIntPratica(intPraticaId);
if (Validator.isNull(dettPratica)) { if (Validator.isNull(dettPratica)) {
List<DettPratica> list = DettPraticaLocalServiceUtil.findByIntPraticaId(intPraticaId); List<DettPratica> list = DettPraticaLocalServiceUtil.findByIntPraticaId(intPraticaId);
@ -214,6 +194,7 @@ public class AllegatiUtil {
} }
private static ServiceContext getServiceContext(long companyId, long groupId, long userId) { private static ServiceContext getServiceContext(long companyId, long groupId, long userId) {
ServiceContext serviceContext = new ServiceContext(); ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(companyId); serviceContext.setCompanyId(companyId);
serviceContext.setScopeGroupId(groupId); serviceContext.setScopeGroupId(groupId);
@ -226,24 +207,23 @@ public class AllegatiUtil {
SystemException { SystemException {
Folder folder = null; Folder folder = null;
long parentFolderId = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong( long parentFolderId = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(serviceContext.getCompanyId(),
serviceContext.getCompanyId(), ConfigurazioneConstants.ATTACHMENT_FOLDER_ID); ConfigurazioneConstants.ATTACHMENT_FOLDER_ID);
Folder parentFolder = DLAppLocalServiceUtil.getFolder(parentFolderId); Folder parentFolder = DLAppLocalServiceUtil.getFolder(parentFolderId);
long repositoryId = parentFolder.getRepositoryId(); long repositoryId = parentFolder.getRepositoryId();
try { try {
folder = DLAppLocalServiceUtil.getFolder(repositoryId, parentFolderId, folderName); folder = DLAppLocalServiceUtil.getFolder(repositoryId, parentFolderId, folderName);
} catch (NoSuchFolderException e) { } catch (NoSuchFolderException e) {
folder = DLAppLocalServiceUtil.addFolder(serviceContext.getUserId(), repositoryId, folder = DLAppLocalServiceUtil.addFolder(serviceContext.getUserId(), repositoryId, parentFolderId,
parentFolderId, folderName, StringPool.BLANK, serviceContext); folderName, StringPool.BLANK, serviceContext);
} }
return folder; return folder;
} }
private static String getTitle(DocPratica docPratica, String sourceFileName, Date date) { private static String getTitle(DocPratica docPratica, String sourceFileName, Date date) {
String className = DocPratica.class.getName(); String className = DocPratica.class.getName();
String tipologia = docPratica.getTipologia(); String tipologia = docPratica.getTipologia();
if (IntPratica.class.getName().equals(className)) { if (IntPratica.class.getName().equals(className)) {
if (tipologia.equalsIgnoreCase(DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_ANNULLAMENTO_FASCICOLO)) { if (tipologia.equalsIgnoreCase(DocumentiPraticaUtil.TIPOLOGIA_ALLEGATO_ANNULLAMENTO_FASCICOLO)) {
sourceFileName = date.getTime() + "_annullamento_" + docPratica.getIntPraticaId() sourceFileName = date.getTime() + "_annullamento_" + docPratica.getIntPraticaId()
@ -255,20 +235,19 @@ public class AllegatiUtil {
return sourceFileName; return sourceFileName;
} }
private static FileEntry addOrUpdateFileEntry(long fileEntryId, Folder folder, long userId, private static FileEntry addOrUpdateFileEntry(long fileEntryId, Folder folder, long userId, String sourceFileName,
String sourceFileName, String title, String description, byte[] bytes, String title, String description, byte[] bytes, ServiceContext serviceContext) throws SystemException,
ServiceContext serviceContext) throws SystemException, PortalException { PortalException {
String mimeType = MimeTypesUtil.getContentType(sourceFileName); String mimeType = MimeTypesUtil.getContentType(sourceFileName);
FileEntry fileEntry = null; FileEntry fileEntry = null;
try { try {
fileEntry = DLAppLocalServiceUtil.getFileEntry(fileEntryId); fileEntry = DLAppLocalServiceUtil.getFileEntry(fileEntryId);
fileEntry = DLAppLocalServiceUtil.updateFileEntry(userId, fileEntry.getFileEntryId(), fileEntry = DLAppLocalServiceUtil.updateFileEntry(userId, fileEntry.getFileEntryId(), sourceFileName,
sourceFileName, mimeType, title, description, StringPool.BLANK, false, bytes, mimeType, title, description, StringPool.BLANK, false, bytes, serviceContext);
serviceContext);
} catch (PortalException e) { } catch (PortalException e) {
fileEntry = DLAppLocalServiceUtil.addFileEntry(userId, folder.getRepositoryId(), fileEntry = DLAppLocalServiceUtil.addFileEntry(userId, folder.getRepositoryId(), folder.getFolderId(),
folder.getFolderId(), sourceFileName, mimeType, title, description, StringPool.BLANK, sourceFileName, mimeType, title, description, StringPool.BLANK, bytes, serviceContext);
bytes, serviceContext);
} }
return fileEntry; 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"; private static final String FILE_ENTRY_TEMPLATE_SORTEGGIO = "Sorteggio";
/** /**
*
* Implementazione della procedura di sorteggio secondo i requisiti della Regione Siciliana. * Implementazione della procedura di sorteggio secondo i requisiti della Regione Siciliana.
* *
* @author Manifattura Web Group per 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 { public static List<String> sorteggio(long companyId, Date dtSorteggio) throws PortalException, SystemException {
@ -84,22 +79,18 @@ public class SorteggioPraticaUtil {
if (lock.tryLock()) { if (lock.tryLock()) {
SimpleDateFormat sdf = new SimpleDateFormat(DATE_TIME_FORMAT); SimpleDateFormat sdf = new SimpleDateFormat(DATE_TIME_FORMAT);
esito.add("Sorteggio iniziato in data " + sdf.format(dtSorteggio) + ".<br><br>"); esito.add("Sorteggio iniziato in data " + sdf.format(dtSorteggio) + ".<br><br>");
Map<String, List<IntPratica>> sorteggiabili = IntPraticaLocalServiceUtil.findSorteggiabiliNew(companyId, Map<String, List<IntPratica>> sorteggiabili = IntPraticaLocalServiceUtil.findSorteggiabiliNew(companyId,
dtSorteggio); dtSorteggio);
int numeroSorteggiabili = 0; int numeroSorteggiabili = 0;
for (Map.Entry<String, List<IntPratica>> s : sorteggiabili.entrySet()) { for (Map.Entry<String, List<IntPratica>> s : sorteggiabili.entrySet()) {
numeroSorteggiabili += s.getValue().size(); numeroSorteggiabili += s.getValue().size();
} }
esito.add("<h1>" + numeroSorteggiabili + " pratiche sottoposte a sorteggio.</h1>"); esito.add("<h1>" + numeroSorteggiabili + " pratiche sottoposte a sorteggio.</h1>");
SecureRandom rnd = new SecureRandom(); SecureRandom rnd = new SecureRandom();
List<IntPratica> sorteggiate = new ArrayList<>(); List<IntPratica> sorteggiate = new ArrayList<>();
for (Map.Entry<String, List<IntPratica>> s : sorteggiabili.entrySet()) { for (Map.Entry<String, List<IntPratica>> s : sorteggiabili.entrySet()) {
String codiceProvincia = s.getKey(); String codiceProvincia = s.getKey();
List<IntPratica> elenco = s.getValue(); List<IntPratica> elenco = s.getValue();
Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(companyId, codiceProvincia); Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(companyId, codiceProvincia);
long numeroSorteggiate = (long) Math.ceil(0.1 * elenco.size()); long numeroSorteggiate = (long) Math.ceil(0.1 * elenco.size());
String testoSorteggio; String testoSorteggio;
@ -109,11 +100,9 @@ public class SorteggioPraticaUtil {
testoSorteggio = "sarà estratta 1 pratica"; testoSorteggio = "sarà estratta 1 pratica";
} }
esito.add("<h2><small>(" + sdf.format(new Date()) + ")</small> Provincia di " 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>"); + ".</h2><ol>");
Map<Integer, IntPratica> ordinate = new HashMap<>(); Map<Integer, IntPratica> ordinate = new HashMap<>();
int chiave; int chiave;
for (IntPratica pratica : elenco) { for (IntPratica pratica : elenco) {
do { do {
@ -122,18 +111,15 @@ public class SorteggioPraticaUtil {
ordinate.put(chiave, pratica); ordinate.put(chiave, pratica);
} }
TreeMap<Integer, IntPratica> mescolate = new TreeMap<Integer, IntPratica>(ordinate); TreeMap<Integer, IntPratica> mescolate = new TreeMap<Integer, IntPratica>(ordinate);
long contatore = 0; long contatore = 0;
for (Map.Entry<Integer, IntPratica> m : mescolate.entrySet()) { for (Map.Entry<Integer, IntPratica> m : mescolate.entrySet()) {
IntPratica pratica = m.getValue(); IntPratica pratica = m.getValue();
long intPraticaId = pratica.getIntPraticaId(); long intPraticaId = pratica.getIntPraticaId();
DettPratica dettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(intPraticaId); DettPratica dettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(intPraticaId);
ServiceContext serviceContext = new ServiceContext(); ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(dettPratica.getCompanyId()); serviceContext.setCompanyId(dettPratica.getCompanyId());
serviceContext.setScopeGroupId(dettPratica.getGroupId()); serviceContext.setScopeGroupId(dettPratica.getGroupId());
serviceContext.setUserId(dettPratica.getUserId()); serviceContext.setUserId(dettPratica.getUserId());
if (contatore++ < numeroSorteggiate) { if (contatore++ < numeroSorteggiate) {
sorteggiate.add(pratica); sorteggiate.add(pratica);
esito.add("<li>Sorteggiata: " + pratica.getNumeroProgetto() + " (id " + intPraticaId + ") del " esito.add("<li>Sorteggiata: " + pratica.getNumeroProgetto() + " (id " + intPraticaId + ") del "
@ -141,7 +127,6 @@ public class SorteggioPraticaUtil {
} else { } else {
pratica.setDtSorteggio(dtSorteggio); pratica.setDtSorteggio(dtSorteggio);
IntPraticaLocalServiceUtil.updateIntPratica(pratica); IntPraticaLocalServiceUtil.updateIntPratica(pratica);
esito.add("<li>Non sorteggiata: " + pratica.getNumeroProgetto() + " (id " + intPraticaId esito.add("<li>Non sorteggiata: " + pratica.getNumeroProgetto() + " (id " + intPraticaId
+ ") del " + sdf.format(pratica.getDtPratica()) + " (" + m.getKey() + ")</li>"); + ") del " + sdf.format(pratica.getDtPratica()) + " (" + m.getKey() + ")</li>");
} }
@ -152,9 +137,7 @@ public class SorteggioPraticaUtil {
saveSorteggio(companyId, sorteggiate, dtSorteggio); saveSorteggio(companyId, sorteggiate, dtSorteggio);
} }
esito.add("Sorteggio terminato in data " + sdf.format(new Date()) + ".<br><br>"); esito.add("Sorteggio terminato in data " + sdf.format(new Date()) + ".<br><br>");
creaReportSorteggio(companyId, dtSorteggio, esito); creaReportSorteggio(companyId, dtSorteggio, esito);
// Salvataggio data ultimo sorteggio // Salvataggio data ultimo sorteggio
ServiceContext serviceContext = new ServiceContext(); ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(companyId); serviceContext.setCompanyId(companyId);
@ -162,10 +145,8 @@ public class SorteggioPraticaUtil {
serviceContext.setUserId(UserLocalServiceUtil.getDefaultUserId(companyId)); serviceContext.setUserId(UserLocalServiceUtil.getDefaultUserId(companyId));
ConfigurazioneLocalServiceUtil.storeConfig(ConfigurazioneConstants.DATE_ULTIMO_SORTEGGIO, ConfigurazioneLocalServiceUtil.storeConfig(ConfigurazioneConstants.DATE_ULTIMO_SORTEGGIO,
sdf.format(dtSorteggio), serviceContext); sdf.format(dtSorteggio), serviceContext);
lock.unlock(); lock.unlock();
} }
return esito; return esito;
} }
@ -174,47 +155,39 @@ public class SorteggioPraticaUtil {
Role role = RoleLocalServiceUtil.getRole(companyId, RoleConstants.ADMINISTRATOR); Role role = RoleLocalServiceUtil.getRole(companyId, RoleConstants.ADMINISTRATOR);
long userId = UserLocalServiceUtil.getRoleUsers(role.getRoleId(), 0, 1).get(0).getUserId(); long userId = UserLocalServiceUtil.getRoleUsers(role.getRoleId(), 0, 1).get(0).getUserId();
Company company = CompanyLocalServiceUtil.getCompany(companyId); Company company = CompanyLocalServiceUtil.getCompany(companyId);
Folder folderTemplate = DLAppLocalServiceUtil.getFolder(company.getGroupId(), Folder folderTemplate = DLAppLocalServiceUtil.getFolder(company.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, "Template"); DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, "Template");
FileEntry fileEntryTemplate = DLAppLocalServiceUtil.getFileEntry(folderTemplate.getGroupId(), FileEntry fileEntryTemplate = DLAppLocalServiceUtil.getFileEntry(folderTemplate.getGroupId(),
folderTemplate.getFolderId(), FILE_ENTRY_TEMPLATE_SORTEGGIO); folderTemplate.getFolderId(), FILE_ENTRY_TEMPLATE_SORTEGGIO);
Folder folderReport = DLAppLocalServiceUtil.getFolder(company.getGroupId(), Folder folderReport = DLAppLocalServiceUtil.getFolder(company.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, FOLDER_SORTEGGIO); DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, FOLDER_SORTEGGIO);
StringBuilder sb = new StringBuilder(contenuto.size()); StringBuilder sb = new StringBuilder(contenuto.size());
for (String riga : contenuto) { for (String riga : contenuto) {
sb.append(riga); sb.append(riga);
} }
Map<String, Object> parameters = new HashMap<String, Object>(); Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("html", sb.toString()); parameters.put("html", sb.toString());
ReportDto reportDto = new ReportDto(); ReportDto reportDto = new ReportDto();
reportDto.setFileEntryIds(new long[] { fileEntryTemplate.getFileEntryId() }); reportDto.setFileEntryIds(new long[] { fileEntryTemplate.getFileEntryId() });
reportDto.setFolderId(folderReport.getFolderId()); reportDto.setFolderId(folderReport.getFolderId());
reportDto.setFileName(reportFileName(companyId, dtSorteggio)); reportDto.setFileName(reportFileName(companyId, dtSorteggio));
reportDto.setHeader(StringPool.BLANK); reportDto.setHeader(StringPool.BLANK);
reportDto.setHeaderHeight(1); reportDto.setHeaderHeight(1);
reportDto.setFooter(StringPool.BLANK); reportDto.setFooter(StringPool.BLANK);
reportDto.setFooterHeight(40); reportDto.setFooterHeight(40);
reportDto.setParameters(parameters); reportDto.setParameters(parameters);
reportDto.setShowNumberOfPage(true); reportDto.setShowNumberOfPage(true);
reportDto.setType(ReportConstants.ReportType.VELOCITY_TO_PDF.toString()); reportDto.setType(ReportConstants.ReportType.VELOCITY_TO_PDF.toString());
String resourcePath = SorteggioPraticaUtil.class.getName().replaceAll("\\w+\\.", "../") String resourcePath = SorteggioPraticaUtil.class.getName().replaceAll("\\w+\\.", "../")
.replace(SorteggioPraticaUtil.class.getSimpleName(), "resource/asseverazioni"); .replace(SorteggioPraticaUtil.class.getSimpleName(), "resource/asseverazioni");
reportDto.setPortalURL(SorteggioPraticaUtil.class.getResource(resourcePath).getPath()); reportDto.setPortalURL(SorteggioPraticaUtil.class.getResource(resourcePath).getPath());
ReportUtil.generateReport(companyId, userId, reportDto, null); ReportUtil.generateReport(companyId, userId, reportDto, null);
return null; return null;
} }
private static String reportFileName(long companyId, Date dtSorteggio) { private static String reportFileName(long companyId, Date dtSorteggio) {
Calendar calSorteggio = DateUtils.toCalendar(dtSorteggio); Calendar calSorteggio = DateUtils.toCalendar(dtSorteggio);
String anno = String.valueOf(calSorteggio.get(Calendar.YEAR)); String anno = String.valueOf(calSorteggio.get(Calendar.YEAR));
int settimana = calSorteggio.get(Calendar.WEEK_OF_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) { 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 * @author Manifattura Web Group per Regione Siciliana
*
* @param companyId * @param companyId
* @param pratiche * @param pratiche
* Lista di pratiche sorteggiate * Lista di pratiche sorteggiate
* @param dtSorteggio * @param dtSorteggio
* Data del sorteggio * Data del sorteggio
* @throws PortalException
* @throws SystemException
*/ */
private static void saveSorteggio(long companyId, List<IntPratica> pratiche, Date dtSorteggio) private static void saveSorteggio(long companyId, List<IntPratica> pratiche, Date dtSorteggio)
throws PortalException, SystemException { throws PortalException, SystemException {
long progressivoEstrazione = 1; long progressivoEstrazione = 1;
for (IntPratica pratica : pratiche) { for (IntPratica pratica : pratiche) {
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(pratica.getTerritorioId()); Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(pratica.getTerritorioId());
Comune comune = ComuneLocalServiceUtil.getComune(territorio.getComuneId()); Comune comune = ComuneLocalServiceUtil.getComune(territorio.getComuneId());
Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(), Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(),
comune.getCodiceProvincia()); comune.getCodiceProvincia());
DettPratica dettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(pratica DettPratica dettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(pratica
.getIntPraticaId()); .getIntPraticaId());
String committente = StringPool.BLANK; String committente = StringPool.BLANK;
List<Soggetto> soggetti = SoggettoLocalServiceUtil.findByIntPratica_TipologiaSoggetto_Aggiuntivo_Rimosso( List<Soggetto> soggetti = SoggettoLocalServiceUtil.findByIntPratica_TipologiaSoggetto_Aggiuntivo_Rimosso(
pratica.getIntPraticaId(), TipoSoggettoUtil.COMMITTENTE, false, false); pratica.getIntPraticaId(), TipoSoggettoUtil.COMMITTENTE, false, false);
if (soggetti.size() > 0) { if (soggetti.size() > 0) {
Soggetto soggetto = soggetti.get(0); Soggetto soggetto = soggetti.get(0);
if (Validator.isNotNull(soggetto.getNome()) && Validator.isNotNull(soggetto.getCognome())) 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())) else if (Validator.isNotNull(soggetto.getDenominazione()))
committente = soggetto.getDenominazione(); committente = soggetto.getDenominazione();
else else
committente = soggetto.getLegaleRap(); committente = soggetto.getLegaleRap();
} }
// anno, mese, settimana della data sorteggio // anno, mese, settimana della data sorteggio
Calendar calSorteggio = Calendar.getInstance(); Calendar calSorteggio = Calendar.getInstance();
calSorteggio.setTime(dtSorteggio); calSorteggio.setTime(dtSorteggio);
String anno = String.valueOf(calSorteggio.get(Calendar.YEAR)); String anno = String.valueOf(calSorteggio.get(Calendar.YEAR));
String mese = String.format("%02d", calSorteggio.get(Calendar.MONTH) + 1); String mese = String.format("%02d", calSorteggio.get(Calendar.MONTH) + 1);
int sett = calSorteggio.get(Calendar.WEEK_OF_YEAR); int sett = calSorteggio.get(Calendar.WEEK_OF_YEAR);
ServiceContext sc = new ServiceContext(); ServiceContext sc = new ServiceContext();
sc.setCompanyId(dettPratica.getCompanyId()); sc.setCompanyId(dettPratica.getCompanyId());
sc.setScopeGroupId(dettPratica.getGroupId()); sc.setScopeGroupId(dettPratica.getGroupId());
sc.setUserId(dettPratica.getUserId()); sc.setUserId(dettPratica.getUserId());
SorteggioLocalServiceUtil.addSorteggio(pratica.getIntPraticaId(), dettPratica.getDettPraticaId(), anno, SorteggioLocalServiceUtil.addSorteggio(pratica.getIntPraticaId(), dettPratica.getDettPraticaId(), anno,
mese, sett, dtSorteggio, StringPool.BLANK, APERTO, StringPool.BLANK, progressivoEstrazione++, mese, sett, dtSorteggio, StringPool.BLANK, APERTO, StringPool.BLANK, progressivoEstrazione++,
pratica.getNumeroProgetto(), committente, comune.getDenominazione(), provincia.getProvincia(), pratica.getNumeroProgetto(), committente, comune.getDenominazione(), provincia.getProvincia(),
false, pratica.getIntPraticaId(), false, sc); false, pratica.getIntPraticaId(), false, sc);
ControlloPratica controllo = ControlloPraticaLocalServiceUtil.addControlloPratica(pratica.getGroupId(), ControlloPratica controllo = ControlloPraticaLocalServiceUtil.addControlloPratica(pratica.getGroupId(),
pratica.getUserId(), pratica.getIntPraticaId(), dettPratica.getDettPraticaId(), true, sc); pratica.getUserId(), pratica.getIntPraticaId(), dettPratica.getDettPraticaId(), true, sc);
long idTemplate = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(sc.getCompanyId(), long idTemplate = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(sc.getCompanyId(),
"conf.geniocivile.avviso.template.id.deposito.S"); "conf.geniocivile.avviso.template.id.deposito.S");
AvvisoLocalServiceUtil.addAvviso(pratica.getIntPraticaId(), "Avviso di sorteggio", dtSorteggio, AvvisoLocalServiceUtil.addAvviso(pratica.getIntPraticaId(), "Avviso di sorteggio", dtSorteggio,
AvvisoUtil.TIPO_AVVISO_DIRETTO, StatoPraticaConstants.SOTTOPOSTA_A_PARERE, idTemplate, AvvisoUtil.TIPO_AVVISO_DIRETTO, StatoPraticaConstants.SOTTOPOSTA_A_PARERE, idTemplate,
dettPratica.getDettPraticaId(), DettPratica.class.getName(), controllo.getControlloPraticaId(), sc); dettPratica.getDettPraticaId(), DettPratica.class.getName(), controllo.getControlloPraticaId(), sc);
IntPraticaLocalServiceUtil.updateIntPraticaSorteggio(pratica.getIntPraticaId(), dtSorteggio, IntPraticaLocalServiceUtil.updateIntPraticaSorteggio(pratica.getIntPraticaId(), dtSorteggio,
StatoPraticaConstants.SOTTOPOSTA_A_PARERE); StatoPraticaConstants.SOTTOPOSTA_A_PARERE);
IntPraticaLocalServiceUtil.reIndexFascicolo(pratica, companyId); IntPraticaLocalServiceUtil.reIndexFascicolo(pratica, companyId);
@ -301,13 +261,10 @@ public class SorteggioPraticaUtil {
throws PortalException, SystemException { throws PortalException, SystemException {
Company company = CompanyLocalServiceUtil.getCompany(companyId); Company company = CompanyLocalServiceUtil.getCompany(companyId);
Folder folder = DLAppLocalServiceUtil.getFolder(company.getGroupId(), Folder folder = DLAppLocalServiceUtil.getFolder(company.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, FOLDER_SORTEGGIO); DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, FOLDER_SORTEGGIO);
String fileName = reportFileName(companyId, dtSorteggio); String fileName = reportFileName(companyId, dtSorteggio);
FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(groupId, folder.getFolderId(), fileName); FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(groupId, folder.getFolderId(), fileName);
return fileEntry; return fileEntry;
} }
@ -315,11 +272,9 @@ public class SorteggioPraticaUtil {
throws PortalException, SystemException { throws PortalException, SystemException {
Company company = CompanyLocalServiceUtil.getCompany(companyId); Company company = CompanyLocalServiceUtil.getCompany(companyId);
Folder folder = DLAppLocalServiceUtil.getFolder(company.getGroupId(), Folder folder = DLAppLocalServiceUtil.getFolder(company.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, FOLDER_SORTEGGIO); DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, FOLDER_SORTEGGIO);
String fileName = reportFileName(companyId, anno, settimana); String fileName = reportFileName(companyId, anno, settimana);
return DLAppLocalServiceUtil.getFileEntry(groupId, folder.getFolderId(), fileName); 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. * 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 * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
* GNU Lesser General Public License as published by the Free Software Foundation; either version * Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option)
* 2.1 of the License, or (at your option) any later version. * any later version.
* *
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* Lesser General Public License for more details. * details.
*/ */
package it.tref.liferay.portos.bo.model.impl; 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; import com.liferay.portal.kernel.util.Validator;
/** /**
* The extended model implementation for the Collaudo service. Represents a row * The extended model implementation for the Collaudo service. Represents a row in the &quot;portos_bo_Collaudo&quot;
* in the &quot;portos_bo_Collaudo&quot; database table, with each column mapped * database table, with each column mapped to a property of this class.
* to a property of this class.
* *
* <p> * <p>
* Helper methods and all application logic should be put in this class. * Helper methods and all application logic should be put in this class. Whenever methods are added, rerun
* Whenever methods are added, rerun ServiceBuilder to copy their definitions * ServiceBuilder to copy their definitions into the {@link it.tref.liferay.portos.bo.model.Collaudo} interface.
* into the {@link it.tref.liferay.portos.bo.model.Collaudo} interface.
* </p> * </p>
* *
* @author Davide Barbagallo, 3F Consulting * @author Davide Barbagallo, 3F Consulting
*/ */
public class CollaudoImpl extends CollaudoBaseImpl { public class CollaudoImpl extends CollaudoBaseImpl {
/* /*
* NOTE FOR DEVELOPERS: * 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.
* 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 long serialVersionUID = -6015747485641141721L;
private static final Log _log = LogFactoryUtil.getLog(CollaudoImpl.class); private static final Log _log = LogFactoryUtil.getLog(CollaudoImpl.class);
public CollaudoImpl() { public CollaudoImpl() {
} }
@Override
public String getTitle(Locale locale) { public String getTitle(Locale locale) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
try { try {
IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(getIntPraticaId()); IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(getIntPraticaId());
// sb.append("Progetto ");
if (AzioniPraticheUtil.isDeposito(intPratica.getIntPraticaId())) { if (AzioniPraticheUtil.isDeposito(intPratica.getIntPraticaId())) {
sb.append("Deposito "); sb.append("Deposito ");
} else if (AzioniPraticheUtil.isAutorizzazione(intPratica.getIntPraticaId())) { } else if (AzioniPraticheUtil.isAutorizzazione(intPratica.getIntPraticaId())) {
sb.append("Autorizzazione "); sb.append("Autorizzazione ");
} }
sb.append("n. "); sb.append("n. ");
if (Validator.isNotNull(getProtocollo())) { 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
// TODO da decidere che data, per adesso si mette quella di sb.append(intPratica.getNumeroProgetto()).append(" del ")
// creazione il numero protocollo .append(FastDateFormatFactoryUtil.getDate(locale).format(intPratica.getDtPratica()))
// sbagliato dovrebbe essere il primo .append(StringPool.SPACE).append(StringPool.DASH).append(StringPool.SPACE).append(" id ")
sb.append(" del "); .append(intPratica.getIntPraticaId());
sb.append(FastDateFormatFactoryUtil.getDate(locale).format(intPratica.getDtPratica()));
sb.append(StringPool.SPACE + StringPool.DASH + StringPool.SPACE);
sb.append(" id ");
sb.append(intPratica.getIntPraticaId());
} else { } else {
if (Validator.isNotNull(intPratica.getNumeroProgetto())) { if (Validator.isNotNull(intPratica.getNumeroProgetto())) {
sb.append(intPratica.getNumeroProgetto()); sb.append(intPratica.getNumeroProgetto()).append(StringPool.SPACE).append(StringPool.DASH)
sb.append(StringPool.SPACE + StringPool.DASH + StringPool.SPACE); .append(StringPool.SPACE);
} }
sb.append(getCollaudoId()); sb.append(getCollaudoId()).append(" (Temporaneo) ").append(StringPool.SPACE).append(StringPool.DASH)
sb.append(" (Temporaneo) "); .append(StringPool.SPACE).append(" id ").append(intPratica.getIntPraticaId());
sb.append(StringPool.SPACE + StringPool.DASH + StringPool.SPACE);
sb.append(" id ");
sb.append(intPratica.getIntPraticaId());
} }
} catch (PortalException | SystemException e) {
} catch (PortalException e) {
_log.error(e, e);
} catch (SystemException e) {
_log.error(e, e); _log.error(e, e);
} }
return sb.toString(); return sb.toString();
} }
@Override
public String getTitle() { public String getTitle() {
return getTitle(LocaleUtil.getSiteDefault()); return getTitle(LocaleUtil.getSiteDefault());
} }
@Override
public String getFullDescription() { public String getFullDescription() {
return getTitle(); 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 { public void onAfterUpdate(ControlloPratica model) throws ModelListenerException {
try { try {
Indexer intIndexer = IndexerRegistryUtil.getIndexer(IntPratica.class); Indexer intIndexer = IndexerRegistryUtil.getIndexer(IntPratica.class);
Indexer controlloIndexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class); Indexer controlloIndexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class);
intIndexer.delete(model.getCompanyId(), model.getUuid()); intIndexer.delete(model.getCompanyId(), model.getUuid());
intIndexer.reindex(IntPratica.class.getName(), model.getIntPraticaId()); intIndexer.reindex(IntPratica.class.getName(), model.getIntPraticaId());
controlloIndexer.delete(model.getCompanyId(), model.getUuid()); controlloIndexer.delete(model.getCompanyId(), model.getUuid());
controlloIndexer.reindex(ControlloPratica.class.getName(), model.getControlloPraticaId()); controlloIndexer.reindex(ControlloPratica.class.getName(), model.getControlloPraticaId());
} catch (SearchException e) { } catch (SearchException e) {
_log.error(e, e); _log.error(e, e);
} }
super.onAfterUpdate(model); 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 { public void onAfterUpdate(DettPratica model) throws ModelListenerException {
try { try {
Indexer indexer = IndexerRegistryUtil.getIndexer(IntPratica.class); Indexer indexer = IndexerRegistryUtil.getIndexer(IntPratica.class);
indexer.reindex(IntPratica.class.getName(), model.getIntPraticaId()); indexer.reindex(IntPratica.class.getName(), model.getIntPraticaId());
if (_log.isDebugEnabled()) { if (_log.isDebugEnabled()) {
_log.debug("DettPraticaModelListener - Chiamato Reindex IntPraticaId : " _log.debug("DettPraticaModelListener - Chiamato Reindex IntPraticaId : " + model.getIntPraticaId());
+ model.getIntPraticaId());
} }
if (model.getStatus() == WorkflowConstants.STATUS_APPROVED) { if (model.getStatus() == WorkflowConstants.STATUS_APPROVED) {
IntPraticaLocalServiceUtil.updateModifiedDate(model.getIntPraticaId(), new Date()); IntPraticaLocalServiceUtil.updateModifiedDate(model.getIntPraticaId(), new Date());
} }
} catch (SearchException | NoSuchIntPraticaException | SystemException e) { } catch (SearchException | NoSuchIntPraticaException | SystemException e) {
_log.error(e, e); _log.error(e, e);
} }
super.onAfterUpdate(model); 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 { public void onAfterUpdate(DocPratica model) throws ModelListenerException {
try { try {
Indexer indexer = IndexerRegistryUtil.getIndexer(IntPratica.class); Indexer indexer = IndexerRegistryUtil.getIndexer(IntPratica.class);
indexer.reindex(IntPratica.class.getName(), model.getIntPraticaId()); indexer.reindex(IntPratica.class.getName(), model.getIntPraticaId());
if (_log.isDebugEnabled()) { if (_log.isDebugEnabled()) {
_log.debug("DettPraticaModelListener - Chiamato Reindex IntPraticaId : " _log.debug("DettPraticaModelListener - Chiamato Reindex IntPraticaId : " + model.getIntPraticaId());
+ model.getIntPraticaId());
} }
} catch (SearchException e) { } catch (SearchException e) {
_log.error(e, e); _log.error(e, e);
} }
super.onAfterUpdate(model); 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 { public void onAfterUpdate(IntPratica model) throws ModelListenerException {
try { try {
Indexer intIndexer = IndexerRegistryUtil.getIndexer(IntPratica.class); Indexer intIndexer = IndexerRegistryUtil.getIndexer(IntPratica.class);
Indexer controlloIndexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class); Indexer controlloIndexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class);
intIndexer.delete(model.getCompanyId(), model.getUuid()); intIndexer.delete(model.getCompanyId(), model.getUuid());
intIndexer.reindex(IntPratica.class.getName(), model.getIntPraticaId()); intIndexer.reindex(IntPratica.class.getName(), model.getIntPraticaId());
DynamicQuery queryCP = DynamicQueryFactoryUtil.forClass(ControlloPratica.class); DynamicQuery queryCP = DynamicQueryFactoryUtil.forClass(ControlloPratica.class);
queryCP.add(RestrictionsFactoryUtil.eq("intPraticaId", model.getIntPraticaId())); queryCP.add(RestrictionsFactoryUtil.eq("intPraticaId", model.getIntPraticaId()));
List<ControlloPratica> appList = ControlloPraticaLocalServiceUtil.dynamicQuery(queryCP, List<ControlloPratica> appList = ControlloPraticaLocalServiceUtil.dynamicQuery(queryCP,
QueryUtil.ALL_POS, QueryUtil.ALL_POS); QueryUtil.ALL_POS, QueryUtil.ALL_POS);
if (appList != null && !appList.isEmpty()) { if (appList != null && !appList.isEmpty()) {
for (ControlloPratica controlloPratica : appList) { for (ControlloPratica controlloPratica : appList) {
controlloIndexer.delete(model.getCompanyId(), controlloPratica.getUuid()); controlloIndexer.delete(model.getCompanyId(), controlloPratica.getUuid());
@ -47,14 +42,9 @@ public class IntPraticaModelListener extends BaseModelListener<IntPratica> {
controlloPratica.getControlloPraticaId()); controlloPratica.getControlloPraticaId());
} }
} }
} catch (SearchException | SystemException e) {
} catch (SearchException e) {
_log.error(e, e);
} catch (SystemException e) {
_log.error(e, e); _log.error(e, e);
} }
super.onAfterUpdate(model); 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 { public void onAfterUpdate(KaleoInstance model) throws ModelListenerException {
try { try {
if (model.getClassName().equals(ControlloPratica.class.getName())) { if (model.getClassName().equals(ControlloPratica.class.getName())) {
Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class); Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class);
indexer.reindex(ControlloPratica.class.getName(), model.getClassPK()); indexer.reindex(ControlloPratica.class.getName(), model.getClassPK());
if (_log.isDebugEnabled()) { if (_log.isDebugEnabled()) {
_log.debug("KaleoInstanceModelListener - Chiamato Reindex ControlloPraticaId : " _log.debug("KaleoInstanceModelListener - Chiamato Reindex ControlloPraticaId : "
+ model.getClassPK()); + model.getClassPK());
} }
} }
} catch (SearchException e) { } catch (SearchException e) {
_log.error(e, e); _log.error(e, e);
} }
super.onAfterUpdate(model); super.onAfterUpdate(model);
} }
@ -55,28 +50,23 @@ public class KaleoInstanceModelListener extends BaseModelListener<KaleoInstance>
public void onAfterRemove(KaleoInstance model) throws ModelListenerException { public void onAfterRemove(KaleoInstance model) throws ModelListenerException {
try { try {
if (model.getClassName().equals(ControlloPratica.class.getName())) { if (model.getClassName().equals(ControlloPratica.class.getName())) {
Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class); Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class);
indexer.reindex(ControlloPratica.class.getName(), model.getClassPK()); indexer.reindex(ControlloPratica.class.getName(), model.getClassPK());
if (_log.isDebugEnabled()) { if (_log.isDebugEnabled()) {
_log.debug("KaleoInstanceModelListener - Chiamato Reindex ControlloPraticaId : " _log.debug("KaleoInstanceModelListener - Chiamato Reindex ControlloPraticaId : "
+ model.getClassPK()); + model.getClassPK());
} }
} }
} catch (SearchException e) { } catch (SearchException e) {
_log.error(e, e); _log.error(e, e);
} }
super.onAfterRemove(model); super.onAfterRemove(model);
} }
@Override @Override
public void onAfterRemoveAssociation(Object classPK, String associationClassName, public void onAfterRemoveAssociation(Object classPK, String associationClassName, Object associationClassPK)
Object associationClassPK) throws ModelListenerException { throws ModelListenerException {
super.onAfterRemoveAssociation(classPK, associationClassName, associationClassPK); super.onAfterRemoveAssociation(classPK, associationClassName, associationClassPK);
} }
@ -101,8 +91,8 @@ public class KaleoInstanceModelListener extends BaseModelListener<KaleoInstance>
} }
@Override @Override
public void onBeforeRemoveAssociation(Object classPK, String associationClassName, public void onBeforeRemoveAssociation(Object classPK, String associationClassName, Object associationClassPK)
Object associationClassPK) throws ModelListenerException { throws ModelListenerException {
super.onBeforeRemoveAssociation(classPK, associationClassName, associationClassPK); super.onBeforeRemoveAssociation(classPK, associationClassName, associationClassPK);
} }
@ -112,5 +102,4 @@ public class KaleoInstanceModelListener extends BaseModelListener<KaleoInstance>
super.onBeforeUpdate(model); 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; 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.ControlloPratica;
import it.tref.liferay.portos.bo.model.DettPratica; import it.tref.liferay.portos.bo.model.DettPratica;
import it.tref.liferay.portos.bo.model.IntPratica; 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.service.IntPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.shared.util.TipoIntegrazioneUtil; import it.tref.liferay.portos.bo.shared.util.TipoIntegrazioneUtil;
import java.util.Date;
import com.liferay.counter.service.CounterLocalServiceUtil; import com.liferay.counter.service.CounterLocalServiceUtil;
import com.liferay.portal.ModelListenerException; import com.liferay.portal.ModelListenerException;
import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.PortalException;
@ -32,22 +32,17 @@ public class KaleoInstanceTokenModelListener extends BaseModelListener<KaleoInst
public void onAfterUpdate(KaleoInstanceToken model) throws ModelListenerException { public void onAfterUpdate(KaleoInstanceToken model) throws ModelListenerException {
try { try {
if (model.getClassName().equals(ControlloPratica.class.getName())) { if (model.getClassName().equals(ControlloPratica.class.getName())) {
Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class); Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class);
indexer.reindex(ControlloPratica.class.getName(), model.getClassPK()); indexer.reindex(ControlloPratica.class.getName(), model.getClassPK());
if (_log.isDebugEnabled()) { if (_log.isDebugEnabled()) {
_log.debug("KaleoInstanceTokenModelListener - Chiamato Reindex ControlloPraticaId : " _log.debug("KaleoInstanceTokenModelListener - Chiamato Reindex ControlloPraticaId : "
+ model.getClassPK()); + model.getClassPK());
} }
} }
} catch (SearchException e) { } catch (SearchException e) {
_log.error(e, e); _log.error(e, e);
} }
super.onAfterUpdate(model); super.onAfterUpdate(model);
} }
@ -61,6 +56,7 @@ public class KaleoInstanceTokenModelListener extends BaseModelListener<KaleoInst
@Override @Override
public void onAfterCreate(KaleoInstanceToken model) throws ModelListenerException { public void onAfterCreate(KaleoInstanceToken model) throws ModelListenerException {
ControlloPratica cp; ControlloPratica cp;
try { try {
cp = ControlloPraticaLocalServiceUtil.getControlloPratica(model.getClassPK()); cp = ControlloPraticaLocalServiceUtil.getControlloPratica(model.getClassPK());
@ -69,12 +65,12 @@ public class KaleoInstanceTokenModelListener extends BaseModelListener<KaleoInst
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
// TODO Auto-generated method stub // TODO Auto-generated method stub
super.onAfterCreate(model); super.onAfterCreate(model);
} }
private void gestioneWFVarianti(ControlloPratica cp, KaleoInstanceToken model) { private void gestioneWFVarianti(ControlloPratica cp, KaleoInstanceToken model) {
try { try {
DettPratica dettPratica = DettPraticaLocalServiceUtil.getDettPratica(cp.getDettPraticaId()); DettPratica dettPratica = DettPraticaLocalServiceUtil.getDettPratica(cp.getDettPraticaId());
if (dettPratica.getTipoIntegrazione().equals(TipoIntegrazioneUtil.VARIANTE) if (dettPratica.getTipoIntegrazione().equals(TipoIntegrazioneUtil.VARIANTE)
@ -91,7 +87,6 @@ public class KaleoInstanceTokenModelListener extends BaseModelListener<KaleoInst
} else { } else {
_log.info("gestioneWFVarianti - statusByuserId determinato =" + statusByuserId); _log.info("gestioneWFVarianti - statusByuserId determinato =" + statusByuserId);
} }
long kaleoTaskInstanceTokenID = CounterLocalServiceUtil long kaleoTaskInstanceTokenID = CounterLocalServiceUtil
.increment("com.liferay.counter.model.Counter"); .increment("com.liferay.counter.model.Counter");
_log.info("kaleoTaskInstanceTokenID=" + kaleoTaskInstanceTokenID); _log.info("kaleoTaskInstanceTokenID=" + kaleoTaskInstanceTokenID);
@ -116,38 +111,29 @@ public class KaleoInstanceTokenModelListener extends BaseModelListener<KaleoInst
+ x.getKaleoTaskInstanceTokenId()); + x.getKaleoTaskInstanceTokenId());
_log.info("gestioneWFVarianti - correttamente eseguito - ControlloPraticaId = " _log.info("gestioneWFVarianti - correttamente eseguito - ControlloPraticaId = "
+ cp.getControlloPraticaId()); + cp.getControlloPraticaId());
// ///////////////////////////////////////////////////////////////////
} }
} catch (Exception e) { } catch (Exception e) {
_log.error( _log.error(
"gestioneWFVarianti - Errore in gestioneWFVarianti - dettaPratiacaId=" "gestioneWFVarianti - Errore in gestioneWFVarianti - dettaPratiacaId="
+ cp.getDettPraticaId(), e); + cp.getDettPraticaId(), e);
// throw e;
} }
} }
@Override @Override
public void onAfterRemove(KaleoInstanceToken model) throws ModelListenerException { public void onAfterRemove(KaleoInstanceToken model) throws ModelListenerException {
try { try {
if (model.getClassName().equals(ControlloPratica.class.getName())) { if (model.getClassName().equals(ControlloPratica.class.getName())) {
Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class); Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class);
indexer.reindex(ControlloPratica.class.getName(), model.getClassPK()); indexer.reindex(ControlloPratica.class.getName(), model.getClassPK());
if (_log.isDebugEnabled()) { if (_log.isDebugEnabled()) {
_log.debug("KaleoInstanceTokenModelListener - Chiamato Reindex ControlloPraticaId : " _log.debug("KaleoInstanceTokenModelListener - Chiamato Reindex ControlloPraticaId : "
+ model.getClassPK()); + model.getClassPK());
} }
} }
} catch (SearchException e) { } catch (SearchException e) {
_log.error(e, e); _log.error(e, e);
} }
super.onAfterRemove(model); super.onAfterRemove(model);
} }
@ -195,5 +181,4 @@ public class KaleoInstanceTokenModelListener extends BaseModelListener<KaleoInst
// TODO Auto-generated method stub // TODO Auto-generated method stub
super.onBeforeUpdate(model); 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 { public void onAfterCreate(KaleoLog model) throws ModelListenerException {
try { try {
long kaleoInstanceTokenId = model.getKaleoInstanceTokenId(); long kaleoInstanceTokenId = model.getKaleoInstanceTokenId();
KaleoInstanceToken instanceToken = KaleoInstanceTokenLocalServiceUtil KaleoInstanceToken instanceToken = KaleoInstanceTokenLocalServiceUtil
.fetchKaleoInstanceToken(kaleoInstanceTokenId); .fetchKaleoInstanceToken(kaleoInstanceTokenId);
if (Validator.isNotNull(instanceToken)) { if (Validator.isNotNull(instanceToken)) {
if (instanceToken.getClassName().equals(ControlloPratica.class.getName())) { if (instanceToken.getClassName().equals(ControlloPratica.class.getName())) {
Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class); Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class);
indexer.reindex(ControlloPratica.class.getName(), instanceToken.getClassPK()); indexer.reindex(ControlloPratica.class.getName(), instanceToken.getClassPK());
if (_log.isDebugEnabled()) { if (_log.isDebugEnabled()) {
_log.debug("KaleoLogModelListener - Chiamato Reindex ControlloPraticaId : " _log.debug("KaleoLogModelListener - Chiamato Reindex ControlloPraticaId : "
+ instanceToken.getClassPK()); + instanceToken.getClassPK());
} }
} }
} }
} catch (SearchException | SystemException e) {
} catch (SearchException e) {
_log.error(e, e);
} catch (SystemException e) {
_log.error(e, e); _log.error(e, e);
} }
super.onAfterUpdate(model); super.onAfterUpdate(model);
} }
@ -62,30 +54,22 @@ public class KaleoLogModelListener extends BaseModelListener<KaleoLog> {
public void onAfterRemove(KaleoLog model) throws ModelListenerException { public void onAfterRemove(KaleoLog model) throws ModelListenerException {
try { try {
long kaleoInstanceTokenId = model.getKaleoInstanceTokenId(); long kaleoInstanceTokenId = model.getKaleoInstanceTokenId();
KaleoInstanceToken instanceToken = KaleoInstanceTokenLocalServiceUtil KaleoInstanceToken instanceToken = KaleoInstanceTokenLocalServiceUtil
.fetchKaleoInstanceToken(kaleoInstanceTokenId); .fetchKaleoInstanceToken(kaleoInstanceTokenId);
if (Validator.isNotNull(instanceToken)) { if (Validator.isNotNull(instanceToken)) {
if (instanceToken.getClassName().equals(ControlloPratica.class.getName())) { if (instanceToken.getClassName().equals(ControlloPratica.class.getName())) {
Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class); Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class);
indexer.reindex(ControlloPratica.class.getName(), instanceToken.getClassPK()); indexer.reindex(ControlloPratica.class.getName(), instanceToken.getClassPK());
if (_log.isDebugEnabled()) { if (_log.isDebugEnabled()) {
_log.debug("KaleoLogModelListener - Chiamato Reindex ControlloPraticaId : " _log.debug("KaleoLogModelListener - Chiamato Reindex ControlloPraticaId : "
+ instanceToken.getClassPK()); + instanceToken.getClassPK());
} }
} }
} }
} catch (SearchException | SystemException e) {
} catch (SearchException e) {
_log.error(e, e);
} catch (SystemException e) {
_log.error(e, e); _log.error(e, e);
} }
super.onAfterRemove(model); 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 { public void onAfterUpdate(KaleoTaskInstanceToken model) throws ModelListenerException {
try { try {
if (model.getClassName().equals(ControlloPratica.class.getName())) { if (model.getClassName().equals(ControlloPratica.class.getName())) {
Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class); Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class);
indexer.reindex(ControlloPratica.class.getName(), model.getClassPK()); indexer.reindex(ControlloPratica.class.getName(), model.getClassPK());
if (_log.isDebugEnabled()) { if (_log.isDebugEnabled()) {
_log.debug("KaleoTaskInstanceToken - Chiamato Reindex ControlloPraticaId : " _log.debug("KaleoTaskInstanceToken - Chiamato Reindex ControlloPraticaId : " + model.getClassPK());
+ model.getClassPK());
} }
} }
} catch (SearchException e) { } catch (SearchException e) {
_log.error(e, e); _log.error(e, e);
} }
super.onAfterUpdate(model); super.onAfterUpdate(model);
} }
@ -57,28 +51,22 @@ public class KaleoTaskInstanceTokenModelListener extends BaseModelListener<Kaleo
public void onAfterRemove(KaleoTaskInstanceToken model) throws ModelListenerException { public void onAfterRemove(KaleoTaskInstanceToken model) throws ModelListenerException {
try { try {
if (model.getClassName().equals(ControlloPratica.class.getName())) { if (model.getClassName().equals(ControlloPratica.class.getName())) {
Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class); Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class);
indexer.reindex(ControlloPratica.class.getName(), model.getClassPK()); indexer.reindex(ControlloPratica.class.getName(), model.getClassPK());
if (_log.isDebugEnabled()) { if (_log.isDebugEnabled()) {
_log.debug("KaleoTaskInstanceToken - Chiamato Reindex ControlloPraticaId : " _log.debug("KaleoTaskInstanceToken - Chiamato Reindex ControlloPraticaId : " + model.getClassPK());
+ model.getClassPK());
} }
} }
} catch (SearchException e) { } catch (SearchException e) {
_log.error(e, e); _log.error(e, e);
} }
super.onAfterRemove(model); super.onAfterRemove(model);
} }
@Override @Override
public void onAfterRemoveAssociation(Object classPK, String associationClassName, public void onAfterRemoveAssociation(Object classPK, String associationClassName, Object associationClassPK)
Object associationClassPK) throws ModelListenerException { throws ModelListenerException {
// TODO Auto-generated method stub // TODO Auto-generated method stub
super.onAfterRemoveAssociation(classPK, associationClassName, associationClassPK); super.onAfterRemoveAssociation(classPK, associationClassName, associationClassPK);
@ -107,8 +95,8 @@ public class KaleoTaskInstanceTokenModelListener extends BaseModelListener<Kaleo
} }
@Override @Override
public void onBeforeRemoveAssociation(Object classPK, String associationClassName, public void onBeforeRemoveAssociation(Object classPK, String associationClassName, Object associationClassPK)
Object associationClassPK) throws ModelListenerException { throws ModelListenerException {
// TODO Auto-generated method stub // TODO Auto-generated method stub
super.onBeforeRemoveAssociation(classPK, associationClassName, associationClassPK); super.onBeforeRemoveAssociation(classPK, associationClassName, associationClassPK);
@ -120,5 +108,4 @@ public class KaleoTaskInstanceTokenModelListener extends BaseModelListener<Kaleo
// TODO Auto-generated method stub // TODO Auto-generated method stub
super.onBeforeUpdate(model); 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 { public void onAfterUpdate(Soggetto model) throws ModelListenerException {
try { try {
Indexer indexer = IndexerRegistryUtil.getIndexer(IntPratica.class); Indexer indexer = IndexerRegistryUtil.getIndexer(IntPratica.class);
indexer.reindex(IntPratica.class.getName(), model.getIntPraticaId()); indexer.reindex(IntPratica.class.getName(), model.getIntPraticaId());
if (_log.isDebugEnabled()) { if (_log.isDebugEnabled()) {
_log.debug("DettPraticaModelListener - Chiamato Reindex IntPraticaId : " _log.debug("DettPraticaModelListener - Chiamato Reindex IntPraticaId : " + model.getIntPraticaId());
+ model.getIntPraticaId());
} }
} catch (SearchException e) { } catch (SearchException e) {
_log.error(e, e); _log.error(e, e);
} }
super.onAfterUpdate(model); 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.model.AllegatoManuale;
import it.tref.liferay.portos.bo.service.AllegatoManualeLocalServiceUtil; import it.tref.liferay.portos.bo.service.AllegatoManualeLocalServiceUtil;
import it.tref.liferay.portos.bo.service.AllegatoManualeServiceUtil; 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.File;
import java.io.IOException; 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.exception.SystemException;
import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil; 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.repository.model.FileEntry;
import com.liferay.portal.kernel.servlet.HttpHeaders; import com.liferay.portal.kernel.servlet.HttpHeaders;
import com.liferay.portal.kernel.servlet.SessionErrors; import com.liferay.portal.kernel.servlet.SessionErrors;
@ -48,6 +45,7 @@ public class AllegatiManualiPortlet extends MVCPortlet {
public void uploadAllegatoManuale(ActionRequest actionRequest, ActionResponse actionResponse) public void uploadAllegatoManuale(ActionRequest actionRequest, ActionResponse actionResponse)
throws PortalException, SystemException { throws PortalException, SystemException {
try { try {
UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest); UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest);
ServiceContext serviceContext = ServiceContextFactory.getInstance(uploadRequest); ServiceContext serviceContext = ServiceContextFactory.getInstance(uploadRequest);
@ -56,7 +54,6 @@ public class AllegatiManualiPortlet extends MVCPortlet {
String descrizione = ParamUtil.getString(uploadRequest, "descrizione"); String descrizione = ParamUtil.getString(uploadRequest, "descrizione");
String sourceFileName = uploadRequest.getFileName("docFile"); String sourceFileName = uploadRequest.getFileName("docFile");
File file = uploadRequest.getFile("docFile"); File file = uploadRequest.getFile("docFile");
if (Validator.isNotNull(sourceFileName) && file != null) { if (Validator.isNotNull(sourceFileName) && file != null) {
// validazione: solo alcune estensioni // validazione: solo alcune estensioni
String ext = FileUtil.getExtension(sourceFileName); String ext = FileUtil.getExtension(sourceFileName);
@ -70,7 +67,6 @@ public class AllegatiManualiPortlet extends MVCPortlet {
} else { } else {
SessionErrors.add(actionRequest, "error.geniocivilefe.allegato.manuale.is.request"); SessionErrors.add(actionRequest, "error.geniocivilefe.allegato.manuale.is.request");
} }
if (SessionErrors.isEmpty(actionRequest)) { if (SessionErrors.isEmpty(actionRequest)) {
if (Validator.isNotNull(intPraticaId) && Validator.isNotNull(dettPraticaId)) { if (Validator.isNotNull(intPraticaId) && Validator.isNotNull(dettPraticaId)) {
byte[] content = FileUtil.getBytes(file); byte[] content = FileUtil.getBytes(file);
@ -84,10 +80,10 @@ public class AllegatiManualiPortlet extends MVCPortlet {
_log.error("Error", e); _log.error("Error", e);
throw new SystemException(e); throw new SystemException(e);
} }
} }
public void deleteAllegatoManuale(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { public void deleteAllegatoManuale(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long allegatoManualeId = ParamUtil.getLong(actionRequest, "allegatoManualeId"); long allegatoManualeId = ParamUtil.getLong(actionRequest, "allegatoManualeId");
AllegatoManualeServiceUtil.deleteAllegatoManuale(allegatoManualeId); AllegatoManualeServiceUtil.deleteAllegatoManuale(allegatoManualeId);
} }
@ -97,56 +93,34 @@ public class AllegatiManualiPortlet extends MVCPortlet {
PortletException { PortletException {
String id = resourceRequest.getResourceID(); String id = resourceRequest.getResourceID();
try { try {
if ("downloadAll".equals(id)) { if ("downloadAll".equals(id)) {
long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId"); long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId");
List<AllegatoManuale> docs = AllegatoManualeServiceUtil.findByIntPratica(intPraticaId); List<AllegatoManuale> docs = AllegatoManualeServiceUtil.findByIntPratica(intPraticaId);
ZipWriter zipWriter = ZipWriterFactoryUtil.getZipWriter(); ZipWriter zipWriter = ZipWriterFactoryUtil.getZipWriter();
for (AllegatoManuale doc : docs) { for (AllegatoManuale doc : docs) {
InputStream inputStream = null; InputStream inputStream = null;
try { try {
FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(doc.getFileEntryId()); FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(doc.getFileEntryId());
inputStream = DLFileEntryLocalServiceUtil.getFileAsStream(fileEntry.getFileEntryId(), inputStream = DLFileEntryLocalServiceUtil.getFileAsStream(fileEntry.getFileEntryId(),
fileEntry.getVersion(), false); fileEntry.getVersion(), false);
String name = fileEntry.getTitle() + StringPool.PERIOD + fileEntry.getExtension(); String name = fileEntry.getTitle() + StringPool.PERIOD + fileEntry.getExtension();
zipWriter.addEntry(name, inputStream); zipWriter.addEntry(name, inputStream);
} finally { } finally {
StreamUtil.cleanUp(inputStream); StreamUtil.cleanUp(inputStream);
} }
} }
resourceResponse.reset(); resourceResponse.reset();
File file = zipWriter.getFile(); File file = zipWriter.getFile();
byte[] data = Files.readAllBytes(file.toPath()); byte[] data = Files.readAllBytes(file.toPath());
resourceResponse.setContentType(ContentTypes.APPLICATION_ZIP); resourceResponse.setContentType(ContentTypes.APPLICATION_ZIP);
resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate"); resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate");
resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION, resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"" + file.getName() + "\""); "attachment; filename=\"" + file.getName() + StringPool.QUOTE);
resourceResponse.setContentLength(data.length); resourceResponse.setContentLength(data.length);
resourceResponse.getPortletOutputStream().write(data); resourceResponse.getPortletOutputStream().write(data);
resourceResponse.getPortletOutputStream().flush(); resourceResponse.getPortletOutputStream().flush();
resourceResponse.getPortletOutputStream().close(); 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 { } else {
super.serveResource(resourceRequest, resourceResponse); 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); private static final Log _log = LogFactoryUtil.getLog(AmministrazionePortlet.class);
public void saveProvincia(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { public void saveProvincia(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long provinciaId = ParamUtil.getLong(actionRequest, "provinciaId"); long provinciaId = ParamUtil.getLong(actionRequest, "provinciaId");
String codiceProvincia = ParamUtil.getString(actionRequest, "codiceProvincia"); String codiceProvincia = ParamUtil.getString(actionRequest, "codiceProvincia");
String provincia = ParamUtil.getString(actionRequest, "provincia"); String provincia = ParamUtil.getString(actionRequest, "provincia");
@ -73,6 +74,7 @@ public class AmministrazionePortlet extends MVCPortlet {
} }
public void saveConfigScheduler(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { public void saveConfigScheduler(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
try { try {
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
serviceContext.setScopeGroupId(-1L); serviceContext.setScopeGroupId(-1L);
@ -147,21 +149,21 @@ public class AmministrazionePortlet extends MVCPortlet {
} }
public void saveConfigTemplate(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { public void saveConfigTemplate(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
try { try {
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
final String _PREFIX_START_CONFIGURAZIONE = "configurazione--"; final String _PREFIX_START_CONFIGURAZIONE = "configurazione--";
final String _PREFIX_END_CONFIGURAZIONE = "--"; final String _PREFIX_END_CONFIGURAZIONE = StringPool.DOUBLE_DASH;
Enumeration<String> enu = actionRequest.getParameterNames(); Enumeration<String> enu = actionRequest.getParameterNames();
while (enu.hasMoreElements()) { while (enu.hasMoreElements()) {
String name = enu.nextElement(); String name = enu.nextElement();
if (!name.startsWith(_PREFIX_START_CONFIGURAZIONE) && !name.endsWith("--")) { if (name.startsWith(_PREFIX_START_CONFIGURAZIONE) && name.endsWith(_PREFIX_END_CONFIGURAZIONE)) {
continue;
}
String key = name.substring(_PREFIX_START_CONFIGURAZIONE.length(), name.length() String key = name.substring(_PREFIX_START_CONFIGURAZIONE.length(), name.length()
- _PREFIX_END_CONFIGURAZIONE.length()); - _PREFIX_END_CONFIGURAZIONE.length());
String value = ParamUtil.getString(actionRequest, name); String value = ParamUtil.getString(actionRequest, name);
ConfigurazioneServiceUtil.storeConfig(key, value, serviceContext); ConfigurazioneServiceUtil.storeConfig(key, value, serviceContext);
} }
}
String redirect = ParamUtil.getString(actionRequest, "redirect"); String redirect = ParamUtil.getString(actionRequest, "redirect");
if (Validator.isNull(redirect)) { if (Validator.isNull(redirect)) {
actionResponse.setRenderParameter("tabs1", "parametri"); actionResponse.setRenderParameter("tabs1", "parametri");
@ -173,6 +175,7 @@ public class AmministrazionePortlet extends MVCPortlet {
} }
public void saveComune(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { public void saveComune(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long comuneId = ParamUtil.getLong(actionRequest, "comuneId"); long comuneId = ParamUtil.getLong(actionRequest, "comuneId");
String codiceProvincia = ParamUtil.getString(actionRequest, "codiceProvincia"); String codiceProvincia = ParamUtil.getString(actionRequest, "codiceProvincia");
String codiceComune = ParamUtil.getString(actionRequest, "codiceComune"); String codiceComune = ParamUtil.getString(actionRequest, "codiceComune");
@ -206,6 +209,7 @@ public class AmministrazionePortlet extends MVCPortlet {
} }
public void saveTerritorio(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { public void saveTerritorio(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long territorioId = ParamUtil.getLong(actionRequest, "territorioId"); long territorioId = ParamUtil.getLong(actionRequest, "territorioId");
long comuneId = ParamUtil.getLong(actionRequest, "comuneId"); long comuneId = ParamUtil.getLong(actionRequest, "comuneId");
long groupId = ParamUtil.getLong(actionRequest, "groupId"); long groupId = ParamUtil.getLong(actionRequest, "groupId");
@ -236,6 +240,7 @@ public class AmministrazionePortlet extends MVCPortlet {
} }
public void deleteComune(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { public void deleteComune(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long comuneId = ParamUtil.getLong(actionRequest, "comuneId"); long comuneId = ParamUtil.getLong(actionRequest, "comuneId");
if (comuneId > 0) { if (comuneId > 0) {
ComuneLocalServiceUtil.deleteComune(comuneId); ComuneLocalServiceUtil.deleteComune(comuneId);
@ -243,6 +248,7 @@ public class AmministrazionePortlet extends MVCPortlet {
} }
public void deleteComunes(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { public void deleteComunes(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long[] deleteComuneIds = ParamUtil.getLongValues(actionRequest, "deleteComuneIds"); long[] deleteComuneIds = ParamUtil.getLongValues(actionRequest, "deleteComuneIds");
for (long deleteComuneId : deleteComuneIds) { for (long deleteComuneId : deleteComuneIds) {
ComuneLocalServiceUtil.deleteComune(deleteComuneId); ComuneLocalServiceUtil.deleteComune(deleteComuneId);
@ -251,6 +257,7 @@ public class AmministrazionePortlet extends MVCPortlet {
} }
public void deleteProvincia(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { public void deleteProvincia(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long provinciaId = ParamUtil.getLong(actionRequest, "provinciaId"); long provinciaId = ParamUtil.getLong(actionRequest, "provinciaId");
if (provinciaId > 0) { if (provinciaId > 0) {
ProvinciaLocalServiceUtil.deleteProvincia(provinciaId); ProvinciaLocalServiceUtil.deleteProvincia(provinciaId);
@ -258,6 +265,7 @@ public class AmministrazionePortlet extends MVCPortlet {
} }
public void deleteProvincias(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { public void deleteProvincias(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long[] deleteProvinciaIds = ParamUtil.getLongValues(actionRequest, "deleteProvinciaIds"); long[] deleteProvinciaIds = ParamUtil.getLongValues(actionRequest, "deleteProvinciaIds");
for (long deleteProvinciaId : deleteProvinciaIds) { for (long deleteProvinciaId : deleteProvinciaIds) {
ProvinciaLocalServiceUtil.deleteProvincia(deleteProvinciaId); ProvinciaLocalServiceUtil.deleteProvincia(deleteProvinciaId);
@ -266,6 +274,7 @@ public class AmministrazionePortlet extends MVCPortlet {
} }
public void deleteTerritorio(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { public void deleteTerritorio(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long territorioId = ParamUtil.getLong(actionRequest, "territorioId"); long territorioId = ParamUtil.getLong(actionRequest, "territorioId");
if (territorioId > 0) { if (territorioId > 0) {
ComuneLocalServiceUtil.deleteComune(territorioId); ComuneLocalServiceUtil.deleteComune(territorioId);
@ -273,6 +282,7 @@ public class AmministrazionePortlet extends MVCPortlet {
} }
public void importProvincias(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { public void importProvincias(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest); UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest);
ThemeDisplay themeDisplay = (ThemeDisplay) uploadPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); ThemeDisplay themeDisplay = (ThemeDisplay) uploadPortletRequest.getAttribute(WebKeys.THEME_DISPLAY);
String delimiter = ParamUtil.getString(uploadPortletRequest, "delimiter"); String delimiter = ParamUtil.getString(uploadPortletRequest, "delimiter");
@ -326,6 +336,7 @@ public class AmministrazionePortlet extends MVCPortlet {
} }
public void importComunes(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { public void importComunes(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest); UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest);
ThemeDisplay themeDisplay = (ThemeDisplay) uploadPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); ThemeDisplay themeDisplay = (ThemeDisplay) uploadPortletRequest.getAttribute(WebKeys.THEME_DISPLAY);
String delimiter = ParamUtil.getString(uploadPortletRequest, "delimiter"); 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: " _log.error("Il comune italiano non ha un codice istat assegnato e non sarà inserito: "
+ csvRecord); + csvRecord);
} else { } else {
boolean isProvincia = Validator.isNotNull(provincia) && provincia.equals("1") ? true : false; boolean isProvincia = Validator.isNotNull(provincia) && provincia.equals("1");
Comune comuneO = ComuneLocalServiceUtil Comune comuneO = ComuneLocalServiceUtil
.fetchByC_CB(themeDisplay.getCompanyId(), codiceBelfiore); .fetchByC_CB(themeDisplay.getCompanyId(), codiceBelfiore);
if (comuneO == null) if (comuneO == null)
comuneO = ComuneLocalServiceUtil.fetchByC_CI(themeDisplay.getCompanyId(), codiceIstat); comuneO = ComuneLocalServiceUtil.fetchByC_CI(themeDisplay.getCompanyId(), codiceIstat);
if (comuneO == null) { if (comuneO == null) {
_log.debug("Il comune non esiste e verra' creato: " + csvRecord); _log.debug("Il comune non esiste e verra' creato: " + csvRecord);
if (nazioneEstera) if (nazioneEstera) {
ComuneLocalServiceUtil.addComune(themeDisplay.getUserId(), codiceProvincia, ComuneLocalServiceUtil.addComune(themeDisplay.getUserId(), codiceProvincia,
codiceComune, codiceIstat, codiceBelfiore, denominazione, false, true, codiceComune, codiceIstat, codiceBelfiore, denominazione, false, true,
StringPool.BLANK, StringPool.BLANK, serviceContext); StringPool.BLANK, StringPool.BLANK, serviceContext);
else } else {
ComuneLocalServiceUtil.addComune(themeDisplay.getUserId(), codiceProvincia, ComuneLocalServiceUtil.addComune(themeDisplay.getUserId(), codiceProvincia,
codiceComune, codiceIstat, codiceBelfiore, denominazione, isProvincia, false, codiceComune, codiceIstat, codiceBelfiore, denominazione, isProvincia, false,
StringPool.BLANK, StringPool.BLANK, serviceContext); StringPool.BLANK, StringPool.BLANK, serviceContext);
}
} else { } else {
_log.debug("Il comune esiste e verra' aggiornato: " + csvRecord); _log.debug("Il comune esiste e verra' aggiornato: " + csvRecord);
ComuneLocalServiceUtil.updateComune(themeDisplay.getUserId(), comuneO.getPrimaryKey(), 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.model.DocAggiuntiva;
import it.tref.liferay.portos.bo.service.DocAggiuntivaLocalServiceUtil; import it.tref.liferay.portos.bo.service.DocAggiuntivaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DocAggiuntivaServiceUtil; 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.File;
import java.io.IOException; 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.exception.SystemException;
import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil; 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.repository.model.FileEntry;
import com.liferay.portal.kernel.servlet.HttpHeaders; import com.liferay.portal.kernel.servlet.HttpHeaders;
import com.liferay.portal.kernel.servlet.SessionErrors; import com.liferay.portal.kernel.servlet.SessionErrors;
@ -46,8 +43,9 @@ public class DocAggiuntivaPortlet extends MVCPortlet {
private Log _log = LogFactoryUtil.getLog(DocAggiuntivaPortlet.class); private Log _log = LogFactoryUtil.getLog(DocAggiuntivaPortlet.class);
public void uploadDocAggiuntiva(ActionRequest actionRequest, ActionResponse actionResponse) public void uploadDocAggiuntiva(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException,
throws PortalException, SystemException { SystemException {
try { try {
UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest); UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest);
ServiceContext serviceContext = ServiceContextFactory.getInstance(uploadRequest); ServiceContext serviceContext = ServiceContextFactory.getInstance(uploadRequest);
@ -57,7 +55,6 @@ public class DocAggiuntivaPortlet extends MVCPortlet {
boolean feVisible = ParamUtil.getBoolean(uploadRequest, "feVisible"); boolean feVisible = ParamUtil.getBoolean(uploadRequest, "feVisible");
String sourceFileName = uploadRequest.getFileName("docFile"); String sourceFileName = uploadRequest.getFileName("docFile");
File file = uploadRequest.getFile("docFile"); File file = uploadRequest.getFile("docFile");
if (Validator.isNotNull(sourceFileName) && file != null) { if (Validator.isNotNull(sourceFileName) && file != null) {
// lunghezza fissata a 200 // lunghezza fissata a 200
if (sourceFileName.length() > 200) { if (sourceFileName.length() > 200) {
@ -66,7 +63,6 @@ public class DocAggiuntivaPortlet extends MVCPortlet {
} else { } else {
SessionErrors.add(actionRequest, "error.geniocivilefe.pagamento.allegato.is.request"); SessionErrors.add(actionRequest, "error.geniocivilefe.pagamento.allegato.is.request");
} }
if (!SessionErrors.isEmpty(actionRequest)) { if (!SessionErrors.isEmpty(actionRequest)) {
PortalUtil.copyRequestParameters(actionRequest, actionResponse); PortalUtil.copyRequestParameters(actionRequest, actionResponse);
} else { } else {
@ -75,39 +71,32 @@ public class DocAggiuntivaPortlet extends MVCPortlet {
DocAggiuntivaLocalServiceUtil.addDocAggiuntiva(serviceContext.getUserId(), intPraticaId, DocAggiuntivaLocalServiceUtil.addDocAggiuntiva(serviceContext.getUserId(), intPraticaId,
dettPraticaId, descrizione, feVisible, content, sourceFileName, serviceContext); dettPraticaId, descrizione, feVisible, content, sourceFileName, serviceContext);
} }
} }
PortalUtil.copyRequestParameters(actionRequest, actionResponse); PortalUtil.copyRequestParameters(actionRequest, actionResponse);
} catch (Exception e) { } catch (Exception e) {
PortalUtil.copyRequestParameters(actionRequest, actionResponse); PortalUtil.copyRequestParameters(actionRequest, actionResponse);
_log.error("Error", e); _log.error("Error", e);
throw new SystemException(e); throw new SystemException(e);
} }
} }
public void deleteDocAggiuntiva(ActionRequest actionRequest, ActionResponse actionResponse) public void deleteDocAggiuntiva(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
throws Exception {
long docAggiuntivaId = ParamUtil.getLong(actionRequest, "docAggiuntivaId"); long docAggiuntivaId = ParamUtil.getLong(actionRequest, "docAggiuntivaId");
DocAggiuntivaServiceUtil.deleteDocAggiuntiva(docAggiuntivaId); DocAggiuntivaServiceUtil.deleteDocAggiuntiva(docAggiuntivaId);
} }
@Override @Override
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException,
throws IOException, PortletException { PortletException {
String id = resourceRequest.getResourceID(); String id = resourceRequest.getResourceID();
try { try {
if ("downloadAll".equals(id)) { if ("downloadAll".equals(id)) {
long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId"); long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId");
List<DocAggiuntiva> docs = DocAggiuntivaServiceUtil.findByIntPratica(intPraticaId); List<DocAggiuntiva> docs = DocAggiuntivaServiceUtil.findByIntPratica(intPraticaId);
ZipWriter zipWriter = ZipWriterFactoryUtil.getZipWriter(); ZipWriter zipWriter = ZipWriterFactoryUtil.getZipWriter();
for (DocAggiuntiva doc : docs) { for (DocAggiuntiva doc : docs) {
InputStream inputStream = null; InputStream inputStream = null;
try { try {
if (Validator.isNull(doc.getFileEntryId())) { if (Validator.isNull(doc.getFileEntryId())) {
@ -123,34 +112,17 @@ public class DocAggiuntivaPortlet extends MVCPortlet {
StreamUtil.cleanUp(inputStream); StreamUtil.cleanUp(inputStream);
} }
} }
resourceResponse.reset(); resourceResponse.reset();
File file = zipWriter.getFile(); File file = zipWriter.getFile();
byte[] data = Files.readAllBytes(file.toPath()); byte[] data = Files.readAllBytes(file.toPath());
resourceResponse.setContentType(ContentTypes.APPLICATION_ZIP); resourceResponse.setContentType(ContentTypes.APPLICATION_ZIP);
resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate"); resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate");
resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION,
+ file.getName() + "\""); "attachment; filename=\"" + file.getName() + StringPool.QUOTE);
resourceResponse.setContentLength(data.length); resourceResponse.setContentLength(data.length);
resourceResponse.getPortletOutputStream().write(data); resourceResponse.getPortletOutputStream().write(data);
resourceResponse.getPortletOutputStream().flush(); resourceResponse.getPortletOutputStream().flush();
resourceResponse.getPortletOutputStream().close(); 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 { } else {
super.serveResource(resourceRequest, resourceResponse); 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.DettPratica;
import it.tref.liferay.portos.bo.model.DocPratica; import it.tref.liferay.portos.bo.model.DocPratica;
import it.tref.liferay.portos.bo.model.HistoryWorkflowAction; 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.IntPratica;
import it.tref.liferay.portos.bo.model.Provincia; import it.tref.liferay.portos.bo.model.Provincia;
import it.tref.liferay.portos.bo.model.Soggetto; 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.DettPraticaServiceUtil;
import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.HistoryWorkflowActionLocalServiceUtil; 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.IntPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.IntPraticaServiceUtil; import it.tref.liferay.portos.bo.service.IntPraticaServiceUtil;
import it.tref.liferay.portos.bo.service.ParereGeologoServiceUtil; 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.SorteggioLocalServiceUtil;
import it.tref.liferay.portos.bo.service.TerritorioLocalServiceUtil; 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.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.StatoPraticaConstants;
import it.tref.liferay.portos.bo.shared.util.TipoSoggettoUtil; import it.tref.liferay.portos.bo.shared.util.TipoSoggettoUtil;
import it.tref.liferay.portos.bo.util.PraticaUtil; import it.tref.liferay.portos.bo.util.PraticaUtil;
@ -53,6 +50,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.liferay.counter.service.CounterLocalServiceUtil; 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.PortalException;
import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSONArray; 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.language.LanguageUtil;
import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil; 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.repository.model.FileEntry;
import com.liferay.portal.kernel.search.Document; import com.liferay.portal.kernel.search.Document;
import com.liferay.portal.kernel.search.Hits; 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.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil;
import com.liferay.util.bridges.mvc.MVCPortlet; import com.liferay.util.bridges.mvc.MVCPortlet;
/**
* Portlet implementation class FascicoloPortlet
*/
public class FascicoloPortlet extends MVCPortlet { public class FascicoloPortlet extends MVCPortlet {
private Log _log = LogFactoryUtil.getLog(FascicoloPortlet.class); private Log _log = LogFactoryUtil.getLog(FascicoloPortlet.class);
@ -108,11 +102,12 @@ public class FascicoloPortlet extends MVCPortlet {
} }
public void toggleWorkflow(ActionRequest actionRequest, ActionResponse actionResponse) { public void toggleWorkflow(ActionRequest actionRequest, ActionResponse actionResponse) {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
User user = themeDisplay.getUser(); User user = themeDisplay.getUser();
boolean attivare = ParamUtil.getBoolean(actionRequest, "avviare"); boolean attivare = ParamUtil.getBoolean(actionRequest, "avviare");
boolean sospendere = ParamUtil.getBoolean(actionRequest, "sospendere"); 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"); String stato_pratica = ParamUtil.getString(actionRequest, "seleziona_stato");
try { try {
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId); IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId);
@ -140,11 +135,10 @@ public class FascicoloPortlet extends MVCPortlet {
} }
if (!attivare) { if (!attivare) {
intPratica.setStatoPratica(stato_pratica); intPratica.setStatoPratica(stato_pratica);
IntPraticaLocalServiceUtil.updateStatoPratica(intPraticaId, 0, stato_pratica); IntPraticaLocalServiceUtil.updateStatoPratica(intPraticaId, stato_pratica);
} else { } else {
intPratica.setStatoPratica(StatoPraticaConstants.SOTTOPOSTA_A_PARERE); intPratica.setStatoPratica(StatoPraticaConstants.SOTTOPOSTA_A_PARERE);
IntPraticaLocalServiceUtil.updateStatoPratica(intPraticaId, 0, IntPraticaLocalServiceUtil.updateStatoPratica(intPraticaId, StatoPraticaConstants.SOTTOPOSTA_A_PARERE);
StatoPraticaConstants.SOTTOPOSTA_A_PARERE);
} }
IntPraticaLocalServiceUtil.reIndexFasciolo(intPraticaId, intPratica.getCompanyId()); IntPraticaLocalServiceUtil.reIndexFasciolo(intPraticaId, intPratica.getCompanyId());
} catch (Exception e) { } catch (Exception e) {
@ -155,6 +149,7 @@ public class FascicoloPortlet extends MVCPortlet {
private void addRowHistoryWorkflowAction(long intPraticaId, long dettPraticaId, long companyId, long groupId, private void addRowHistoryWorkflowAction(long intPraticaId, long dettPraticaId, long companyId, long groupId,
User user, boolean attivato) throws SystemException { User user, boolean attivato) throws SystemException {
HistoryWorkflowAction historyWorkflowAction = HistoryWorkflowActionLocalServiceUtil HistoryWorkflowAction historyWorkflowAction = HistoryWorkflowActionLocalServiceUtil
.createHistoryWorkflowAction(CounterLocalServiceUtil.increment(HistoryWorkflowAction.class.getName())); .createHistoryWorkflowAction(CounterLocalServiceUtil.increment(HistoryWorkflowAction.class.getName()));
historyWorkflowAction.setAttivato(attivato); historyWorkflowAction.setAttivato(attivato);
@ -170,7 +165,8 @@ public class FascicoloPortlet extends MVCPortlet {
} }
public void toggleSospensione(ActionRequest actionRequest, ActionResponse actionResponse) { 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"); boolean sospesa = ParamUtil.getBoolean(actionRequest, "sospesa");
try { try {
IntPraticaServiceUtil.sospendiPratica(intPraticaId, sospesa); IntPraticaServiceUtil.sospendiPratica(intPraticaId, sospesa);
@ -182,7 +178,8 @@ public class FascicoloPortlet extends MVCPortlet {
} }
public void cambiaStato(ActionRequest actionRequest, ActionResponse actionResponse) { 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"); String statoPratica = ParamUtil.getString(actionRequest, "nuovoStatoPratica");
_log.info("cambiaSospendiRiprendi: INTPRATICAID" + intPraticaId); _log.info("cambiaSospendiRiprendi: INTPRATICAID" + intPraticaId);
try { try {
@ -196,6 +193,7 @@ public class FascicoloPortlet extends MVCPortlet {
} }
public void aggiungiRichiestaParere(ActionRequest actionRequest, ActionResponse actionResponse) { public void aggiungiRichiestaParere(ActionRequest actionRequest, ActionResponse actionResponse) {
long geologoId = ParamUtil.getLong(actionRequest, "geologoId"); long geologoId = ParamUtil.getLong(actionRequest, "geologoId");
long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId"); long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId");
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId"); long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId");
@ -211,8 +209,9 @@ public class FascicoloPortlet extends MVCPortlet {
} }
public void cambiaTitolare(ActionRequest actionRequest, ActionResponse actionResponse) { public void cambiaTitolare(ActionRequest actionRequest, ActionResponse actionResponse) {
String nuovoSoggettoCF = ParamUtil.getString(actionRequest, "nuovoSoggettoCF"); 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"); long companyId = ParamUtil.getLong(actionRequest, "companyId");
try { try {
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
@ -237,6 +236,7 @@ public class FascicoloPortlet extends MVCPortlet {
} }
public void searchURL(ActionRequest actionRequest, ActionResponse actionResponse) { public void searchURL(ActionRequest actionRequest, ActionResponse actionResponse) {
String numeroProgetto = actionRequest.getParameter("numeroProgetto"); String numeroProgetto = actionRequest.getParameter("numeroProgetto");
String protocollo = actionRequest.getParameter("protocollo"); String protocollo = actionRequest.getParameter("protocollo");
String tipoPratica = actionRequest.getParameter("tipoPratica"); String tipoPratica = actionRequest.getParameter("tipoPratica");
@ -255,15 +255,15 @@ public class FascicoloPortlet extends MVCPortlet {
String indirizzo = actionRequest.getParameter("indirizzo"); String indirizzo = actionRequest.getParameter("indirizzo");
if (Validator.isNotNull(dataRichiestaInizio)) { if (Validator.isNotNull(dataRichiestaInizio)) {
String[] dataRichiestaInizioSplitted = dataRichiestaInizio.split(StringPool.FORWARD_SLASH); String[] dataRichiestaInizioSplitted = dataRichiestaInizio.split(StringPool.FORWARD_SLASH);
int month = Integer.valueOf(dataRichiestaInizioSplitted[1]) - 1;
actionResponse.setRenderParameter("dataRichiestaInizioDay", dataRichiestaInizioSplitted[0]); actionResponse.setRenderParameter("dataRichiestaInizioDay", dataRichiestaInizioSplitted[0]);
int month = Integer.valueOf(dataRichiestaInizioSplitted[1]) - 1;
actionResponse.setRenderParameter("dataRichiestaInizioMonth", String.valueOf(month)); actionResponse.setRenderParameter("dataRichiestaInizioMonth", String.valueOf(month));
actionResponse.setRenderParameter("dataRichiestaInizioYear", dataRichiestaInizioSplitted[2]); actionResponse.setRenderParameter("dataRichiestaInizioYear", dataRichiestaInizioSplitted[2]);
} }
if (Validator.isNotNull(dataRichiestaFine)) { if (Validator.isNotNull(dataRichiestaFine)) {
String[] dataRichiestaFineSplitted = dataRichiestaFine.split(StringPool.FORWARD_SLASH); String[] dataRichiestaFineSplitted = dataRichiestaFine.split(StringPool.FORWARD_SLASH);
int month = Integer.valueOf(dataRichiestaFineSplitted[1]) - 1;
actionResponse.setRenderParameter("dataRichiestaFineDay", dataRichiestaFineSplitted[0]); actionResponse.setRenderParameter("dataRichiestaFineDay", dataRichiestaFineSplitted[0]);
int month = Integer.valueOf(dataRichiestaFineSplitted[1]) - 1;
actionResponse.setRenderParameter("dataRichiestaFineMonth", String.valueOf(month)); actionResponse.setRenderParameter("dataRichiestaFineMonth", String.valueOf(month));
actionResponse.setRenderParameter("dataRichiestaFineYear", dataRichiestaFineSplitted[2]); actionResponse.setRenderParameter("dataRichiestaFineYear", dataRichiestaFineSplitted[2]);
} }
@ -306,12 +306,13 @@ public class FascicoloPortlet extends MVCPortlet {
actionResponse.setRenderParameter("ordinaTipo", ordinaTipo); actionResponse.setRenderParameter("ordinaTipo", ordinaTipo);
} }
public void versiona(ActionRequest actionRequest, ActionResponse actionResponse) { public void versiona(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId", 0);
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId", 0L);
long companyId = ParamUtil.getLong(actionRequest, "companyId"); long companyId = ParamUtil.getLong(actionRequest, "companyId");
try { try {
DettPraticaServiceUtil.sendToVersioning(dettPraticaId, companyId); DettPraticaServiceUtil.sendToVersioning(dettPraticaId, companyId);
} catch (Exception e) { } catch (PortalException | SystemException | IOException | NoSuchFieldException | SecurityException e) {
_log.error("error-versioning", e); _log.error("error-versioning", e);
SessionErrors.add(actionRequest, "error-versioning"); SessionErrors.add(actionRequest, "error-versioning");
} }
@ -368,40 +369,11 @@ public class FascicoloPortlet extends MVCPortlet {
resourceResponse.setContentType(ContentTypes.APPLICATION_ZIP); resourceResponse.setContentType(ContentTypes.APPLICATION_ZIP);
resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate"); resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate");
resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION, resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"" + file.getName() + "\""); "attachment; filename=\"" + file.getName() + StringPool.QUOTE);
resourceResponse.setContentLength(data.length); resourceResponse.setContentLength(data.length);
resourceResponse.getPortletOutputStream().write(data); resourceResponse.getPortletOutputStream().write(data);
resourceResponse.getPortletOutputStream().flush(); resourceResponse.getPortletOutputStream().flush();
resourceResponse.getPortletOutputStream().close(); 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)) { } else if ("comuni".equals(id)) {
String provinciaId = ParamUtil.getString(resourceRequest, "provinciaId"); String provinciaId = ParamUtil.getString(resourceRequest, "provinciaId");
JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
@ -447,11 +419,12 @@ public class FascicoloPortlet extends MVCPortlet {
} }
private String exportSearch(Locale locale, ResourceRequest resourceRequest, User user) { private String exportSearch(Locale locale, ResourceRequest resourceRequest, User user) {
String method = "exportSearch"; String method = "exportSearch";
HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(resourceRequest); HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(resourceRequest);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
List<IntPratica> lista = new ArrayList<IntPratica>(); 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()) { for (Document doc : hits.toList()) {
String intPraticaId = doc.get("intPraticaId"); String intPraticaId = doc.get("intPraticaId");
try { try {
@ -466,41 +439,43 @@ public class FascicoloPortlet extends MVCPortlet {
_log.error(method + " IntPraticaLocalServiceUtil.fetchIntPratica IntPraticaId: " + intPraticaId, e); _log.error(method + " IntPraticaLocalServiceUtil.fetchIntPratica IntPraticaId: " + intPraticaId, e);
} }
} }
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.sorteggiata"))); sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.sorteggiata")))
sb.append(StringPool.SEMICOLON); .append(StringPool.SEMICOLON)
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.pratica"))); .append(CSVUtil.encode(LanguageUtil
sb.append(StringPool.SEMICOLON); .get(getPortletConfig(), locale, "label.scadenzegeniocivile.pratica")))
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.titolare"))); .append(StringPool.SEMICOLON)
sb.append(StringPool.SEMICOLON); .append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale,
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.committenti"))); "label.scadenzegeniocivile.titolare")))
sb.append(StringPool.SEMICOLON); .append(StringPool.SEMICOLON)
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.istruttore"))); .append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale,
sb.append(StringPool.SEMICOLON); "label.scadenzegeniocivile.committenti")))
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.statoPratica"))); .append(StringPool.SEMICOLON)
sb.append(StringPool.SEMICOLON); .append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale,
// ADT BUG-ID=15 Sezione Ricerca / Export csv "label.scadenzegeniocivile.istruttore")))
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.provincia"))); .append(StringPool.SEMICOLON)
sb.append(StringPool.SEMICOLON); .append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale,
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.comune"))); "label.scadenzegeniocivile.statoPratica")))
sb.append(StringPool.SEMICOLON); .append(StringPool.SEMICOLON)
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, .append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale,
"label.scadenzegeniocivile.descrizioneIntervento"))); "label.scadenzegeniocivile.provincia")))
sb.append(StringPool.SEMICOLON); .append(StringPool.SEMICOLON)
sb.append(StringPool.NEW_LINE); .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) { for (IntPratica intPratica : lista) {
try { try {
DettPratica lastDettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(intPratica long intPraticaId = intPratica.getIntPraticaId();
.getIntPraticaId()); DettPratica lastDettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(intPraticaId);
Territorio territorio = TerritorioLocalServiceUtil.fetchTerritorio(intPratica.getTerritorioId()); Territorio territorio = TerritorioLocalServiceUtil.fetchTerritorio(intPratica.getTerritorioId());
Comune comune = ComuneLocalServiceUtil.fetchComune(territorio.getComuneId()); Comune comune = ComuneLocalServiceUtil.fetchComune(territorio.getComuneId());
Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(), Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(),
territorio.getCodiceProvincia()); territorio.getCodiceProvincia());
boolean sorteggiata = SorteggioLocalServiceUtil.findByIntPratica(intPratica.getIntPraticaId()) != null; boolean sorteggiata = SorteggioLocalServiceUtil.findByIntPratica(intPratica.getIntPraticaId()) != null;
sb.append(CSVUtil.encode((sorteggiata) ? "Si" : "No")); sb.append(CSVUtil.encode((sorteggiata) ? "Sì" : "No")).append(StringPool.SEMICOLON);
sb.append(StringPool.SEMICOLON);
String praticaLabel = intPratica.getTitle(locale, true); String praticaLabel = intPratica.getTitle(locale, true);
sb.append(CSVUtil.encode(praticaLabel)); sb.append(CSVUtil.encode(praticaLabel)).append(StringPool.SEMICOLON);
sb.append(StringPool.SEMICOLON);
List<Soggetto> titolari = SoggettoLocalServiceUtil.getValidByIntPratica_CodiceFiscale( List<Soggetto> titolari = SoggettoLocalServiceUtil.getValidByIntPratica_CodiceFiscale(
lastDettPratica.getIntPraticaId(), lastDettPratica.getCodiceFiscaleDelegatoCommittente()); lastDettPratica.getIntPraticaId(), lastDettPratica.getCodiceFiscaleDelegatoCommittente());
Soggetto titolare = null; Soggetto titolare = null;
@ -515,21 +490,20 @@ public class FascicoloPortlet extends MVCPortlet {
List<Soggetto> committenti = SoggettoLocalServiceUtil.findByIntPratica_TipologiaSoggetto( List<Soggetto> committenti = SoggettoLocalServiceUtil.findByIntPratica_TipologiaSoggetto(
lastDettPratica.getIntPraticaId(), TipoSoggettoUtil.COMMITTENTE); lastDettPratica.getIntPraticaId(), TipoSoggettoUtil.COMMITTENTE);
for (Soggetto committente : committenti) { for (Soggetto committente : committenti) {
builder.append(committente.getTitle() + " - " + committente.getCodiceFiscale()).append( builder.append(committente.getTitle()).append(" - ").append(committente.getCodiceFiscale())
StringPool.COMMA_AND_SPACE); .append(StringPool.COMMA_AND_SPACE);
} }
if (builder.length() > 0) if (builder.length() > 0)
builder.setLength(builder.length() - 12); builder.setLength(builder.length() - 12);
sb.append(builder.toString()); sb.append(builder.toString()).append(StringPool.SEMICOLON);
sb.append(StringPool.SEMICOLON);
User istruttore = UserLocalServiceUtil.fetchUser(intPratica.getStatusByUserId()); User istruttore = UserLocalServiceUtil.fetchUser(intPratica.getStatusByUserId());
if (istruttore != null) { if (istruttore != null) {
sb.append(istruttore.getFullName()); sb.append(istruttore.getFullName());
} }
sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON)
sb.append(LanguageUtil.get(locale, .append(LanguageUtil.get(locale,
PraticaUtil.getStatoPraticaLabel(intPratica.getStatoPratica(), intPratica))); PraticaUtil.getStatoPraticaLabel(intPratica.getStatoPratica(), intPratica)))
sb.append(StringPool.SEMICOLON); .append(StringPool.SEMICOLON);
// ADT BUG-ID=15 Sezione Ricerca / Export csv // ADT BUG-ID=15 Sezione Ricerca / Export csv
if (Validator.isNotNull(provincia)) { if (Validator.isNotNull(provincia)) {
sb.append(provincia.getProvincia()); sb.append(provincia.getProvincia());
@ -548,7 +522,8 @@ public class FascicoloPortlet extends MVCPortlet {
} }
sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON);
} catch (Throwable e) { } catch (Throwable e) {
_log.error(method + " IntPraticaId: " + intPratica != null ? intPratica.getIntPraticaId() : "", e); _log.error(method + " IntPraticaId: " + intPratica != null ? intPratica.getIntPraticaId()
: StringPool.BLANK, e);
} finally { } finally {
sb.append(StringPool.NEW_LINE); 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); GetterUtil.getInteger(PropsUtil.get(PropsKeys.INDEX_FILTER_SEARCH_LIMIT)), isExport);
try { try {
for (Document doc : hits.toList()) { for (Document doc : hits.toList()) {
String intPraticaId = doc.get("intPraticaId"); String intPraticaId = doc.get("intPraticaId");
if (Validator.isNotNull(intPraticaId)) { if (Validator.isNotNull(intPraticaId)) {
IntPratica intPratica = IntPraticaLocalServiceUtil
IntPratica intPratica; .fetchIntPratica(GetterUtil.getLong(intPraticaId));
intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(GetterUtil.getLong(intPraticaId));
if (Validator.isNotNull(intPratica)) { if (Validator.isNotNull(intPratica)) {
lista.add(intPratica); lista.add(intPratica);
} }
} }
} }
} catch (PortalException | SystemException e) { } catch (PortalException | SystemException e) {
throw new IOException(e); throw new IOException(e);
} }
if (isExport && Validator.isNotNull(lista) && !lista.isEmpty()) { if (isExport && Validator.isNotNull(lista) && !lista.isEmpty()) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (String columnName : FIELD_NAMES) { for (String columnName : FIELD_NAMES) {
sb.append(columnName); sb.append(columnName).append(StringPool.SEMICOLON);
sb.append(StringPool.SEMICOLON);
} }
sb.append(CharPool.NEW_LINE); sb.append(CharPool.NEW_LINE).append(CharPool.NEW_LINE);
sb.append(CharPool.NEW_LINE);
for (IntPratica pratica : lista) { for (IntPratica pratica : lista) {
try { try {
DettPratica lastDettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(pratica DettPratica lastDettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(pratica
@ -175,31 +167,22 @@ public class GestioneAttivitaIstruttorePortlet extends MVCPortlet {
if (collaudatori != null && !collaudatori.isEmpty()) { if (collaudatori != null && !collaudatori.isEmpty()) {
collaudoPrevisto = true; collaudoPrevisto = true;
} }
sb.append(pratica.getTipoPratica()); sb.append(pratica.getTipoPratica()).append(StringPool.SEMICOLON)
sb.append(StringPool.SEMICOLON); .append(pratica.getNumeroProgetto()).append(StringPool.SEMICOLON);
sb.append(pratica.getNumeroProgetto());
sb.append(StringPool.SEMICOLON);
if (Validator.isNotNull(pratica.getDtPratica())) { if (Validator.isNotNull(pratica.getDtPratica())) {
sb.append(sdf.format(pratica.getDtPratica())); sb.append(sdf.format(pratica.getDtPratica()));
} }
sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON).append(comune.getDenominazione()).append(StringPool.SEMICOLON)
sb.append(comune.getDenominazione()); .append(provincia.getProvincia()).append(StringPool.SEMICOLON)
sb.append(StringPool.SEMICOLON); .append(pratica.getStatoPratica()).append(StringPool.SEMICOLON);
sb.append(provincia.getProvincia());
sb.append(StringPool.SEMICOLON);
sb.append(pratica.getStatoPratica());
sb.append(StringPool.SEMICOLON);
for (Soggetto soggetto : committenti) { for (Soggetto soggetto : committenti) {
// ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV // ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV
// sb.append(soggetto.getCodiceFiscale().toUpperCase()); sb.append(soggetto.getDescrizioneCompleta().toUpperCase()).append(StringPool.SPACE);
sb.append(soggetto.getDescrizioneCompleta().toUpperCase());
sb.append(StringPool.SPACE);
} }
sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON);
for (Soggetto soggetto : direttoreLavori) { for (Soggetto soggetto : direttoreLavori) {
// ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV // ADT BUG-ID=16 Sezione Pratiche Assegnate / Export CSV
sb.append(soggetto.getDescrizioneCompleta().toUpperCase()); sb.append(soggetto.getDescrizioneCompleta().toUpperCase()).append(StringPool.SPACE);
sb.append(StringPool.SPACE);
} }
sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON);
if (Validator.isNotNull(lastDettPratica)) { if (Validator.isNotNull(lastDettPratica)) {
@ -278,13 +261,11 @@ public class GestioneAttivitaIstruttorePortlet extends MVCPortlet {
JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
jsonObject.put("comuneId", comune.getComuneId()); jsonObject.put("comuneId", comune.getComuneId());
jsonObject.put("descLong", comune.getDenominazione()); jsonObject.put("descLong", comune.getDenominazione());
jsonArray.put(jsonObject); jsonArray.put(jsonObject);
} }
writeJSON(resourceRequest, resourceResponse, jsonArray); writeJSON(resourceRequest, resourceResponse, jsonArray);
} }
} } catch (Exception e) {
catch (Exception e) {
e.printStackTrace(); 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.portal.workflow.kaleo.service.KaleoTaskInstanceTokenLocalServiceUtil;
import com.liferay.util.bridges.mvc.MVCPortlet; import com.liferay.util.bridges.mvc.MVCPortlet;
/**
* Portlet implementation class HomeBOPortlet
*/
public class HomeBOPortlet extends MVCPortlet { public class HomeBOPortlet extends MVCPortlet {
private static final Log _log = LogFactoryUtil.getLog(HomeBOPortlet.class); private static final Log _log = LogFactoryUtil.getLog(HomeBOPortlet.class);
@Override @Override
public void render(RenderRequest renderRequest, RenderResponse renderResponse) public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException {
throws PortletException, IOException {
ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
try { try {
int countPraticheScaduteAutorizzazione = TempisticaLocalServiceUtil.countPraticheScaduteAutorizzazione( int countPraticheScaduteAutorizzazione = TempisticaLocalServiceUtil.countPraticheScaduteAutorizzazione(
themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId()); themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId());
int countPraticheScaduteSorteggiate = TempisticaLocalServiceUtil.countPraticheScaduteSorteggiate( int countPraticheScaduteSorteggiate = TempisticaLocalServiceUtil.countPraticheScaduteSorteggiate(
themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId()); themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId());
int countPraticheScaduteControlloObbligatorio = TempisticaLocalServiceUtil
int countPraticheScaduteControlloObbligatorio = TempisticaLocalServiceUtil.countPraticheScaduteControlloObbligatorio( .countPraticheScaduteControlloObbligatorio(themeDisplay.getCompanyId(),
themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId()); themeDisplay.getScopeGroupId());
int countPraticheInScadenzaAutorizzazioni = TempisticaLocalServiceUtil
.countPraticheInScadenzaAutorizzazioni(themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId());
int countPraticheInScadenzaAutorizzazioni = TempisticaLocalServiceUtil.countPraticheInScadenzaAutorizzazioni(
themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId());
int countPraticheInScadenzaSorteggiate = TempisticaLocalServiceUtil.countPraticheInScadenzaSorteggiate( int countPraticheInScadenzaSorteggiate = TempisticaLocalServiceUtil.countPraticheInScadenzaSorteggiate(
themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId()); themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId());
int countPraticheInScadenzaControlloObbligatorio = TempisticaLocalServiceUtil
int countPraticheInScadenzaControlloObbligatorio = TempisticaLocalServiceUtil.countPraticheInScadenzaControlloObbligatorio( .countPraticheInScadenzaControlloObbligatorio(themeDisplay.getCompanyId(),
themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId()); themeDisplay.getScopeGroupId());
renderRequest.setAttribute("countPraticheScaduteAutorizzazione", countPraticheScaduteAutorizzazione); renderRequest.setAttribute("countPraticheScaduteAutorizzazione", countPraticheScaduteAutorizzazione);
renderRequest.setAttribute("countPraticheScaduteSorteggiate", countPraticheScaduteSorteggiate); renderRequest.setAttribute("countPraticheScaduteSorteggiate", countPraticheScaduteSorteggiate);
renderRequest.setAttribute("countPraticheScaduteControlloObbligatorio", countPraticheScaduteControlloObbligatorio); renderRequest.setAttribute("countPraticheScaduteControlloObbligatorio",
countPraticheScaduteControlloObbligatorio);
renderRequest.setAttribute("countPraticheInScadenzaAutorizzazioni", countPraticheInScadenzaAutorizzazioni); renderRequest.setAttribute("countPraticheInScadenzaAutorizzazioni", countPraticheInScadenzaAutorizzazioni);
renderRequest.setAttribute("countPraticheInScadenzaSorteggiate", countPraticheInScadenzaSorteggiate); renderRequest.setAttribute("countPraticheInScadenzaSorteggiate", countPraticheInScadenzaSorteggiate);
renderRequest.setAttribute("countPraticheInScadenzaControlloObbligatorio", countPraticheInScadenzaControlloObbligatorio); renderRequest.setAttribute("countPraticheInScadenzaControlloObbligatorio",
countPraticheInScadenzaControlloObbligatorio);
ClassLoader classLoader = (ClassLoader) PortletBeanLocatorUtil.locate(
ClassLoader classLoader = com.liferay.portal.workflow.kaleo.service.ClpSerializer.getServletContextName(),
(ClassLoader) PortletBeanLocatorUtil.locate(com.liferay.portal.workflow.kaleo.service.ClpSerializer.getServletContextName(), "portletClassLoader"); "portletClassLoader");
List<Long> praticheAttiveAutorizzazioni = TempisticaLocalServiceUtil.praticheAttiveAutorizzazioni( List<Long> praticheAttiveAutorizzazioni = TempisticaLocalServiceUtil.praticheAttiveAutorizzazioni(
themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId()); themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId());
int countAutorizzazioniDaAssegnare = 0; int countAutorizzazioniDaAssegnare = 0;
int countAutorizzazioniOrdinarie = 0; int countAutorizzazioniOrdinarie = 0;
for (Long intPraticaId : praticheAttiveAutorizzazioni) { for (Long intPraticaId : praticheAttiveAutorizzazioni) {
DynamicQuery query = DynamicQueryFactoryUtil.forClass(ControlloPratica.class); DynamicQuery query = DynamicQueryFactoryUtil.forClass(ControlloPratica.class);
query.add(RestrictionsFactoryUtil.eq("intPraticaId", intPraticaId)); query.add(RestrictionsFactoryUtil.eq("intPraticaId", intPraticaId));
List<ControlloPratica> lista = ControlloPraticaLocalServiceUtil.dynamicQuery(query); List<ControlloPratica> lista = ControlloPraticaLocalServiceUtil.dynamicQuery(query);
if (lista != null && !lista.isEmpty()) { if (lista != null && !lista.isEmpty()) {
ControlloPratica controlloPratica = lista.get(0); ControlloPratica controlloPratica = lista.get(0);
if (controlloPratica != null) { if (controlloPratica != null) {
DynamicQuery queryKaleo = DynamicQueryFactoryUtil.forClass(KaleoTaskInstanceToken.class,
DynamicQuery queryKaleo = DynamicQueryFactoryUtil.forClass(KaleoTaskInstanceToken.class,classLoader); classLoader);
queryKaleo.add(RestrictionsFactoryUtil.eq("classPK", controlloPratica.getControlloPraticaId())); queryKaleo.add(RestrictionsFactoryUtil.eq("classPK", controlloPratica.getControlloPraticaId()));
queryKaleo.add(RestrictionsFactoryUtil.eq("kaleoTaskName", "Assegnazione")); queryKaleo.add(RestrictionsFactoryUtil.eq("kaleoTaskName", "Assegnazione"));
queryKaleo.add(RestrictionsFactoryUtil.eq("completed", false)); queryKaleo.add(RestrictionsFactoryUtil.eq("completed", false));
List<KaleoTaskInstanceToken> listaKaleo = KaleoTaskInstanceTokenLocalServiceUtil
List<KaleoTaskInstanceToken> listaKaleo = KaleoTaskInstanceTokenLocalServiceUtil.dynamicQuery(queryKaleo); .dynamicQuery(queryKaleo);
if (listaKaleo != null && !listaKaleo.isEmpty()) { if (listaKaleo != null && !listaKaleo.isEmpty()) {
countAutorizzazioniDaAssegnare++; countAutorizzazioniDaAssegnare++;
} else { } else {
@ -103,34 +84,26 @@ public class HomeBOPortlet extends MVCPortlet {
} }
} }
} }
renderRequest.setAttribute("countAutorizzazioniDaAssegnare", countAutorizzazioniDaAssegnare); renderRequest.setAttribute("countAutorizzazioniDaAssegnare", countAutorizzazioniDaAssegnare);
renderRequest.setAttribute("countAutorizzazioniOrdinarie", countAutorizzazioniOrdinarie); renderRequest.setAttribute("countAutorizzazioniOrdinarie", countAutorizzazioniOrdinarie);
List<Long> praticheAttiveSorteggiate = TempisticaLocalServiceUtil.praticheAttiveSorteggiate( List<Long> praticheAttiveSorteggiate = TempisticaLocalServiceUtil.praticheAttiveSorteggiate(
themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId()); themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId());
int countSorteggiateDaAssegnare = 0; int countSorteggiateDaAssegnare = 0;
int countSorteggiateOrdinarie = 0; int countSorteggiateOrdinarie = 0;
for (Long intPraticaId : praticheAttiveSorteggiate) { for (Long intPraticaId : praticheAttiveSorteggiate) {
DynamicQuery query = DynamicQueryFactoryUtil.forClass(ControlloPratica.class); DynamicQuery query = DynamicQueryFactoryUtil.forClass(ControlloPratica.class);
query.add(RestrictionsFactoryUtil.eq("intPraticaId", intPraticaId)); query.add(RestrictionsFactoryUtil.eq("intPraticaId", intPraticaId));
List<ControlloPratica> lista = ControlloPraticaLocalServiceUtil.dynamicQuery(query); List<ControlloPratica> lista = ControlloPraticaLocalServiceUtil.dynamicQuery(query);
if (lista != null && !lista.isEmpty()) { if (lista != null && !lista.isEmpty()) {
ControlloPratica controlloPratica = lista.get(0); ControlloPratica controlloPratica = lista.get(0);
if (controlloPratica != null) { if (controlloPratica != null) {
DynamicQuery queryKaleo = DynamicQueryFactoryUtil.forClass(KaleoTaskInstanceToken.class,
DynamicQuery queryKaleo = DynamicQueryFactoryUtil.forClass(KaleoTaskInstanceToken.class,classLoader); classLoader);
queryKaleo.add(RestrictionsFactoryUtil.eq("classPK", controlloPratica.getControlloPraticaId())); queryKaleo.add(RestrictionsFactoryUtil.eq("classPK", controlloPratica.getControlloPraticaId()));
queryKaleo.add(RestrictionsFactoryUtil.eq("kaleoTaskName", "Assegnazione")); queryKaleo.add(RestrictionsFactoryUtil.eq("kaleoTaskName", "Assegnazione"));
queryKaleo.add(RestrictionsFactoryUtil.eq("completed", false)); queryKaleo.add(RestrictionsFactoryUtil.eq("completed", false));
List<KaleoTaskInstanceToken> listaKaleo = KaleoTaskInstanceTokenLocalServiceUtil
List<KaleoTaskInstanceToken> listaKaleo = KaleoTaskInstanceTokenLocalServiceUtil.dynamicQuery(queryKaleo); .dynamicQuery(queryKaleo);
if (listaKaleo != null && !listaKaleo.isEmpty()) { if (listaKaleo != null && !listaKaleo.isEmpty()) {
countSorteggiateDaAssegnare++; countSorteggiateDaAssegnare++;
} else { } else {
@ -139,54 +112,40 @@ public class HomeBOPortlet extends MVCPortlet {
} }
} }
} }
renderRequest.setAttribute("countSorteggiateDaAssegnare", countSorteggiateDaAssegnare); renderRequest.setAttribute("countSorteggiateDaAssegnare", countSorteggiateDaAssegnare);
renderRequest.setAttribute("countSorteggiateOrdinarie", countSorteggiateOrdinarie); renderRequest.setAttribute("countSorteggiateOrdinarie", countSorteggiateOrdinarie);
List<Long> praticheAttiveControlloObbligatorio = TempisticaLocalServiceUtil
List<Long> praticheAttiveControlloObbligatorio = TempisticaLocalServiceUtil.praticheAttiveControlloObbligatorio( .praticheAttiveControlloObbligatorio(themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId());
themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId());
int countControlloObbligatorioDaAssegnare = 0; int countControlloObbligatorioDaAssegnare = 0;
int countControlloObbligatorioOrdinarie = 0; int countControlloObbligatorioOrdinarie = 0;
for (Long intPraticaId : praticheAttiveControlloObbligatorio) { for (Long intPraticaId : praticheAttiveControlloObbligatorio) {
DynamicQuery query = DynamicQueryFactoryUtil.forClass(ControlloPratica.class); DynamicQuery query = DynamicQueryFactoryUtil.forClass(ControlloPratica.class);
query.add(RestrictionsFactoryUtil.eq("intPraticaId", intPraticaId)); query.add(RestrictionsFactoryUtil.eq("intPraticaId", intPraticaId));
List<ControlloPratica> lista = ControlloPraticaLocalServiceUtil.dynamicQuery(query); List<ControlloPratica> lista = ControlloPraticaLocalServiceUtil.dynamicQuery(query);
if (lista != null && !lista.isEmpty()) { if (lista != null && !lista.isEmpty()) {
ControlloPratica controlloPratica = lista.get(0); ControlloPratica controlloPratica = lista.get(0);
if (controlloPratica != null) { if (controlloPratica != null) {
DynamicQuery queryKaleo = DynamicQueryFactoryUtil.forClass(KaleoTaskInstanceToken.class,
DynamicQuery queryKaleo = DynamicQueryFactoryUtil.forClass(KaleoTaskInstanceToken.class,classLoader); classLoader);
queryKaleo.add(RestrictionsFactoryUtil.eq("classPK", controlloPratica.getControlloPraticaId())); queryKaleo.add(RestrictionsFactoryUtil.eq("classPK", controlloPratica.getControlloPraticaId()));
queryKaleo.add(RestrictionsFactoryUtil.eq("className", ControlloPratica.class.getName())); queryKaleo.add(RestrictionsFactoryUtil.eq("className", ControlloPratica.class.getName()));
queryKaleo.add(RestrictionsFactoryUtil.eq("kaleoTaskName", "Assegnazione")); queryKaleo.add(RestrictionsFactoryUtil.eq("kaleoTaskName", "Assegnazione"));
queryKaleo.add(RestrictionsFactoryUtil.eq("completed", false)); queryKaleo.add(RestrictionsFactoryUtil.eq("completed", false));
List<KaleoTaskInstanceToken> listaKaleo = KaleoTaskInstanceTokenLocalServiceUtil
List<KaleoTaskInstanceToken> listaKaleo = KaleoTaskInstanceTokenLocalServiceUtil.dynamicQuery(queryKaleo); .dynamicQuery(queryKaleo);
if (listaKaleo != null && !listaKaleo.isEmpty()) { if (listaKaleo != null && !listaKaleo.isEmpty()) {
countControlloObbligatorioDaAssegnare++; countControlloObbligatorioDaAssegnare++;
} else { } else {
countControlloObbligatorioOrdinarie++; countControlloObbligatorioOrdinarie++;
} }
} }
} }
} }
renderRequest.setAttribute("countControlloObbligatorioDaAssegnare", countControlloObbligatorioDaAssegnare); renderRequest.setAttribute("countControlloObbligatorioDaAssegnare", countControlloObbligatorioDaAssegnare);
renderRequest.setAttribute("countControlloObbligatorioOrdinarie", countControlloObbligatorioOrdinarie); renderRequest.setAttribute("countControlloObbligatorioOrdinarie", countControlloObbligatorioOrdinarie);
} catch (SystemException e) { } catch (SystemException e) {
_log.error(e, e); _log.error(e, e);
} }
super.render(renderRequest, renderResponse); 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.portal.kernel.util.StringPool;
import com.liferay.util.bridges.mvc.MVCPortlet; import com.liferay.util.bridges.mvc.MVCPortlet;
/**
* Portlet implementation class RicercaProtocolloPortlet
*/
public class RicercaProtocolloPortlet extends MVCPortlet { public class RicercaProtocolloPortlet extends MVCPortlet {
public void search(ActionRequest actionRequest, ActionResponse actionResponse) { public void search(ActionRequest actionRequest, ActionResponse actionResponse) {
String dataDa = ParamUtil.getString(actionRequest, "dataDa", StringPool.BLANK); String dataDa = ParamUtil.getString(actionRequest, "dataDa", StringPool.BLANK);
String dataA = ParamUtil.getString(actionRequest, "dataA", StringPool.BLANK); String dataA = ParamUtil.getString(actionRequest, "dataA", StringPool.BLANK);
String numeroProtocollo = ParamUtil.getString(actionRequest, "numeroProtocollo", StringPool.BLANK); String numeroProtocollo = ParamUtil.getString(actionRequest, "numeroProtocollo", StringPool.BLANK);
actionResponse.setRenderParameter("dataDa", dataDa); actionResponse.setRenderParameter("dataDa", dataDa);
actionResponse.setRenderParameter("dataA", dataA); actionResponse.setRenderParameter("dataA", dataA);
actionResponse.setRenderParameter("numeroProtocollo", numeroProtocollo); 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.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.ParamUtil; 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.Validator;
import com.liferay.portal.kernel.util.WebKeys; import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.service.ServiceContext; import com.liferay.portal.service.ServiceContext;
@ -35,30 +36,28 @@ public class SismicaAdministrationPortlet extends MVCPortlet {
private static final Log _log = LogFactoryUtil.getLog(SismicaAdministrationPortlet.class); private static final Log _log = LogFactoryUtil.getLog(SismicaAdministrationPortlet.class);
public void mostraConfigurazione(ActionRequest actionRequest, ActionResponse actionResponse) public void mostraConfigurazione(ActionRequest actionRequest, ActionResponse actionResponse) throws SystemException {
throws SystemException {
List<String> esito = new ArrayList<String>(); List<String> esito = new ArrayList<String>();
esito.add("<h3>Env</h3>"); esito.add("<h3>Env</h3>");
for (Map.Entry<String, String> entry : System.getenv().entrySet()) { 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>"); esito.add("<h3>Properties</h3>");
for (Map.Entry<Object, Object> entry : System.getProperties().entrySet()) { 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()])); actionResponse.setRenderParameter("esito", esito.toArray(new String[esito.size()]));
} }
public void generaDocumenti(ActionRequest actionRequest, ActionResponse actionResponse) { 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<>(); List<String> esito = new ArrayList<>();
try { // try {
esito = SismicaUtil.fixInvio(td.getCompanyId()); // } catch (PortalException | SystemException e) {
} catch (PortalException | SystemException e) { // esito.add("Errore durante l'invio " + e.getMessage());
esito.add("Errore durante l'invio " + e.getMessage()); // }
}
actionResponse.setRenderParameter("esito", esito.toArray(new String[esito.size()])); 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()])); actionResponse.setRenderParameter("esito", esito.toArray(new String[esito.size()]));
} }
public void reIndexFasciolo(ActionRequest actionRequest, ActionResponse actionResponse) public void reIndexFasciolo(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException,
throws PortalException, SystemException { SystemException {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); 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()])); actionResponse.setRenderParameter("esito", esito.toArray(new String[esito.size()]));
} }
public void inviaAvviso(ActionRequest actionRequest, ActionResponse actionResponse) public void inviaAvviso(ActionRequest actionRequest, ActionResponse actionResponse) throws SystemException {
throws SystemException {
SismicaUtil.inviaAvviso(actionRequest, actionResponse); 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.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil;
import com.liferay.util.bridges.mvc.MVCPortlet; import com.liferay.util.bridges.mvc.MVCPortlet;
/**
* Portlet implementation class SorteggioGenioCivilePortlet
*/
public class SorteggioPortlet extends MVCPortlet { public class SorteggioPortlet extends MVCPortlet {
private final static Log _log = LogFactoryUtil.getLog(SorteggioPortlet.class); private final static Log _log = LogFactoryUtil.getLog(SorteggioPortlet.class);
@ -29,26 +26,17 @@ public class SorteggioPortlet extends MVCPortlet {
PortletException { PortletException {
String resourceID = resourceRequest.getResourceID(); String resourceID = resourceRequest.getResourceID();
if ("downloadReport".equals(resourceID)) { if ("downloadReport".equals(resourceID)) {
long fileEntryId = ParamUtil.getLong(resourceRequest, "fileEntryId"); long fileEntryId = ParamUtil.getLong(resourceRequest, "fileEntryId");
try { try {
FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(fileEntryId); FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(fileEntryId);
String fileName = fileEntry.getTitle() + StringPool.PERIOD + fileEntry.getExtension(); String fileName = fileEntry.getTitle() + StringPool.PERIOD + fileEntry.getExtension();
byte[] data = byte[] data = FileUtil.getBytes(DLFileEntryLocalServiceUtil.getFileAsStream(fileEntry.getUserId(),
FileUtil.getBytes(DLFileEntryLocalServiceUtil.getFileAsStream(fileEntry.getUserId(), fileEntryId, fileEntryId, fileEntry.getVersion(), false));
fileEntry.getVersion(), false));
resourceResponse.setContentType(fileEntry.getMimeType()); resourceResponse.setContentType(fileEntry.getMimeType());
resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate"); resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate");
resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION, "filename=\"" + fileName + "\""); resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION, "filename=\"" + fileName + "\"");
resourceResponse.setContentLength(data.length); resourceResponse.setContentLength(data.length);
resourceResponse.getPortletOutputStream().write(data); resourceResponse.getPortletOutputStream().write(data);
resourceResponse.getPortletOutputStream().flush(); resourceResponse.getPortletOutputStream().flush();
resourceResponse.getPortletOutputStream().close(); resourceResponse.getPortletOutputStream().close();
@ -56,10 +44,8 @@ public class SorteggioPortlet extends MVCPortlet {
_log.error(e, e); _log.error(e, e);
throw new IOException(e); throw new IOException(e);
} }
} else { } else {
super.serveResource(resourceRequest, resourceResponse); 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.ConfigurazioneLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants; import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants;
import java.io.File;
import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.FileUtils;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntityBuilder; 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.MessageListener;
import com.liferay.portal.kernel.messaging.MessageListenerException; import com.liferay.portal.kernel.messaging.MessageListenerException;
import com.liferay.portal.kernel.util.FileUtil; 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.StringPool;
import com.liferay.portal.kernel.util.UniqueList; import com.liferay.portal.kernel.util.UniqueList;
import com.liferay.portal.kernel.workflow.WorkflowConstants; import com.liferay.portal.kernel.workflow.WorkflowConstants;
@ -52,36 +49,30 @@ public class SchedulerEstrazioneFirme implements MessageListener {
private static final Lock lock = new ReentrantLock(); private static final Lock lock = new ReentrantLock();
@Override
public void receive(Message message) throws MessageListenerException { public void receive(Message message) throws MessageListenerException {
if (lock.tryLock()) { if (lock.tryLock()) {
try { try {
for (Company company : CompanyLocalServiceUtil.getCompanies()) { for (Company company : CompanyLocalServiceUtil.getCompanies()) {
// campo abilitazione scheduler // campo abilitazione scheduler
// TODO creare la configurazione aggiuntiva per lo scheduler // TODO creare la configurazione aggiuntiva per lo scheduler estrazione firme
// estrazione firme boolean condition = Boolean.parseBoolean(ConfigurazioneLocalServiceUtil.findByC_ChiaveString(
boolean condition = Boolean.parseBoolean(ConfigurazioneLocalServiceUtil company.getCompanyId(), ConfigurazioneConstants.SCHEDULER_FIRMA_DOCUMENTO));
.findByC_ChiaveString(company.getCompanyId(),
ConfigurazioneConstants.SCHEDULER_FIRMA_DOCUMENTO));
if (condition) { if (condition) {
List<DocPratica> docPratiche = DocPraticaLocalServiceUtil.findByStaus( List<DocPratica> docPratiche = DocPraticaLocalServiceUtil.findByStaus(
WorkflowConstants.STATUS_PENDING, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); WorkflowConstants.STATUS_PENDING, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
String urlPdfExtractor = (String) company.getExpandoBridge().getAttribute("url_pdf_extractor",
String urlPdfExtractor = (String) company.getExpandoBridge().getAttribute( false);
"url_pdf_extractor", false);
for (DocPratica docPratica : docPratiche) { for (DocPratica docPratica : docPratiche) {
DLFileEntry fileEntry = DLFileEntryLocalServiceUtil.getFileEntry(docPratica DLFileEntry fileEntry = DLFileEntryLocalServiceUtil.getFileEntry(docPratica
.getDlFileEntryId()); .getDlFileEntryId());
User user = UserLocalServiceUtil.getRoleUsers( User user = UserLocalServiceUtil.getRoleUsers(
RoleLocalServiceUtil.getRole(docPratica.getCompanyId(), RoleLocalServiceUtil
RoleConstants.ADMINISTRATOR).getRoleId()).get(0); .getRole(docPratica.getCompanyId(), RoleConstants.ADMINISTRATOR)
PermissionThreadLocal.setPermissionChecker(PermissionCheckerFactoryUtil .getRoleId()).get(0);
.create(user)); PermissionThreadLocal.setPermissionChecker(PermissionCheckerFactoryUtil.create(user));
byte[] fileBytes = FileUtil.getBytes(fileEntry.getContentStream()); byte[] fileBytes = FileUtil.getBytes(fileEntry.getContentStream());
MultipartEntityBuilder builder = MultipartEntityBuilder.create(); MultipartEntityBuilder builder = MultipartEntityBuilder.create();
ContentBody body = new ByteArrayBody(fileBytes, fileEntry.getTitle()); ContentBody body = new ByteArrayBody(fileBytes, fileEntry.getTitle());
builder.addPart("file", body); builder.addPart("file", body);
@ -89,31 +80,23 @@ public class SchedulerEstrazioneFirme implements MessageListener {
request.setEntity(builder.build()); request.setEntity(builder.build());
CloseableHttpClient client = HttpClientBuilder.create().build(); CloseableHttpClient client = HttpClientBuilder.create().build();
HttpResponse response = client.execute(request); HttpResponse response = client.execute(request);
int statusCode = response.getStatusLine().getStatusCode(); int statusCode = response.getStatusLine().getStatusCode();
String responseBody = EntityUtils.toString(response.getEntity(), StringPool.UTF8); String responseBody = EntityUtils.toString(response.getEntity(), StringPool.UTF8);
if (statusCode == HttpServletResponse.SC_OK if (statusCode == HttpServletResponse.SC_OK || statusCode == HttpServletResponse.SC_CREATED) {
|| statusCode == HttpServletResponse.SC_CREATED) {
JSONArray arrayFirme = JSONFactoryUtil.createJSONObject(responseBody) JSONArray arrayFirme = JSONFactoryUtil.createJSONObject(responseBody)
.getJSONArray("cf"); .getJSONArray("cf");
List<String> cf = new UniqueList<String>(); List<String> cf = new UniqueList<String>();
for (int i = 0; i < arrayFirme.length(); i++) { for (int i = 0; i < arrayFirme.length(); i++) {
cf.add(arrayFirme.getString(i)); cf.add(arrayFirme.getString(i));
} }
DocPraticaLocalServiceUtil.addFirmeAndApprova(docPratica.getDocPraticaId(), DocPraticaLocalServiceUtil.addFirmeAndApprova(docPratica.getDocPraticaId(), cf);
cf);
_log.info("risposta ws " + responseBody + " numero firme " + cf.size()); _log.info("risposta ws " + responseBody + " numero firme " + cf.size());
// if (cf.size() > 1)
// salvaCampione(fileEntry, fileBytes, cf.size()
// + "-firme");
} else { } else {
String errorCode = JSONFactoryUtil.createJSONObject(responseBody).getString( String errorCode = JSONFactoryUtil.createJSONObject(responseBody)
"errorCode"); .getString("errorCode");
DocPraticaLocalServiceUtil.addErrorAndApprova(docPratica.getDocPraticaId(), DocPraticaLocalServiceUtil.addErrorAndApprova(docPratica.getDocPraticaId(), errorCode);
errorCode); _log.warn("P7M REST extractor error. Response: " + new String(responseBody) + " id="
_log.warn("P7M REST extractor error. Response: " + new String(responseBody) + fileEntry.getFileEntryId());
+ " id=" + fileEntry.getFileEntryId());
salvaCampione(fileEntry, fileBytes, "0-firme");
} }
} }
} }
@ -127,19 +110,5 @@ public class SchedulerEstrazioneFirme implements MessageListener {
lock.unlock(); 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 { public void receive(Message message) throws MessageListenerException {
if (lock.tryLock()) { if (lock.tryLock()) {
_log.debug("SchedulerGeneraDocumento - inizio");
try { try {
// campo abilitazione scheduler // campo abilitazione scheduler
for (Company company : CompanyLocalServiceUtil.getCompanies()) { for (Company company : CompanyLocalServiceUtil.getCompanies()) {
String condition = ConfigurazioneLocalServiceUtil.findByC_ChiaveString( String condition = ConfigurazioneLocalServiceUtil.findByC_ChiaveString(company.getCompanyId(),
company.getCompanyId(), ConfigurazioneConstants.SCHEDULER_GENERA_DOCUMENTO); ConfigurazioneConstants.SCHEDULER_GENERA_DOCUMENTO);
_log.debug("SchedulerGeneraDocumento - per company " + company.getCompanyId()
+ " attivo? " + condition);
if (Boolean.parseBoolean(condition)) { if (Boolean.parseBoolean(condition)) {
int count = AvvisoLocalServiceUtil.countAvvisiGenerazioneDocumento(); int count = AvvisoLocalServiceUtil.countAvvisiGenerazioneDocumento();
_log.debug("SchedulerGeneraDocumento - numero avvisi " + count);
if (count > 0) { if (count > 0) {
for (int cursor = 0; cursor <= count; cursor += SIZE) { for (int cursor = 0; cursor <= count; cursor += SIZE) {
List<Avviso> avvisi = AvvisoLocalServiceUtil.getAvvisiGenerazioneDocumento(cursor,
List<Avviso> avvisi = AvvisoLocalServiceUtil.getAvvisiGenerazioneDocumento( cursor + SIZE);
cursor, cursor + SIZE);
for (Avviso avviso : avvisi) { for (Avviso avviso : avvisi) {
_log.debug("SchedulerGeneraDocumento - avviso " + avviso.getAvvisoId());
try { try {
FileEntry fileEntryTemplate = null; FileEntry fileEntryTemplate = null;
try { try {
fileEntryTemplate = DLAppLocalServiceUtil.getFileEntry(avviso fileEntryTemplate = DLAppLocalServiceUtil.getFileEntry(avviso
.getFileEntryIdTemplate()); .getFileEntryIdTemplate());
} catch (PortalException e) { } catch (PortalException e) {
// bloccato, non esiste file di // bloccato, non esiste file di template
// template AvvisoLocalServiceUtil.updateAvvisoErrore(avviso.getAvvisoId(), true);
_log.debug("SchedulerGeneraDocumento - non esiste file template");
AvvisoLocalServiceUtil.updateAvvisoErrore(avviso.getAvvisoId(),
true);
} }
if (fileEntryTemplate != null) { if (fileEntryTemplate != null) {
_log.debug("SchedulerGeneraDocumento - inizio genera documento");
generaDocumento(avviso, fileEntryTemplate.getFileEntryId()); generaDocumento(avviso, fileEntryTemplate.getFileEntryId());
_log.debug("SchedulerGeneraDocumento - fine genera documento");
} }
} catch (Exception e) { } catch (Exception e) {
_log.error("Error", e); _log.error("Error", e);
@ -112,63 +98,40 @@ public class SchedulerGeneraDocumento implements MessageListener {
private Long generaDocumento(Avviso avviso, long fileEntryIdTemplate) throws SystemException { private Long generaDocumento(Avviso avviso, long fileEntryIdTemplate) throws SystemException {
Long idFileEntry = null; Long idFileEntry = null;
try { try {
long companyId = avviso.getCompanyId(); long companyId = avviso.getCompanyId();
long groupId = avviso.getGroupId(); long groupId = avviso.getGroupId();
long userId = avviso.getUserId(); long userId = avviso.getUserId();
ServiceContext serviceContext = new ServiceContext(); ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(companyId); serviceContext.setCompanyId(companyId);
serviceContext.setScopeGroupId(groupId); serviceContext.setScopeGroupId(groupId);
serviceContext.setUserId(userId); serviceContext.setUserId(userId);
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(avviso.getIntPraticaId()); IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(avviso.getIntPraticaId());
long folderId = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(companyId, AvvisoUtil long folderId = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(companyId, AvvisoUtil
.getAllTipoDocumentoFolderProps().get(avviso.getTipoDocumento())); .getAllTipoDocumentoFolderProps().get(avviso.getTipoDocumento()));
String fileName = AvvisoLocalServiceUtil.getFileNameAvviso(avviso.getClassPk(), avviso.getTipoDocumento(),
String fileName = AvvisoLocalServiceUtil.getFileNameAvviso(avviso.getClassPk(), avviso.getAvvisoId(), "B");
avviso.getTipoDocumento(), avviso.getAvvisoId(), "B");
Map<String, Object> parameters = new HashMap<String, Object>(); Map<String, Object> parameters = new HashMap<String, Object>();
if (Validator.isNotNull(avviso.getJsonParameters())) { if (Validator.isNotNull(avviso.getJsonParameters())) {
JSONDeserializer<Map<String, String>> deserializer = JSONFactoryUtil.createJSONDeserializer(); JSONDeserializer<Map<String, String>> deserializer = JSONFactoryUtil.createJSONDeserializer();
parameters.putAll(deserializer.deserialize(avviso.getJsonParameters())); parameters.putAll(deserializer.deserialize(avviso.getJsonParameters()));
} }
if (DettPratica.class.getName().equals(avviso.getClassName())) { if (DettPratica.class.getName().equals(avviso.getClassName())) {
DettPratica dettPratica = DettPraticaLocalServiceUtil.fetchDettPratica(avviso.getClassPk()); DettPratica dettPratica = DettPraticaLocalServiceUtil.fetchDettPratica(avviso.getClassPk());
if (dettPratica != null) { if (dettPratica != null) {
if (intPratica != null && Validator.isNotNull(intPratica.getStatusByUserId())) { if (intPratica != null && Validator.isNotNull(intPratica.getStatusByUserId())) {
User tecnico = UserLocalServiceUtil.fetchUserById(intPratica.getStatusByUserId()); User tecnico = UserLocalServiceUtil.fetchUserById(intPratica.getStatusByUserId());
if (tecnico != null) { if (tecnico != null) {
parameters.put(WorkflowConstants.WORKFLOW_PARAM_NAME_TECNICO, parameters.put(WorkflowConstants.WORKFLOW_PARAM_NAME_TECNICO, tecnico.getFullName());
tecnico.getFullName());
parameters.put("delegato", tecnico.getFullName()); parameters.put("delegato", tecnico.getFullName());
} }
} }
} }
} }
ReportAvvisoBean bean = ReportAvvisoBeanBuilder.build(avviso, parameters); ReportAvvisoBean bean = ReportAvvisoBeanBuilder.build(avviso, parameters);
String resourcePath = getClass().getName().replaceAll("\\w+\\.", "../") String resourcePath = getClass().getName().replaceAll("\\w+\\.", "../")
.replace(getClass().getSimpleName(), ReportConstants.PATH_LOGO_REGIONE); .replace(getClass().getSimpleName(), ReportConstants.PATH_LOGO_REGIONE);
parameters.put(ReportConstants.LOGO_REGIONE, getClass().getResource(resourcePath).getPath()); 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 reportDto = new ReportDto();
reportDto.setFileEntryIds(new long[] { fileEntryIdTemplate }); reportDto.setFileEntryIds(new long[] { fileEntryIdTemplate });
reportDto.setFolderId(folderId); reportDto.setFolderId(folderId);
@ -176,18 +139,12 @@ public class SchedulerGeneraDocumento implements MessageListener {
reportDto.setParameters(parameters); reportDto.setParameters(parameters);
reportDto.setShowNumberOfPage(true); reportDto.setShowNumberOfPage(true);
reportDto.setType(ReportConstants.ReportType.JRXML_TO_PDF.toString()); reportDto.setType(ReportConstants.ReportType.JRXML_TO_PDF.toString());
ReportResultDto result = ReportUtil.generateReport(companyId, userId, reportDto, bean); ReportResultDto result = ReportUtil.generateReport(companyId, userId, reportDto, bean);
idFileEntry = result.getFileEntryIds()[0]; idFileEntry = result.getFileEntryIds()[0];
// idFileEntry = (Long)
// MessageBusUtil.sendSynchronousMessage(ReportDestinationNames.SYNC,
// messageReport, 1);
if (Validator.isNotNull(idFileEntry)) { if (Validator.isNotNull(idFileEntry)) {
if (avviso.getTipoAvviso().equalsIgnoreCase(AvvisoUtil.TIPO_AVVISO_DIRETTO)) { if (avviso.getTipoAvviso().equalsIgnoreCase(AvvisoUtil.TIPO_AVVISO_DIRETTO)) {
gestioneProtocollazione(avviso, idFileEntry); gestioneProtocollazione(avviso, idFileEntry);
} }
if (AvvisoUtil.TIPO_AVVISO_DIRETTO.equals(avviso.getTipoAvviso())) { if (AvvisoUtil.TIPO_AVVISO_DIRETTO.equals(avviso.getTipoAvviso())) {
AvvisoLocalServiceUtil.updateAvvisoDlFileEntryIdBase(avviso.getAvvisoId(), idFileEntry); AvvisoLocalServiceUtil.updateAvvisoDlFileEntryIdBase(avviso.getAvvisoId(), idFileEntry);
} else if (AvvisoUtil.TIPO_AVVISO_FIRMA.equals(avviso.getTipoAvviso())) { } else if (AvvisoUtil.TIPO_AVVISO_FIRMA.equals(avviso.getTipoAvviso())) {
@ -197,30 +154,18 @@ public class SchedulerGeneraDocumento implements MessageListener {
} catch (Exception e) { } catch (Exception e) {
_log.error("Error on AvvisoId = " + avviso.getAvvisoId(), e); _log.error("Error on AvvisoId = " + avviso.getAvvisoId(), e);
} }
return idFileEntry; return idFileEntry;
} }
private Avviso gestioneProtocollazione(Avviso avviso, long fileEntryId) throws Exception { private Avviso gestioneProtocollazione(Avviso avviso, long fileEntryId) throws Exception {
if (Validator.isNull(avviso.getProtocollo())) { if (Validator.isNull(avviso.getProtocollo())) {
String protocollo = ProtocollazioneUtil.protocollaPartenza(avviso, fileEntryId); String protocollo = ProtocollazioneUtil.protocollaPartenza(avviso, fileEntryId);
if (Validator.isNull(protocollo)) { if (Validator.isNull(protocollo)) {
throw new Exception("errore nella protocollazione avviso"); throw new Exception("errore nella protocollazione avviso");
} }
avviso = AvvisoLocalServiceUtil.updateAvvisoProtocollo(avviso.getAvvisoId(), protocollo); avviso = AvvisoLocalServiceUtil.updateAvvisoProtocollo(avviso.getAvvisoId(), protocollo);
} }
return avviso; 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 @Override
public void receive(Message message) throws MessageListenerException { public void receive(Message message) throws MessageListenerException {
long avvisoId = 0L;
if (lock.tryLock()) { if (lock.tryLock()) {
_log.debug("SchedulerGeneraProtocollo - inizio");
try { try {
List<Avviso> avvisiList = AvvisoLocalServiceUtil.getAvvisiPerAggiuntaProtocollo(-1, SIZE); List<Avviso> avvisiList = AvvisoLocalServiceUtil.getAvvisiPerAggiuntaProtocollo(-1, SIZE);
if (Validator.isNotNull(avvisiList) && !avvisiList.isEmpty()) { if (Validator.isNotNull(avvisiList) && !avvisiList.isEmpty()) {
for (Avviso avviso : avvisiList) { for (Avviso avviso : avvisiList) {
_log.info("SchedulerGeneraProtocollo - avviso " + avviso.getAvvisoId()); _log.info("SchedulerGeneraProtocollo - avviso " + avviso.getAvvisoId());
try { try {
avvisoId = avviso.getAvvisoId();
FileEntry fileEntryBase = DLAppLocalServiceUtil.getFileEntry(avviso.getFileEntryIdBase()); FileEntry fileEntryBase = DLAppLocalServiceUtil.getFileEntry(avviso.getFileEntryIdBase());
if (Validator.isNotNull(fileEntryBase)) { if (Validator.isNotNull(fileEntryBase)) {
generaProtocollo(avviso, fileEntryBase); generaProtocollo(avviso, fileEntryBase);
} }
} catch (PortalException e) { } 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 companyId = avviso.getCompanyId();
long userId = avviso.getUserId(); long userId = avviso.getUserId();
ReportDto reportDto = new ReportDto(); ReportDto reportDto = new ReportDto();
reportDto.setFileEntryIds(new long[] { fileEntry.getFileEntryId() }); reportDto.setFileEntryIds(new long[] { fileEntry.getFileEntryId() });
reportDto.setFolderId(fileEntry.getFolderId()); reportDto.setFolderId(fileEntry.getFolderId());
reportDto.setFileName(fileEntry.getTitle() + "_protocollato"); reportDto.setFileName(fileEntry.getTitle() + "_protocollato");
reportDto.setType(ReportConstants.ReportType.JRXML_TO_PDF.toString()); reportDto.setType(ReportConstants.ReportType.JRXML_TO_PDF.toString());
Map<String, Object> parameters = new HashMap<String, Object>(); Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("protocollo", avviso.getProtocollo()); parameters.put("protocollo", avviso.getProtocollo());
parameters.put("dtProtocollo", avviso.getDtProtocollo().getTime()); parameters.put("dtProtocollo", avviso.getDtProtocollo().getTime());
parameters.put("oggetto", avviso.getOggettoProtocollo()); parameters.put("oggetto", avviso.getOggettoProtocollo());
reportDto.setParameters(parameters); reportDto.setParameters(parameters);
ReportResultDto result = ReportUtil.generateProtocollo(companyId, userId, reportDto); ReportResultDto result = ReportUtil.generateProtocollo(companyId, userId, reportDto);
long[] fileEntryIds = result.getFileEntryIds(); long[] fileEntryIds = result.getFileEntryIds();
if (Validator.isNotNull(fileEntryIds) && (fileEntryIds.length > 0)) { if (Validator.isNotNull(fileEntryIds) && (fileEntryIds.length > 0)) {
long idFileEntry = fileEntryIds[0]; long idFileEntry = fileEntryIds[0];
Avviso avvisoModified = AvvisoLocalServiceUtil.fetchAvviso(avviso.getAvvisoId()); Avviso avvisoModified = AvvisoLocalServiceUtil.fetchAvviso(avviso.getAvvisoId());
if (avvisoModified != null) { if (avvisoModified != null) {
avvisoModified.setFileEntryIdProtocollo(idFileEntry); 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 int SIZE = 10;
// private static final String TECNICO_MITTENTE = @Override
// "geniocivile.tecnico.mittente";
// private static final String TECNICO_OGGETTO =
// "geniocivile.tecnico.oggetto";
// private static final String TECNICO_CORPO = "geniocivile.tecnico.corpo";
public void receive(Message message) throws MessageListenerException { public void receive(Message message) throws MessageListenerException {
if (lock.tryLock()) { if (lock.tryLock()) {
try { try {
// campo abilitazione scheduler // campo abilitazione scheduler
for (Company company : CompanyLocalServiceUtil.getCompanies()) { for (Company company : CompanyLocalServiceUtil.getCompanies()) {
String condition = ConfigurazioneLocalServiceUtil.findByC_ChiaveString( String condition = ConfigurazioneLocalServiceUtil.findByC_ChiaveString(company.getCompanyId(),
company.getCompanyId(), ConfigurazioneConstants.SCHEDULER_INVIO_DOCUMENTO); ConfigurazioneConstants.SCHEDULER_INVIO_DOCUMENTO);
if (Boolean.parseBoolean(condition)) { if (Boolean.parseBoolean(condition)) {
processAvvisiInvioSuap(); processAvvisiInvioSuap();
processIntegrazioniInvioSignal(); processIntegrazioniInvioSignal();
@ -117,17 +112,11 @@ public class SchedulerInvioDocumento implements MessageListener {
private void processAvvisiInvioSuap() throws SystemException { private void processAvvisiInvioSuap() throws SystemException {
int count = AvvisoLocalServiceUtil.countAvvisiInvioDocumento(); int count = AvvisoLocalServiceUtil.countAvvisiInvioDocumento();
if (count > 0) { if (count > 0) {
for (int cursor = 0; cursor <= count; cursor += SIZE) { for (int cursor = 0; cursor <= count; cursor += SIZE) {
List<Avviso> avvisi = AvvisoLocalServiceUtil.getAvvisiInvioDocumento(cursor, cursor + SIZE); List<Avviso> avvisi = AvvisoLocalServiceUtil.getAvvisiInvioDocumento(cursor, cursor + SIZE);
for (Avviso avviso : avvisi) { for (Avviso avviso : avvisi) {
try { try {
FileEntry fileEntry = null; FileEntry fileEntry = null;
try { try {
fileEntry = DLAppLocalServiceUtil.getFileEntry(avviso.getFileEntryIdInvio()); fileEntry = DLAppLocalServiceUtil.getFileEntry(avviso.getFileEntryIdInvio());
@ -135,7 +124,6 @@ public class SchedulerInvioDocumento implements MessageListener {
// bloccato // bloccato
AvvisoLocalServiceUtil.updateAvvisoErrore(avviso.getAvvisoId(), true); AvvisoLocalServiceUtil.updateAvvisoErrore(avviso.getAvvisoId(), true);
} }
if (fileEntry != null) { if (fileEntry != null) {
// xxx senza suap non serve inviare // xxx senza suap non serve inviare
String url = StringPool.BLANK; String url = StringPool.BLANK;
@ -143,27 +131,22 @@ public class SchedulerInvioDocumento implements MessageListener {
if (Validator.isNotNull(avviso.getControlloPraticaId())) { if (Validator.isNotNull(avviso.getControlloPraticaId())) {
ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil
.getControlloPratica(avviso.getControlloPraticaId()); .getControlloPratica(avviso.getControlloPraticaId());
Avviso avvisoSignal = AvvisoLocalServiceUtil.getAvvisoInvioSignal(avviso Avviso avvisoSignal = AvvisoLocalServiceUtil.getAvvisoInvioSignal(avviso.getAvvisoId());
.getAvvisoId());
if (avvisoSignal != null) { if (avvisoSignal != null) {
invioSignal(avvisoSignal, controlloPratica); invioSignal(avvisoSignal, controlloPratica);
} }
Avviso avvisoTempistica = AvvisoLocalServiceUtil.getAvvisoTempistica(avviso Avviso avvisoTempistica = AvvisoLocalServiceUtil.getAvvisoTempistica(avviso
.getAvvisoId()); .getAvvisoId());
if (avvisoTempistica != null) { if (avvisoTempistica != null) {
gestioneTempistica(avvisoTempistica, controlloPratica); gestioneTempistica(avvisoTempistica, controlloPratica);
} }
Avviso avvisoInvioTecnico = AvvisoLocalServiceUtil.getAvvisoInvioTecnico(avviso
Avviso avvisoInvioTecnico = AvvisoLocalServiceUtil .getAvvisoId());
.getAvvisoInvioTecnico(avviso.getAvvisoId());
if (avvisoInvioTecnico != null) { if (avvisoInvioTecnico != null) {
sendToTecnico(avvisoInvioTecnico); sendToTecnico(avvisoInvioTecnico);
} }
} }
} }
} catch (Exception e) { } catch (Exception e) {
_log.error("Error", e); _log.error("Error", e);
} }
@ -175,13 +158,9 @@ public class SchedulerInvioDocumento implements MessageListener {
private void processAvvisiInvioSignal() throws SystemException { private void processAvvisiInvioSignal() throws SystemException {
int count = AvvisoLocalServiceUtil.countAvvisiInvioSignal(); int count = AvvisoLocalServiceUtil.countAvvisiInvioSignal();
if (count > 0) { if (count > 0) {
for (int cursor = 0; cursor <= count; cursor += SIZE) { for (int cursor = 0; cursor <= count; cursor += SIZE) {
List<Avviso> avvisi = AvvisoLocalServiceUtil.getAvvisiInvioSignal(cursor, cursor + SIZE); List<Avviso> avvisi = AvvisoLocalServiceUtil.getAvvisiInvioSignal(cursor, cursor + SIZE);
for (Avviso avviso : avvisi) { for (Avviso avviso : avvisi) {
long controlloPraticaId = avviso.getControlloPraticaId(); long controlloPraticaId = avviso.getControlloPraticaId();
if (controlloPraticaId != 0) { if (controlloPraticaId != 0) {
@ -190,7 +169,7 @@ public class SchedulerInvioDocumento implements MessageListener {
.getControlloPratica(avviso.getControlloPraticaId()); .getControlloPratica(avviso.getControlloPraticaId());
invioSignal(avviso, controlloPratica); invioSignal(avviso, controlloPratica);
} catch (Exception e) { } catch (Exception e) {
_log.info(e.getMessage() + " " + avviso.getAvvisoId() + " " _log.info(e.getMessage() + StringPool.SPACE + avviso.getAvvisoId() + StringPool.SPACE
+ avviso.getControlloPraticaId()); + avviso.getControlloPraticaId());
_log.debug("Error", e); _log.debug("Error", e);
} }
@ -203,26 +182,19 @@ public class SchedulerInvioDocumento implements MessageListener {
private void processIntegrazioniInvioSignal() throws SystemException { private void processIntegrazioniInvioSignal() throws SystemException {
int count = DettPraticaLocalServiceUtil.countInvioSignal(); int count = DettPraticaLocalServiceUtil.countInvioSignal();
if (count > 0) { if (count > 0) {
for (int cursor = 0; cursor <= count; cursor += SIZE) { 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) { for (DettPratica integrazione : integrazioni) {
try { try {
ControlloPratica controlloPratica = null; ControlloPratica controlloPratica = null;
List<ControlloPratica> controlli = ControlloPraticaLocalServiceUtil List<ControlloPratica> controlli = ControlloPraticaLocalServiceUtil.findByIntPraticaId_Status(
.findByIntPraticaId_Status(integrazione.getIntPraticaId(), integrazione.getIntPraticaId(), WorkflowConstants.STATUS_PENDING);
WorkflowConstants.STATUS_PENDING);
if (controlli.isEmpty()) { if (controlli.isEmpty()) {
ServiceContext serviceContext = new ServiceContext(); ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(integrazione.getCompanyId()); serviceContext.setCompanyId(integrazione.getCompanyId());
serviceContext.setScopeGroupId(integrazione.getGroupId()); serviceContext.setScopeGroupId(integrazione.getGroupId());
serviceContext.setUserId(integrazione.getUserId()); serviceContext.setUserId(integrazione.getUserId());
controlloPratica = ControlloPraticaLocalServiceUtil.addControlloPratica( controlloPratica = ControlloPraticaLocalServiceUtil.addControlloPratica(
integrazione.getGroupId(), integrazione.getUserId(), integrazione.getGroupId(), integrazione.getUserId(),
integrazione.getIntPraticaId(), integrazione.getDettPraticaId(), false, integrazione.getIntPraticaId(), integrazione.getDettPraticaId(), false,
@ -230,8 +202,7 @@ public class SchedulerInvioDocumento implements MessageListener {
} else { } else {
controlloPratica = controlli.get(0); controlloPratica = controlli.get(0);
} }
invioSignal(integrazione, controlloPratica, invioSignal(integrazione, controlloPratica, WorkflowConstants.WORKFLOW_SIGNAL_INTEGRAZIONE);
WorkflowConstants.WORKFLOW_SIGNAL_INTEGRAZIONE);
} catch (Exception e) { } catch (Exception e) {
_log.error("Error", e); _log.error("Error", e);
} }
@ -243,13 +214,9 @@ public class SchedulerInvioDocumento implements MessageListener {
private void processAvvisiTempistica() throws SystemException { private void processAvvisiTempistica() throws SystemException {
int count = AvvisoLocalServiceUtil.countAvvisiTempistica(); int count = AvvisoLocalServiceUtil.countAvvisiTempistica();
if (count > 0) { if (count > 0) {
for (int cursor = 0; cursor <= count; cursor += SIZE) { for (int cursor = 0; cursor <= count; cursor += SIZE) {
List<Avviso> avvisi = AvvisoLocalServiceUtil.getAvvisiTempistica(cursor, cursor + SIZE); List<Avviso> avvisi = AvvisoLocalServiceUtil.getAvvisiTempistica(cursor, cursor + SIZE);
for (Avviso avviso : avvisi) { for (Avviso avviso : avvisi) {
long controlloPraticaId = avviso.getControlloPraticaId(); long controlloPraticaId = avviso.getControlloPraticaId();
if (controlloPraticaId > 0) { if (controlloPraticaId > 0) {
@ -258,7 +225,7 @@ public class SchedulerInvioDocumento implements MessageListener {
.getControlloPratica(controlloPraticaId); .getControlloPratica(controlloPraticaId);
gestioneTempistica(avviso, controlloPratica); gestioneTempistica(avviso, controlloPratica);
} catch (Exception e) { } catch (Exception e) {
_log.debug(e.getMessage() + " " + avviso.getAvvisoId() + " " _log.debug(e.getMessage() + StringPool.SPACE + avviso.getAvvisoId() + StringPool.SPACE
+ avviso.getControlloPraticaId()); + avviso.getControlloPraticaId());
_log.debug("Error", e); _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
* ADT: gestione notifiche al tecnico istruttore. Al momento gestisce solo
* notifica di assegnazione/riassegnazione
*
* @throws SystemException
*/
private void processAvvisiInvioTecnico() throws SystemException { private void processAvvisiInvioTecnico() throws SystemException {
int count = AvvisoLocalServiceUtil.countAvvisiInvioTecnicoNew(); int count = AvvisoLocalServiceUtil.countAvvisiInvioTecnicoNew();
if (count > 0) { if (count > 0) {
_log.info("trovati avvisi per invio email notifiche al tecnico:" + count); _log.info("trovati avvisi per invio email notifiche al tecnico:" + count);
for (int cursor = 0; cursor <= count; cursor += SIZE) { for (int cursor = 0; cursor <= count; cursor += SIZE) {
List<Avviso> avvisi = AvvisoLocalServiceUtil.getAvvisiInvioTecnicoNew(cursor, cursor + SIZE); List<Avviso> avvisi = AvvisoLocalServiceUtil.getAvvisiInvioTecnicoNew(cursor, cursor + SIZE);
for (Avviso avviso : avvisi) { for (Avviso avviso : avvisi) {
try { try {
// trattandosi solo di avvisi con tipo documento CI // trattandosi solo di avvisi con tipo documento CI oppure SP si tratta di assegnazione
// oppure SP si tratta di assegnazione istruttore // istruttore
MailUtil.invioNotificaAssegnazioneIstruttore(avviso); MailUtil.invioNotificaAssegnazioneIstruttore(avviso);
} catch (Exception e) { } catch (Exception e) {
_log.error("Error", 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 { private void invioDocumento(Avviso avviso, FileEntry fileEntry, String url) throws Exception {
// xxx senza suap non serve inviare l'avviso se non metterlo come // xxx senza suap non serve inviare l'avviso se non metterlo come inviato per farlo vedere nel FE
// inviato per farlo vedere nel
// FE
if (AvvisoUtil.DOCUMENTO_INVIATO.equalsIgnoreCase(avviso.getInviato())) { if (AvvisoUtil.DOCUMENTO_INVIATO.equalsIgnoreCase(avviso.getInviato())) {
return; return;
} }
AvvisoLocalServiceUtil.updateAvvisoInvio(avviso.getAvvisoId()); AvvisoLocalServiceUtil.updateAvvisoInvio(avviso.getAvvisoId());
inviaMailnotifica(avviso.getAvvisoId()); inviaMailnotifica(avviso.getAvvisoId());
} }
@ -312,27 +269,16 @@ public class SchedulerInvioDocumento implements MessageListener {
private void inviaMailnotifica(long avvisoId) throws SystemException, PortalException { private void inviaMailnotifica(long avvisoId) throws SystemException, PortalException {
Avviso avviso = AvvisoLocalServiceUtil.getAvviso(avvisoId); Avviso avviso = AvvisoLocalServiceUtil.getAvviso(avvisoId);
long intPraticaId = avviso.getIntPraticaId(); long intPraticaId = avviso.getIntPraticaId();
DettPratica dettPratica = null; 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 tipoDocumento = avviso.translateTipoDocumento();
String tipoAvviso = LanguageUtil.get(LocaleUtil.ITALIAN, tipoDocumento); String tipoAvviso = LanguageUtil.get(LocaleUtil.ITALIAN, tipoDocumento);
String tipoAllegato = StringPool.BLANK; String tipoAllegato = StringPool.BLANK;
if (avviso.getTipoDocumento().equalsIgnoreCase(StatoPraticaConstants.VIDIMATA)) { if (avviso.getTipoDocumento().equalsIgnoreCase(StatoPraticaConstants.VIDIMATA)) {
tipoAllegato = "accettazione istanza di "; tipoAllegato = "accettazione istanza di ";
if (avviso.getClassName().equals(DettPratica.class.getName())) { if (avviso.getClassName().equals(DettPratica.class.getName())) {
dettPratica = DettPraticaLocalServiceUtil.getDettPratica(avviso.getClassPk()); dettPratica = DettPraticaLocalServiceUtil.getDettPratica(avviso.getClassPk());
if (TipoIntegrazioneUtil.VARIAZIONE_SOGGETTO.equalsIgnoreCase(dettPratica if (TipoIntegrazioneUtil.VARIAZIONE_SOGGETTO.equalsIgnoreCase(dettPratica.getTipoIntegrazione())) {
.getTipoIntegrazione())) {
tipoAllegato += LanguageUtil.get(LocaleUtil.ITALIAN, "label-integrazione-12"); tipoAllegato += LanguageUtil.get(LocaleUtil.ITALIAN, "label-integrazione-12");
} else if (TipoIntegrazioneUtil.RICHIESTA_INTEGRAZIONE.equalsIgnoreCase(dettPratica } else if (TipoIntegrazioneUtil.RICHIESTA_INTEGRAZIONE.equalsIgnoreCase(dettPratica
.getTipoIntegrazione())) { .getTipoIntegrazione())) {
@ -341,8 +287,7 @@ public class SchedulerInvioDocumento implements MessageListener {
tipoAllegato += LanguageUtil.get(LocaleUtil.ITALIAN, "label-integrazione-13"); tipoAllegato += LanguageUtil.get(LocaleUtil.ITALIAN, "label-integrazione-13");
} }
} else { } else {
dettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(avviso dettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(avviso.getIntPraticaId());
.getIntPraticaId());
if (avviso.getClassName().equals(FineLavori.class.getName())) { if (avviso.getClassName().equals(FineLavori.class.getName())) {
FineLavori fineLavori = FineLavoriLocalServiceUtil.getFineLavori(avviso.getClassPk()); FineLavori fineLavori = FineLavoriLocalServiceUtil.getFineLavori(avviso.getClassPk());
tipoAllegato += LanguageUtil.get(LocaleUtil.ITALIAN, tipoAllegato += LanguageUtil.get(LocaleUtil.ITALIAN,
@ -357,71 +302,53 @@ public class SchedulerInvioDocumento implements MessageListener {
} }
} else { } else {
tipoAllegato = "documento di " tipoAllegato = "documento di "
+ LanguageUtil.get(LocaleUtil.ITALIAN, + LanguageUtil.get(LocaleUtil.ITALIAN, tipoDocumento.replace("tipoDocumento", "documento"));
tipoDocumento.replace("tipoDocumento", "documento"));
dettPratica = DettPraticaLocalServiceUtil.fetchDettPratica(avviso.getClassPk()); dettPratica = DettPraticaLocalServiceUtil.fetchDettPratica(avviso.getClassPk());
if (Validator.isNull(dettPratica)) { if (Validator.isNull(dettPratica)) {
dettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(avviso dettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(avviso.getIntPraticaId());
.getIntPraticaId());
} }
} }
List<Soggetto> soggetti = new ArrayList<Soggetto>(SoggettoLocalServiceUtil.getValidByIntPratica(intPraticaId));
List<Soggetto> soggetti = new ArrayList<Soggetto>( Soggetto committentePrincipale = SoggettoLocalServiceUtil.getValidByIntPratica_CodiceFiscale_TipologiaSoggetto(
SoggettoLocalServiceUtil.getValidByIntPratica(intPraticaId)); intPraticaId, dettPratica.getCodiceFiscalePrincipaleCommittente(), TipoSoggettoUtil.COMMITTENTE);
Soggetto committentePrincipale = SoggettoLocalServiceUtil
.getValidByIntPratica_CodiceFiscale_TipologiaSoggetto(intPraticaId,
dettPratica.getCodiceFiscalePrincipaleCommittente(), TipoSoggettoUtil.COMMITTENTE);
if (null == committentePrincipale) { if (null == committentePrincipale) {
_log.error("Il committente principale non esiste, intPraticaId = " + intPraticaId); _log.error("Il committente principale non esiste, intPraticaId = " + intPraticaId);
} else { } else {
soggetti.remove(committentePrincipale); soggetti.remove(committentePrincipale);
} }
Set<String> sTo = new HashSet<>(); Set<String> sTo = new HashSet<>();
for (Soggetto soggetto : soggetti) { for (Soggetto soggetto : soggetti) {
sTo.add(soggetto.getEmail()); sTo.add(soggetto.getEmail());
} }
String[] to = sTo.toArray(new String[sTo.size()]); String[] to = sTo.toArray(new String[sTo.size()]);
String[] cc = new String[0]; String[] cc = new String[0];
String[] ccn = new String[0]; String[] ccn = new String[0];
String tipoPratica = StringPool.BLANK; String tipoPratica = StringPool.BLANK;
if (AzioniPraticheUtil.isDeposito(intPraticaId)) { if (AzioniPraticheUtil.isDeposito(intPraticaId)) {
tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-01"); tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-01");
} else if (AzioniPraticheUtil.isAutorizzazione(intPraticaId)) { } else if (AzioniPraticheUtil.isAutorizzazione(intPraticaId)) {
tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-02"); tipoPratica = LanguageUtil.get(LocaleUtil.ITALIAN, "tipo-pratica-02");
} }
String url = FascicoloURLUtil.getFascicoloFEViewURL(avviso.getCompanyId(), avviso.getIntPraticaId(), String url = FascicoloURLUtil.getFascicoloFEViewURL(avviso.getCompanyId(), avviso.getIntPraticaId(),
"/html/fascicolofe/view_fascicolo.jsp", StringPool.BLANK); "/html/fascicolofe/view_fascicolo.jsp", StringPool.BLANK);
JSONObject templateVariables = JSONFactoryUtil.createJSONObject(); JSONObject templateVariables = JSONFactoryUtil.createJSONObject();
templateVariables.put("tipoPratica", tipoPratica); templateVariables.put("tipoPratica", tipoPratica);
templateVariables.put("tipoAvviso", tipoAvviso); templateVariables.put("tipoAvviso", tipoAvviso);
templateVariables.put("tipoAllegato", tipoAllegato); templateVariables.put("tipoAllegato", tipoAllegato);
templateVariables.put("link", url); templateVariables.put("link", url);
ServiceContext serviceContext = new ServiceContext(); ServiceContext serviceContext = new ServiceContext();
serviceContext.setScopeGroupId(avviso.getGroupId()); serviceContext.setScopeGroupId(avviso.getGroupId());
serviceContext.setCompanyId(avviso.getCompanyId()); serviceContext.setCompanyId(avviso.getCompanyId());
serviceContext.setUserId(avviso.getUserId()); serviceContext.setUserId(avviso.getUserId());
MailUtil.invioMailNotifica(intPraticaId, dettPratica.getDettPraticaId(), avvisoId, Avviso.class.getName(), to,
MailUtil.invioMailNotifica(intPraticaId, dettPratica.getDettPraticaId(), avvisoId, cc, ccn, "NOTIFICA-SOGGETTI-ATTIVI", templateVariables, null, serviceContext);
Avviso.class.getName(), to, cc, ccn, "NOTIFICA-SOGGETTI-ATTIVI", templateVariables, null,
serviceContext);
if (null != committentePrincipale) { if (null != committentePrincipale) {
to = new String[] { committentePrincipale.getEmail() }; to = new String[] { committentePrincipale.getEmail() };
List<FileAttachment> allegati = new ArrayList<FileAttachment>(); List<FileAttachment> allegati = new ArrayList<FileAttachment>();
long fileEntryId = 0l; long fileEntryId = 0L;
String[] pdfInvio = new String[] { StatoPraticaConstants.CAMBIO_ISTRUTTORE, String[] pdfInvio = new String[] { StatoPraticaConstants.CAMBIO_ISTRUTTORE,
StatoPraticaConstants.SOTTOPOSTA_A_PARERE }; StatoPraticaConstants.SOTTOPOSTA_A_PARERE };
// se è avviso di Vidimazione o di Avvio procedimento o di Cambio // se è avviso di Vidimazione o di Avvio procedimento o di Cambio Istruttore => file protocollato
// Istruttore => file protocollato
if (avviso.getTipoDocumento().equalsIgnoreCase(StatoPraticaConstants.VIDIMATA) if (avviso.getTipoDocumento().equalsIgnoreCase(StatoPraticaConstants.VIDIMATA)
|| ArrayUtil.contains(pdfInvio, avviso.getTipoDocumento())) { || ArrayUtil.contains(pdfInvio, avviso.getTipoDocumento())) {
if (Validator.isNotNull(avviso.getFileEntryIdProtocollo())) { if (Validator.isNotNull(avviso.getFileEntryIdProtocollo())) {
@ -434,45 +361,34 @@ public class SchedulerInvioDocumento implements MessageListener {
fileEntryId = avviso.getFileEntryIdInvio(); fileEntryId = avviso.getFileEntryIdInvio();
} }
} }
if (Validator.isNotNull(fileEntryId)) { if (Validator.isNotNull(fileEntryId)) {
FileAttachment fileAttachment = new FileAttachment(); FileAttachment fileAttachment = new FileAttachment();
fileAttachment.setFileEntryId(avviso.getFileEntryIdProtocollo()); fileAttachment.setFileEntryId(avviso.getFileEntryIdProtocollo());
fileAttachment.generateFile(); fileAttachment.generateFile();
allegati.add(fileAttachment); allegati.add(fileAttachment);
} }
MailUtil.invioMailNotifica(intPraticaId, dettPratica.getDettPraticaId(), avvisoId, Avviso.class.getName(),
MailUtil.invioMailNotifica(intPraticaId, dettPratica.getDettPraticaId(), avvisoId, to, cc, ccn, "NOTIFICA-SOGGETTI-ATTIVI", templateVariables, allegati, serviceContext);
Avviso.class.getName(), to, cc, ccn, "NOTIFICA-SOGGETTI-ATTIVI", templateVariables, String[] suapEnabled = new String[] { StatoPraticaConstants.CONFORME, StatoPraticaConstants.NON_CONFORME };
allegati, serviceContext);
String[] suapEnabled = new String[] { StatoPraticaConstants.CONFORME,
StatoPraticaConstants.NON_CONFORME };
if ((AzioniPraticheUtil.isAutorizzazione(intPraticaId) && ArrayUtil.contains(suapEnabled, if ((AzioniPraticheUtil.isAutorizzazione(intPraticaId) && ArrayUtil.contains(suapEnabled,
avviso.getTipoDocumento())) avviso.getTipoDocumento()))
|| (StatoPraticaConstants.VIDIMATA.equals(avviso.getTipoDocumento()))) { || (StatoPraticaConstants.VIDIMATA.equals(avviso.getTipoDocumento()))) {
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId); IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId);
Territorio territorio = TerritorioLocalServiceUtil Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId());
.getTerritorio(intPratica.getTerritorioId());
Comune comune = ComuneLocalServiceUtil.getComune(territorio.getComuneId()); Comune comune = ComuneLocalServiceUtil.getComune(territorio.getComuneId());
String eMail = StringPool.BLANK; String eMail = StringPool.BLANK;
if (dettPratica.getSuap()) { if (dettPratica.getSuap()) {
eMail = comune.getMailSuap(); eMail = comune.getMailSuap();
} else { } else {
eMail = comune.getMailSue(); eMail = comune.getMailSue();
} }
to = new String[] { eMail }; to = new String[] { eMail };
templateVariables.put("cont", StringPool.BLANK); templateVariables.put("cont", StringPool.BLANK);
templateVariables.put("anno", StringPool.BLANK); templateVariables.put("anno", StringPool.BLANK);
templateVariables.put( templateVariables.put(
"dataVidimazione", "dataVidimazione",
FastDateFormatFactoryUtil.getSimpleDateFormat("dd/MM/yyyy HH:mm").format( FastDateFormatFactoryUtil.getSimpleDateFormat("dd/MM/yyyy HH:mm").format(
intPratica.getDtPratica())); intPratica.getDtPratica()));
if (to.length > 0 && to[0] != StringPool.BLANK) { if (to.length > 0 && to[0] != StringPool.BLANK) {
MailUtil.invioMailNotifica(intPraticaId, dettPratica.getDettPraticaId(), avvisoId, MailUtil.invioMailNotifica(intPraticaId, dettPratica.getDettPraticaId(), avvisoId,
Avviso.class.getName(), to, cc, ccn, "INVIO-SUAP", templateVariables, allegati, 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) private void invioSignal(DettPratica integrazione, ControlloPratica controlloPratica, String signalName)
@ -491,37 +406,23 @@ public class SchedulerInvioDocumento implements MessageListener {
long companyId = controlloPratica.getCompanyId(); long companyId = controlloPratica.getCompanyId();
long userId = WorkflowUtil.getWorkflowInstanceCreateUserId(controlloPratica); long userId = WorkflowUtil.getWorkflowInstanceCreateUserId(controlloPratica);
try { try {
WorkflowInstance workflowInstance = WorkflowInstanceManagerUtil.getWorkflowInstance(companyId, WorkflowInstance workflowInstance = WorkflowInstanceManagerUtil.getWorkflowInstance(companyId,
workflowInstanceId); 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 serviceContext = new ServiceContext();
serviceContext.setCompanyId(companyId); serviceContext.setCompanyId(companyId);
KaleoInstance kaleoInstance = KaleoInstanceLocalServiceUtil.getKaleoInstance(workflowInstanceId); KaleoInstance kaleoInstance = KaleoInstanceLocalServiceUtil.getKaleoInstance(workflowInstanceId);
KaleoInstanceToken rootKaleoInstanceToken = kaleoInstance KaleoInstanceToken rootKaleoInstanceToken = kaleoInstance.getRootKaleoInstanceToken(serviceContext);
.getRootKaleoInstanceToken(serviceContext);
// ADT:bug importazione portos1 in richiesta di integraione // ADT:bug importazione portos1 in richiesta di integraione
this.checkPresenzaIstruttore(controlloPratica, integrazione, serviceContext, userId, this.checkPresenzaIstruttore(controlloPratica, integrazione, serviceContext, userId, workflowInstanceId);
workflowInstanceId); if (rootKaleoInstanceToken.getCurrentKaleoNodeName().equals(WorkflowConstants.WORKFLOW_SIGNAL_INTEGRAZIONE)) {
WorkflowInstanceManagerUtil.signalWorkflowInstance(companyId, userId, workflowInstanceId, signalName,
if (rootKaleoInstanceToken.getCurrentKaleoNodeName().equals( workflowInstance.getWorkflowContext());
WorkflowConstants.WORKFLOW_SIGNAL_INTEGRAZIONE)) {
WorkflowInstanceManagerUtil.signalWorkflowInstance(companyId, userId, workflowInstanceId,
signalName, workflowInstance.getWorkflowContext());
} }
DettPraticaLocalServiceUtil.updateSignal(integrazione.getDettPraticaId(), new Date()); DettPraticaLocalServiceUtil.updateSignal(integrazione.getDettPraticaId(), new Date());
} catch (WorkflowException e) {
_log.error("Error on controllo pratica id : " + controlloPratica.getControlloPraticaId(), e);
} catch (PortalException e) { } catch (PortalException e) {
_log.error("Error on controllo pratica id : " + controlloPratica.getControlloPraticaId(), e); _log.error("Error on controllo pratica id : " + controlloPratica.getControlloPraticaId(), e);
} }
} }
private void invioSignal(Avviso avviso, ControlloPratica controlloPratica) throws SystemException, private void invioSignal(Avviso avviso, ControlloPratica controlloPratica) throws SystemException,
@ -534,31 +435,18 @@ public class SchedulerInvioDocumento implements MessageListener {
long userId = WorkflowUtil.getWorkflowInstanceCreateUserId(controlloPratica); long userId = WorkflowUtil.getWorkflowInstanceCreateUserId(controlloPratica);
String signalName = WorkflowUtil.getSignalByTipoDocumento(avviso.getTipoDocumento()); String signalName = WorkflowUtil.getSignalByTipoDocumento(avviso.getTipoDocumento());
try { try {
WorkflowInstance workflowInstance = WorkflowInstanceManagerUtil.getWorkflowInstance(companyId,
WorkflowInstance workflowInstance = WorkflowInstanceManagerUtil.getWorkflowInstance( workflowInstanceId);
companyId, workflowInstanceId); // Fix per errore su No KaleoTransition exists with the key {kaleoNodeId=xxx, name=signal_ff}
// Fix per errore su No KaleoTransition exists with the key
// {kaleoNodeId=xxx, name=signal_ff}
ServiceContext serviceContext = new ServiceContext(); ServiceContext serviceContext = new ServiceContext();
serviceContext.setCompanyId(companyId); serviceContext.setCompanyId(companyId);
KaleoInstance kaleoInstance = KaleoInstanceLocalServiceUtil KaleoInstance kaleoInstance = KaleoInstanceLocalServiceUtil.getKaleoInstance(workflowInstanceId);
.getKaleoInstance(workflowInstanceId); KaleoInstanceToken rootKaleoInstanceToken = kaleoInstance.getRootKaleoInstanceToken(serviceContext);
KaleoInstanceToken rootKaleoInstanceToken = kaleoInstance
.getRootKaleoInstanceToken(serviceContext);
if (rootKaleoInstanceToken.getCurrentKaleoNodeName().equals(signalName)) { if (rootKaleoInstanceToken.getCurrentKaleoNodeName().equals(signalName)) {
WorkflowInstanceManagerUtil.signalWorkflowInstance(companyId, userId, workflowInstanceId, WorkflowInstanceManagerUtil.signalWorkflowInstance(companyId, userId, workflowInstanceId,
signalName, workflowInstance.getWorkflowContext()); signalName, workflowInstance.getWorkflowContext());
} }
AvvisoLocalServiceUtil.updateAvvisoSignal(avviso.getAvvisoId(), new Date()); 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) { } catch (PortalException e) {
_log.error("Error on controllo pratica id : " + controlloPratica.getControlloPraticaId(), 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 // FIXME la tempistica non va bene mette le date sbagliate
String tipoDocumento = avviso.getTipoDocumento(); String tipoDocumento = avviso.getTipoDocumento();
// String tipoDocumento = avviso.translateTipoDocumento();
Date dtInvio = avviso.getDtInvio(); Date dtInvio = avviso.getDtInvio();
if (tipoDocumento.equals(StatoPraticaConstants.SOTTOPOSTA_A_PARERE)) { if (tipoDocumento.equals(StatoPraticaConstants.SOTTOPOSTA_A_PARERE)) {
long intPraticaId = controlloPratica.getIntPraticaId(); long intPraticaId = controlloPratica.getIntPraticaId();
@ -580,33 +467,25 @@ public class SchedulerInvioDocumento implements MessageListener {
try { try {
intPratica = IntPraticaLocalServiceUtil.getIntPratica(controlloPratica.getIntPraticaId()); intPratica = IntPraticaLocalServiceUtil.getIntPratica(controlloPratica.getIntPraticaId());
} catch (PortalException e) { } catch (PortalException e) {
_log.error(e, e); _log.error(e, e);
} }
// FIX prendo la data di vidimazione e non quella di sottoposto a // FIX prendo la data di vidimazione e non quella di sottoposto a parere per avvio dei tempi
// parere per avvio dei tempi
Avviso avvisoExtra = null; Avviso avvisoExtra = null;
if (Validator.isNotNull(intPratica.getDtSorteggio())) { if (Validator.isNotNull(intPratica.getDtSorteggio())) {
dtInvio = intPratica.getDtSorteggio(); dtInvio = intPratica.getDtSorteggio();
} else { } else {
List<Avviso> documentiVid = AvvisoLocalServiceUtil.findByIntPraticaId_tipoDocumento( List<Avviso> documentiVid = AvvisoLocalServiceUtil.findByIntPraticaId_tipoDocumento(intPraticaId,
intPraticaId, StatoPraticaConstants.VIDIMATA); StatoPraticaConstants.VIDIMATA);
avvisoExtra = documentiVid.get(0); avvisoExtra = documentiVid.get(0);
dtInvio = avvisoExtra.getDtInvio(); dtInvio = avvisoExtra.getDtInvio();
} }
// fino qui // fino qui
// TempisticaLocalServiceUtil.addTempistica(intPraticaId,
// dettPraticaId, TempisticaConstants.TIPO_PRATICA, dtInvio,
// serviceContext);
Date now = new Date(); Date now = new Date();
// FIX come sopra // FIX come sopra
if (avvisoExtra != null) { if (avvisoExtra != null) {
AvvisoLocalServiceUtil.updateAvvisoTempistica(avvisoExtra.getAvvisoId(), now); AvvisoLocalServiceUtil.updateAvvisoTempistica(avvisoExtra.getAvvisoId(), now);
} }
// fino qui // fino qui
AvvisoLocalServiceUtil.updateAvvisoTempistica(avviso.getAvvisoId(), now); AvvisoLocalServiceUtil.updateAvvisoTempistica(avviso.getAvvisoId(), now);
} else if (tipoDocumento.equals(StatoPraticaConstants.INTEGRAZIONE)) { } else if (tipoDocumento.equals(StatoPraticaConstants.INTEGRAZIONE)) {
long intPraticaId = controlloPratica.getIntPraticaId(); long intPraticaId = controlloPratica.getIntPraticaId();
@ -614,8 +493,7 @@ public class SchedulerInvioDocumento implements MessageListener {
ServiceContext serviceContext = getServiceContext(controlloPratica); ServiceContext serviceContext = getServiceContext(controlloPratica);
Tempistica tempistica = TempisticaLocalServiceUtil.getTempistica(serviceContext.getCompanyId(), Tempistica tempistica = TempisticaLocalServiceUtil.getTempistica(serviceContext.getCompanyId(),
intPraticaId, TempisticaConstants.TIPO_PRATICA, false); intPraticaId, TempisticaConstants.TIPO_PRATICA, false);
// tempstica = null se pratica con cambio di stato forzato e no // tempstica = null se pratica con cambio di stato forzato e no workflow
// workflow
if (tempistica != null) { if (tempistica != null) {
TempisticaLocalServiceUtil.stopTempistica(tempistica.getTempisticaId(), dtInvio); TempisticaLocalServiceUtil.stopTempistica(tempistica.getTempisticaId(), dtInvio);
} }
@ -630,8 +508,7 @@ public class SchedulerInvioDocumento implements MessageListener {
ServiceContext serviceContext = getServiceContext(controlloPratica); ServiceContext serviceContext = getServiceContext(controlloPratica);
Tempistica tempistica = TempisticaLocalServiceUtil.getTempistica(serviceContext.getCompanyId(), Tempistica tempistica = TempisticaLocalServiceUtil.getTempistica(serviceContext.getCompanyId(),
intPraticaId, TempisticaConstants.TIPO_PRATICA, false); intPraticaId, TempisticaConstants.TIPO_PRATICA, false);
// tempstica = null se pratica con cambio di stato forzato e no // tempstica = null se pratica con cambio di stato forzato e no workflow
// workflow
if (tempistica != null) { if (tempistica != null) {
TempisticaLocalServiceUtil.concludiTempistica(tempistica.getTempisticaId(), dtInvio); TempisticaLocalServiceUtil.concludiTempistica(tempistica.getTempisticaId(), dtInvio);
AvvisoLocalServiceUtil.updateAvvisoTempistica(avviso.getAvvisoId(), new Date()); AvvisoLocalServiceUtil.updateAvvisoTempistica(avviso.getAvvisoId(), new Date());
@ -644,87 +521,6 @@ public class SchedulerInvioDocumento implements MessageListener {
} }
private void sendToTecnico(Avviso avviso) throws SystemException, PortalException { 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) { private ServiceContext getServiceContext(ControlloPratica controlloPratica) {
@ -736,25 +532,18 @@ public class SchedulerInvioDocumento implements MessageListener {
return serviceContext; return serviceContext;
} }
/** // ADT: check congruenza WF - presenza dell'istruttore per pratiche importate da PORTOS1
* ADT: check congruenza WF - presenza dell'istruttore per pratiche
* importate da PORTOS1
*
*
* @param transitionName
* @param workflowTaskId
*/
private void checkPresenzaIstruttore(ControlloPratica controlloPratica, DettPratica integrazione, private void checkPresenzaIstruttore(ControlloPratica controlloPratica, DettPratica integrazione,
ServiceContext serviceContext, long userId, long workflowInstanceId) { ServiceContext serviceContext, long userId, long workflowInstanceId) {
try { try {
Map<String, Serializable> wfParameters = WorkflowUtil.getFormParameters(controlloPratica); Map<String, Serializable> wfParameters = WorkflowUtil.getFormParameters(controlloPratica);
String istruttore = (String) wfParameters.get("istruttore"); String istruttore = (String) wfParameters.get("istruttore");
_log.info("checkPresenzaIstruttore risposta integrazioni - istruttore presente sul workflow= " _log.info("checkPresenzaIstruttore risposta integrazioni - istruttore presente sul workflow= " + istruttore
+ istruttore + " - -controlloPratica=" + controlloPratica.getControlloPraticaId()); + " - -controlloPratica=" + controlloPratica.getControlloPraticaId());
if (istruttore == null) { if (istruttore == null) {
_log.info("checkPresenzaIstruttore gestione risposta integrazioni - rilevata incongrueza WF " _log.info("checkPresenzaIstruttore gestione risposta integrazioni - rilevata incongrueza WF "
+ "- istruttore non presente per dettpraticaid= " + "- istruttore non presente per dettpraticaid= " + integrazione.getDettPraticaId()
+ integrazione.getDettPraticaId()
+ " -controlloPratica=" + controlloPratica.getControlloPraticaId()); + " -controlloPratica=" + controlloPratica.getControlloPraticaId());
long istruttoreId = IntPraticaLocalServiceUtil.getIntPratica(integrazione.getIntPraticaId()) long istruttoreId = IntPraticaLocalServiceUtil.getIntPratica(integrazione.getIntPraticaId())
.getStatusByUserId(); .getStatusByUserId();
@ -765,8 +554,8 @@ public class SchedulerInvioDocumento implements MessageListener {
JSONSerializer jsonSerializer = JSONFactoryUtil.createJSONSerializer(); JSONSerializer jsonSerializer = JSONFactoryUtil.createJSONSerializer();
jsonFormParameters = jsonSerializer.serialize(parametri); jsonFormParameters = jsonSerializer.serialize(parametri);
serviceContext.setUserId(userId); serviceContext.setUserId(userId);
FormLogLocalServiceUtil.addFormLog(workflowInstanceId, 0l, "cambio-istruttore", FormLogLocalServiceUtil.addFormLog(workflowInstanceId, 0L, "cambio-istruttore", jsonFormParameters,
jsonFormParameters, serviceContext); serviceContext);
_log.info("checkPresenzaIstruttore OK per controlloPratica = " _log.info("checkPresenzaIstruttore OK per controlloPratica = "
+ controlloPratica.getControlloPraticaId()); + controlloPratica.getControlloPraticaId());
} else { } else {
@ -774,15 +563,9 @@ public class SchedulerInvioDocumento implements MessageListener {
+ controlloPratica.getControlloPraticaId() + " - istruttore non calcolato - "); + controlloPratica.getControlloPraticaId() + " - istruttore non calcolato - ");
} }
} }
} catch (Exception e) { } catch (Exception e) {
_log.error("checkPresenzaIstruttore KO per controlloPratica = " + controlloPratica.getControlloPraticaId()
_log.error("checkPresenzaIstruttore KO per controlloPratica = " + " [" + e.getMessage() + StringPool.COMMA_AND_SPACE + e.getCause() + StringPool.CLOSE_BRACKET);
+ controlloPratica.getControlloPraticaId() + " [" + e.getMessage() + " , " + e.getCause()
+ "]");
} }
} }
} }

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"; _methodName222 = "updateStatoPratica";
_methodParameterTypes222 = new String[] { _methodParameterTypes222 = new String[] { "long", "java.lang.String" };
"long", "long", "java.lang.String"
};
_methodName224 = "updateIntPraticaSorteggio"; _methodName224 = "updateIntPraticaSorteggio";
@ -690,7 +688,7 @@ public class IntPraticaLocalServiceClpInvoker {
if (_methodName222.equals(name) && if (_methodName222.equals(name) &&
Arrays.deepEquals(_methodParameterTypes222, parameterTypes)) { Arrays.deepEquals(_methodParameterTypes222, parameterTypes)) {
return IntPraticaLocalServiceUtil.updateStatoPratica(((Long)arguments[0]).longValue(), 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) && 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); resourceLocalService.addModelResources(entry, serviceContext);
// aggiorno int e dett pratica per avvio workflow // aggiorno int e dett pratica per avvio workflow
IntPratica intPratica = intPraticaLocalService.updateStatoPratica(intPraticaId, dettPraticaId, IntPratica intPratica = intPraticaLocalService.updateStatoPratica(intPraticaId,
StatoPraticaConstants.SOTTOPOSTA_A_PARERE); StatoPraticaConstants.SOTTOPOSTA_A_PARERE);
if (updateFlagControlloObbligatorio && Constants.TIPO_PRATICA_DEPOSITO.equals(intPratica.getTipoPratica())) { if (updateFlagControlloObbligatorio && Constants.TIPO_PRATICA_DEPOSITO.equals(intPratica.getTipoPratica())) {
intPratica.setControlloObbligatorio(true); intPratica.setControlloObbligatorio(true);
@ -449,28 +449,21 @@ public class ControlloPraticaLocalServiceImpl extends ControlloPraticaLocalServi
default: default:
break; break;
} }
if (updateIntPratica) { if (updateIntPratica) {
intPraticaLocalService.updateStatoPratica(controlloPratica.getIntPraticaId(), intPraticaLocalService.updateStatoPratica(controlloPratica.getIntPraticaId(), esito);
controlloPratica.getDettPraticaId(), esito);
} }
} }
Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class); Indexer indexer = IndexerRegistryUtil.getIndexer(ControlloPratica.class);
indexer.reindex(controlloPratica); indexer.reindex(controlloPratica);
return ramoWorkflow; return ramoWorkflow;
} }
private String getEsitoFinale(long controlloPraticaId, Map<String, Serializable> workflowContext) private String getEsitoFinale(long controlloPraticaId, Map<String, Serializable> workflowContext)
throws PortalException, SystemException { throws PortalException, SystemException {
// Map<String, String> parametri = (Map<String, String>)
// workflowContext.get("CONTEXT_TASK_FORM_PARAMETERS");
ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil.getControlloPratica(controlloPraticaId); ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil.getControlloPratica(controlloPraticaId);
Map<String, Serializable> parametri = WorkflowUtil.getFormParameters(controlloPratica); Map<String, Serializable> parametri = WorkflowUtil.getFormParameters(controlloPratica);
String esitoScelta = (String) parametri.get(WorkflowConstants.WORKFLOW_TASKNAME_ESITO); String esitoScelta = (String) parametri.get(WorkflowConstants.WORKFLOW_TASKNAME_ESITO);
if (StatoPraticaConstants.CONFORME.equalsIgnoreCase(esitoScelta) if (StatoPraticaConstants.CONFORME.equalsIgnoreCase(esitoScelta)
&& AzioniPraticheUtil.isAutorizzazione(controlloPratica.getIntPraticaId())) { && AzioniPraticheUtil.isAutorizzazione(controlloPratica.getIntPraticaId())) {
esitoScelta = StatoPraticaConstants.AUTORIZZATA; esitoScelta = StatoPraticaConstants.AUTORIZZATA;
@ -478,7 +471,6 @@ public class ControlloPraticaLocalServiceImpl extends ControlloPraticaLocalServi
&& AzioniPraticheUtil.isAutorizzazione(controlloPratica.getIntPraticaId())) { && AzioniPraticheUtil.isAutorizzazione(controlloPratica.getIntPraticaId())) {
esitoScelta = StatoPraticaConstants.NON_AUTORIZZATA; esitoScelta = StatoPraticaConstants.NON_AUTORIZZATA;
} }
return esitoScelta; return esitoScelta;
} }
@ -497,13 +489,10 @@ public class ControlloPraticaLocalServiceImpl extends ControlloPraticaLocalServi
throws PortalException, SystemException { throws PortalException, SystemException {
ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil.getControlloPratica(controlloPraticaId); ControlloPratica controlloPratica = ControlloPraticaLocalServiceUtil.getControlloPratica(controlloPraticaId);
JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
jsonObject.put("istruttore", jsonArray); jsonObject.put("istruttore", jsonArray);
Role role = RoleLocalServiceUtil.getRole(controlloPratica.getCompanyId(), "portos_istruttore"); Role role = RoleLocalServiceUtil.getRole(controlloPratica.getCompanyId(), "portos_istruttore");
List<UserGroupRole> userGroupRoles = UserGroupRoleLocalServiceUtil.getUserGroupRolesByGroupAndRole( List<UserGroupRole> userGroupRoles = UserGroupRoleLocalServiceUtil.getUserGroupRolesByGroupAndRole(
controlloPratica.getGroupId(), role.getRoleId()); controlloPratica.getGroupId(), role.getRoleId());
for (UserGroupRole userGroupRole : userGroupRoles) { for (UserGroupRole userGroupRole : userGroupRoles) {
@ -513,7 +502,6 @@ public class ControlloPraticaLocalServiceImpl extends ControlloPraticaLocalServi
istruttore.put("default", false); istruttore.put("default", false);
jsonArray.put(istruttore); jsonArray.put(istruttore);
} }
return jsonObject.toString(); 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 @Override
@Indexable(type = IndexableType.REINDEX) @Indexable(type = IndexableType.REINDEX)
public IntPratica updateStatoPratica(long intPraticaId, long dettPraticaId, String statoPratica) public IntPratica updateStatoPratica(long intPraticaId, String statoPratica) throws PortalException,
throws PortalException, SystemException { SystemException {
IntPratica intPratica = intPraticaLocalService.getIntPratica(intPraticaId); IntPratica intPratica = intPraticaLocalService.getIntPratica(intPraticaId);
intPratica.setModifiedDate(new Date()); intPratica.setModifiedDate(new Date());
intPratica.setStatoPratica(statoPratica); intPratica.setStatoPratica(statoPratica);
return intPraticaLocalService.updateIntPratica(intPratica); return intPraticaLocalService.updateIntPratica(intPratica);
} }
@ -760,6 +756,7 @@ public class IntPraticaLocalServiceImpl extends IntPraticaLocalServiceBaseImpl {
@Override @Override
public IntPratica updateIntPraticaSorteggio(long intPraticaId, Date dtSorteggio) throws SystemException { public IntPratica updateIntPraticaSorteggio(long intPraticaId, Date dtSorteggio) throws SystemException {
// TODO vedere se va cambiato lo stato // TODO vedere se va cambiato lo stato
return updateIntPraticaSorteggio(intPraticaId, dtSorteggio, null); 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. * 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 * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
* GNU Lesser General Public License as published by the Free Software Foundation; either version * Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option)
* 2.1 of the License, or (at your option) any later version. * any later version.
* *
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* Lesser General Public License for more details. * details.
*/ */
package it.tref.liferay.portos.bo.service.impl; 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. * The implementation of the int pratica remote service.
* *
* <p> * <p>
* All custom service methods should be put in this class. Whenever methods are added, rerun * All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy
* ServiceBuilder to copy their definitions into the * their definitions into the {@link it.tref.liferay.portos.bo.service.IntPraticaService} interface.
* {@link it.tref.liferay.portos.bo.service.IntPraticaService} interface.
* *
* <p> * <p>
* This is a remote service. Methods of this service are expected to have security checks based on * This is a remote service. Methods of this service are expected to have security checks based on the propagated JAAS
* the propagated JAAS credentials because this service can be accessed remotely. * credentials because this service can be accessed remotely.
* </p> * </p>
* *
* @author Davide Barbagallo, 3F Consulting * @author Davide Barbagallo, 3F Consulting
@ -53,16 +52,17 @@ import com.liferay.portal.service.ServiceContext;
public class IntPraticaServiceImpl extends IntPraticaServiceBaseImpl { public class IntPraticaServiceImpl extends IntPraticaServiceBaseImpl {
/* /*
* NOTE FOR DEVELOPERS: Never reference this interface directly. Always use {@link * NOTE FOR DEVELOPERS: Never reference this interface directly. Always use {@link
* it.tref.liferay.portos.bo.service.IntPraticaServiceUtil} to access the int pratica remote * it.tref.liferay.portos.bo.service.IntPraticaServiceUtil} to access the int pratica remote service.
* service.
*/ */
@Override
public IntPratica getIntPratica(long intPraticaId) throws PortalException, SystemException { public IntPratica getIntPratica(long intPraticaId) throws PortalException, SystemException {
// TODO: Permessi // TODO: Permessi
return intPraticaLocalService.getIntPratica(intPraticaId); return intPraticaLocalService.getIntPratica(intPraticaId);
} }
@Override
public void deleteIntPratica(long intPraticaId, long userId) throws PortalException, SystemException { public void deleteIntPratica(long intPraticaId, long userId) throws PortalException, SystemException {
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId); 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 { public void sospendiPratica(long intPraticaId, boolean sospesa) throws PortalException, SystemException {
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId); 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, @Override
SystemException { public void cambiaTitolare(long intPraticaId, long soggettoId, ServiceContext serviceContext)
throws PortalException, SystemException {
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId); IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId);
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()); Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId());
@ -110,95 +111,108 @@ public class IntPraticaServiceImpl extends IntPraticaServiceBaseImpl {
intPraticaLocalService.cambiaTitolare(intPraticaId, soggettoId, serviceContext); intPraticaLocalService.cambiaTitolare(intPraticaId, soggettoId, serviceContext);
} }
@Override
public void updateStatoPratica(long intPraticaId, String statoPratica) throws PortalException, SystemException { public void updateStatoPratica(long intPraticaId, String statoPratica) throws PortalException, SystemException {
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId); IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId);
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()); Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId());
IntPraticaPermission.check(getPermissionChecker(), territorio.getGroupId(), ActionKeys.CAMBIO_STATO); 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 { public List<IntPratica> search(List<Long> groupIds, int start, int end) throws SystemException {
// TODO Modificare tramite Indexer // TODO Modificare tramite Indexer
// TODO Aggiungere controllo permessi // TODO Aggiungere controllo permessi
return intPraticaLocalService.search(groupIds, start, end); return intPraticaLocalService.search(groupIds, start, end);
} }
@Override
public int countSearch(List<Long> groupIds) throws SystemException { public int countSearch(List<Long> groupIds) throws SystemException {
// TODO Modificare tramite Indexer // TODO Modificare tramite Indexer
// TODO Aggiungere controllo permessi // TODO Aggiungere controllo permessi
return intPraticaLocalService.countSearch(groupIds); return intPraticaLocalService.countSearch(groupIds);
} }
@Override
public List<IntPratica> findByCompanyIdSoggettoProgetti(long companyId, long soggettoId) throws SystemException, public List<IntPratica> findByCompanyIdSoggettoProgetti(long companyId, long soggettoId) throws SystemException,
PortalException { PortalException {
return intPraticaLocalService.findByCompanyIdSoggettoProgetti(companyId, soggettoId); 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); return intPraticaLocalService.countByCompanyIdSoggettoProgetti(companyId, soggettoId);
} }
@Override
public List<IntPratica> findByCompanyIdSoggettoArchivio(long companyId, long soggettoId) throws SystemException, public List<IntPratica> findByCompanyIdSoggettoArchivio(long companyId, long soggettoId) throws SystemException,
PortalException { PortalException {
return intPraticaLocalService.findByCompanyIdSoggettoArchivio(companyId, soggettoId); 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); return intPraticaLocalService.countByCompanyIdSoggettoArchivio(companyId, soggettoId);
} }
@Override
public List<IntPratica> findByCompanyIdSoggettoAltriProgetti(long companyId, long soggettoId, int start, int end) public List<IntPratica> findByCompanyIdSoggettoAltriProgetti(long companyId, long soggettoId, int start, int end)
throws SystemException, PortalException { throws SystemException, PortalException {
return intPraticaLocalService.findByCompanyIdSoggettoAltriProgetti(companyId, soggettoId, start, end); return intPraticaLocalService.findByCompanyIdSoggettoAltriProgetti(companyId, soggettoId, start, end);
} }
@Override
public int countByCompanyIdSoggettoAltriProgetti(long companyId, long soggettoId) throws SystemException, public int countByCompanyIdSoggettoAltriProgetti(long companyId, long soggettoId) throws SystemException,
PortalException { PortalException {
return intPraticaLocalService.countByCompanyIdSoggettoAltriProgetti(companyId, soggettoId); return intPraticaLocalService.countByCompanyIdSoggettoAltriProgetti(companyId, soggettoId);
} }
@Override
public List<IntPratica> findByCanAddFineLavori(long companyId, String codiceFiscale, int start, int end) public List<IntPratica> findByCanAddFineLavori(long companyId, String codiceFiscale, int start, int end)
throws SystemException, PortalException { throws SystemException, PortalException {
return intPraticaLocalService.findByCanAddFineLavori(companyId, codiceFiscale, start, end); return intPraticaLocalService.findByCanAddFineLavori(companyId, codiceFiscale, start, end);
} }
@Override
public int countByCanAddFineLavori(long companyId, String codiceFiscale) throws SystemException, PortalException { public int countByCanAddFineLavori(long companyId, String codiceFiscale) throws SystemException, PortalException {
return intPraticaLocalService.countByCanAddFineLavori(companyId, codiceFiscale); return intPraticaLocalService.countByCanAddFineLavori(companyId, codiceFiscale);
} }
@Override
public List<IntPratica> findByCanAddCollaudo(long companyId, String codiceFiscale, int start, int end) public List<IntPratica> findByCanAddCollaudo(long companyId, String codiceFiscale, int start, int end)
throws SystemException, PortalException { throws SystemException, PortalException {
return intPraticaLocalService.findByCanAddCollaudo(companyId, codiceFiscale, start, end); return intPraticaLocalService.findByCanAddCollaudo(companyId, codiceFiscale, start, end);
} }
@Override
public int countByCanAddCollaudo(long companyId, String codiceFiscale) throws SystemException, PortalException { public int countByCanAddCollaudo(long companyId, String codiceFiscale) throws SystemException, PortalException {
return intPraticaLocalService.countByCanAddCollaudo(companyId, codiceFiscale); return intPraticaLocalService.countByCanAddCollaudo(companyId, codiceFiscale);
} }
@Override
public FileEntry allegaFileAnnullamento(long intPraticaId, byte[] content, String sourceFileName, public FileEntry allegaFileAnnullamento(long intPraticaId, byte[] content, String sourceFileName,
String jsonFirmatari, ServiceContext serviceContext) throws SystemException, PortalException, IOException { 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 { public void completeAnnullamento(long intPraticaId, long userId) throws PortalException, SystemException {
if (!AzioniPraticheUtil.isAllowedAction(intPraticaId, AzioniPraticheUtil.ACTION_ANNULLA) if (!AzioniPraticheUtil.isAllowedAction(intPraticaId, AzioniPraticheUtil.ACTION_ANNULLA)
@ -208,12 +222,14 @@ public class IntPraticaServiceImpl extends IntPraticaServiceBaseImpl {
intPraticaLocalService.completeAnnullamento(intPraticaId); intPraticaLocalService.completeAnnullamento(intPraticaId);
} }
@Override
public void cambiaIstruttore(long intPraticaId, long controlloPraticaId, long istruttoreId) throws PortalException, public void cambiaIstruttore(long intPraticaId, long controlloPraticaId, long istruttoreId) throws PortalException,
SystemException { SystemException {
intPraticaLocalService.cambiaIstruttore(intPraticaId, controlloPraticaId, istruttoreId); intPraticaLocalService.cambiaIstruttore(intPraticaId, controlloPraticaId, istruttoreId);
} }
@Override
public String geosisma(long intPraticaId) throws PortalException, SystemException { public String geosisma(long intPraticaId) throws PortalException, SystemException {
JSONObject json = JSONFactoryUtil.createJSONObject(); 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.protocollo.model.Protocollo.TipoProtocollo;
import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants; import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants;
import java.io.FileNotFoundException; import java.io.ByteArrayInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.text.ParseException; 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.exception.SystemException;
import com.liferay.portal.kernel.json.JSONObject; import com.liferay.portal.kernel.json.JSONObject;
import com.liferay.portal.kernel.repository.model.FileEntry; 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.GetterUtil;
import com.liferay.portal.kernel.util.ParamUtil; import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.StreamUtil; import com.liferay.portal.kernel.util.StreamUtil;
@ -53,6 +56,7 @@ import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil;
public class ProtocollazioneUtil { public class ProtocollazioneUtil {
public static String protocollaPartenza(Avviso avviso, Long fileEntryId) throws Exception { public static String protocollaPartenza(Avviso avviso, Long fileEntryId) throws Exception {
String protocollo = null; String protocollo = null;
InputStream inputStream = null; InputStream inputStream = null;
try { try {
@ -72,8 +76,8 @@ public class ProtocollazioneUtil {
allegato.setFileId("0"); allegato.setFileId("0");
allegato.setFileSha256(sha256); allegato.setFileSha256(sha256);
} }
// utilizzato anche come discriminate tra la 1a e la 2a chiamata 1a recupero numero protocollo -> 1 allegato // utilizzato anche come discriminate tra la 1ª e la 2ª chiamata 1ª recupero numero protocollo -> 1 allegato
// finto 2a aggiorno dati del documento prodotto -> 2 allegati, il 1o giusto e il 2o per recupero num // finto 2ª aggiorno dati del documento prodotto -> 2 allegati, il 1º giusto e il 2º per recupero num
// protocollo // protocollo
Protocollo protocolloBean = new Protocollo(); Protocollo protocolloBean = new Protocollo();
protocolloBean.setOggetto(generaOggettoProtocollo(avviso.getClassName(), avviso.getAvvisoId())); protocolloBean.setOggetto(generaOggettoProtocollo(avviso.getClassName(), avviso.getAvvisoId()));
@ -92,6 +96,7 @@ public class ProtocollazioneUtil {
} }
public static String protocollaArrivo(Object praticaInstance, String title) throws Exception { public static String protocollaArrivo(Object praticaInstance, String title) throws Exception {
long groupId = 0L; long groupId = 0L;
long praticaId = 0L; long praticaId = 0L;
long companyId = 0L; long companyId = 0L;
@ -125,9 +130,6 @@ public class ProtocollazioneUtil {
if (Validator.isNull(sha256)) { if (Validator.isNull(sha256)) {
InputStream inputStream = null; InputStream inputStream = null;
try { try {
if (docPratica.getDlFileEntryId() == 0L) {
FilesImporter.importaFile(docPratica.getDocPraticaId(), DocPratica.class.getName());
}
FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(docPratica.getDlFileEntryId()); FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(docPratica.getDlFileEntryId());
inputStream = DLFileEntryLocalServiceUtil.getFileAsStream(fileEntry.getFileEntryId(), inputStream = DLFileEntryLocalServiceUtil.getFileAsStream(fileEntry.getFileEntryId(),
fileEntry.getVersion()); fileEntry.getVersion());
@ -156,6 +158,7 @@ public class ProtocollazioneUtil {
public static String protocollaArrivoAccessoAtti(long groupId, long companyId, String userName, long accessoAttiId, public static String protocollaArrivoAccessoAtti(long groupId, long companyId, String userName, long accessoAttiId,
String className) throws Exception { String className) throws Exception {
List<File> allegati = new ArrayList<File>(); List<File> allegati = new ArrayList<File>();
File allegato = new File(); File allegato = new File();
String doc = String.valueOf(accessoAttiId); String doc = String.valueOf(accessoAttiId);
@ -176,6 +179,7 @@ public class ProtocollazioneUtil {
} }
public static String generaOggettoProtocollo(String className, long classPk) { public static String generaOggettoProtocollo(String className, long classPk) {
try { try {
Avviso avviso = AvvisoLocalServiceUtil.fetchAvviso(classPk); Avviso avviso = AvvisoLocalServiceUtil.fetchAvviso(classPk);
if (Validator.isNotNull(avviso)) { if (Validator.isNotNull(avviso)) {
@ -187,24 +191,28 @@ public class ProtocollazioneUtil {
return "Oggetto: " + className + StringPool.SPACE + classPk; return "Oggetto: " + className + StringPool.SPACE + classPk;
} }
public static List<OggettoProtocollo> csvToOggettoProtocollo(java.io.File file) throws FileNotFoundException, private static final String[] FILE_PROTOCOLLO_HEADER = { "id", "mittente/destinatario id", "ufficio id", "oggetto",
IOException, ParseException {
String[] FILE_PROTOCOLLO_HEADER = { "id", "mittente/destinatario id", "ufficio id", "oggetto",
"numero fascicolo", "data inserimento", "tipo" }; "numero fascicolo", "data inserimento", "tipo" };
private static List<OggettoProtocollo> csvToOggettoProtocollo(byte[] bytes) throws IOException, ParseException {
CSVFormat format = CSVFormat.EXCEL.withTrailingDelimiter().withHeader(FILE_PROTOCOLLO_HEADER) CSVFormat format = CSVFormat.EXCEL.withTrailingDelimiter().withHeader(FILE_PROTOCOLLO_HEADER)
.withSkipHeaderRecord().withIgnoreEmptyLines().withIgnoreSurroundingSpaces(); .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<>(); List<OggettoProtocollo> listaOggettoProtocollo = new ArrayList<>();
for (CSVRecord csvRecord : records) { reader.close();
listaOggettoProtocollo.add(new OggettoProtocollo(csvRecord.get("id"), csvRecord for (CSVRecord record : records) {
.get("mittente/destinatario id"), csvRecord.get("ufficio id"), csvRecord.get("oggetto"), csvRecord listaOggettoProtocollo.add(new OggettoProtocollo(record.get("id"), record.get("mittente/destinatario id"),
.get("numero fascicolo"), csvRecord.get("data inserimento"), csvRecord.get("tipo"))); record.get("ufficio id"), record.get("oggetto"), record.get("numero fascicolo"), record
.get("data inserimento"), record.get("tipo")));
} }
return listaOggettoProtocollo; return listaOggettoProtocollo;
} }
public static List<OggettoProtocollo> searchProtocolli(HttpServletRequest request, long companyId, long userId) { 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 ufficioIds = StringPool.BLANK;
String anno = ParamUtil.getString(request, "annoRiferimento"); String anno = ParamUtil.getString(request, "annoRiferimento");
String numeroProtocollo = ParamUtil.getString(request, "numeroProtocollo"); String numeroProtocollo = ParamUtil.getString(request, "numeroProtocollo");
@ -239,19 +247,14 @@ public class ProtocollazioneUtil {
URL url = new URL(urlCSVService + data); URL url = new URL(urlCSVService + data);
HttpURLConnection conn = (HttpURLConnection) url.openConnection(); HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true); conn.setDoOutput(true);
conn.setRequestMethod("POST"); conn.setRequestMethod(HttpMethods.POST);
conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestProperty(HttpHeaders.CONTENT_TYPE, ContentTypes.APPLICATION_JSON);
if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) { if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode()); throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
} }
byte[] bytes = IOUtils.toByteArray(conn.getInputStream()); 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(); conn.disconnect();
return ProtocollazioneUtil.csvToOggettoProtocollo(tempFile); return csvToOggettoProtocollo(bytes);
} catch (Exception e) { } catch (Exception e) {
} }
return result; 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=\ application.startup.events=\
it.tref.liferay.portos.bo.startup.RoleUpdateAction,\ it.tref.liferay.portos.bo.startup.RoleUpdateAction,\
it.tref.liferay.portos.bo.startup.KaleoListenereStartupAction,\ 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.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.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 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.namespace=portos_bo
build.number=2569 build.number=2574
build.date=1618578205435 build.date=1618926051044
build.auto.upgrade=true 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; 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.PortalException;
import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil; 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.repository.model.FileEntry;
import com.liferay.portal.kernel.servlet.HttpHeaders; import com.liferay.portal.kernel.servlet.HttpHeaders;
import com.liferay.portal.kernel.servlet.SessionErrors; 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.FileUtil;
import com.liferay.portal.kernel.util.ParamUtil; import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.StreamUtil; 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.util.Validator;
import com.liferay.portal.kernel.zip.ZipWriter; import com.liferay.portal.kernel.zip.ZipWriter;
import com.liferay.portal.kernel.zip.ZipWriterFactoryUtil; 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.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil;
import com.liferay.util.bridges.mvc.MVCPortlet; 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 { public class AllegatiPraticaPortlet extends MVCPortlet {
private static Log _log = LogFactoryUtil.getLog(AllegatiPraticaPortlet.class); private static Log _log = LogFactoryUtil.getLog(AllegatiPraticaPortlet.class);
@ -68,7 +61,6 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
long docPraticaId = ParamUtil.getLong(actionRequest, "docPraticaId"); long docPraticaId = ParamUtil.getLong(actionRequest, "docPraticaId");
String comingFrom = ParamUtil.getString(actionRequest, "comingFrom"); String comingFrom = ParamUtil.getString(actionRequest, "comingFrom");
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
// TODO rivedere assolutamente il controllo // TODO rivedere assolutamente il controllo
boolean controllo = false; boolean controllo = false;
if (comingFrom.equalsIgnoreCase("page_fine_lavori") || comingFrom.equalsIgnoreCase("page_collaudo")) { 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, controllo = DelegheUtil.hasDelegaDeleteFile(serviceContext.getUserId(), docPraticaId,
"page_geologo".equalsIgnoreCase(comingFrom)); "page_geologo".equalsIgnoreCase(comingFrom));
} }
if (controllo) { if (controllo) {
DocPraticaServiceUtil.deleteDocPratica(docPraticaId); DocPraticaServiceUtil.deleteDocPratica(docPraticaId);
} }
@ -86,90 +77,67 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
public void uploadAllegato(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { public void uploadAllegato(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest); UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest);
long classPk = ParamUtil.getLong(uploadRequest, "classPk"); long classPk = ParamUtil.getLong(uploadRequest, "classPk");
String className = ParamUtil.getString(uploadRequest, "className"); String className = ParamUtil.getString(uploadRequest, "className");
long intPraticaId = ParamUtil.getLong(uploadRequest, "intPraticaId"); long intPraticaId = ParamUtil.getLong(uploadRequest, "intPraticaId");
try { try {
User user = PortalUtil.getUser(actionRequest); User user = PortalUtil.getUser(actionRequest);
ServiceContext serviceContext = ServiceContextFactory.getInstance(uploadRequest); ServiceContext serviceContext = ServiceContextFactory.getInstance(uploadRequest);
String tipologia = ParamUtil.getString(uploadRequest, "tipologia"); String tipologia = ParamUtil.getString(uploadRequest, "tipologia");
String sourceFileName = uploadRequest.getFileName("docFile"); String sourceFileName = uploadRequest.getFileName("docFile");
boolean applicaFirma = ParamUtil.getBoolean(uploadRequest, "applicaFirma"); boolean applicaFirma = ParamUtil.getBoolean(uploadRequest, "applicaFirma");
File file = uploadRequest.getFile("docFile"); File file = uploadRequest.getFile("docFile");
if (Validator.isNotNull(sourceFileName)) { if (Validator.isNotNull(sourceFileName)) {
// validazione: solo alcune estensioni // validazione: solo alcune estensioni
String ext = FileUtil.getExtension(sourceFileName); String ext = FileUtil.getExtension(sourceFileName);
if (!ext.equalsIgnoreCase("p7m") && !ext.equalsIgnoreCase("pdf") if (!ext.equalsIgnoreCase("p7m") && !ext.equalsIgnoreCase("pdf") && !ext.equalsIgnoreCase("dwg")) {
&& !ext.equalsIgnoreCase("dwg")) {
SessionErrors.add(actionRequest, "error.geniocivilefe.pratica.allegato.ext.valid"); SessionErrors.add(actionRequest, "error.geniocivilefe.pratica.allegato.ext.valid");
} }
// lunghezza fissata a 200 // lunghezza fissata a 200
if (sourceFileName.length() > 200) { if (sourceFileName.length() > 200) {
SessionErrors.add(actionRequest, "error.geniocivilefe.pratica.allegato.length.valid"); SessionErrors.add(actionRequest, "error.geniocivilefe.pratica.allegato.length.valid");
} }
// Manifattura Web Group, mofidica per rendere la dimensione // Manifattura Web Group, mofidica per rendere la dimensione massima degli allegati configurabile da
// massima degli allegati configurabile // pannello di controllo. In origine era hardcoded a 20971520 byte.
// da pannello di controllo. In origine era hardcoded a 20971520
// byte.
Company company = PortalUtil.getCompany(actionRequest); Company company = PortalUtil.getCompany(actionRequest);
int dimensioneMassimaAllegati = (int) ((Short) company.getExpandoBridge().getAttribute( int dimensioneMassimaAllegati = ((Short) company.getExpandoBridge().getAttribute(
Constants.COMPANY_CUSTOM_FIELD_DIMENSIONE_MASSIMA_ALLEGATI_IN_MIB, false)) Constants.COMPANY_CUSTOM_FIELD_DIMENSIONE_MASSIMA_ALLEGATI_IN_MIB, false)).shortValue();
.shortValue();
if (file.length() > dimensioneMassimaAllegati * 1048576) { if (file.length() > dimensioneMassimaAllegati * 1048576) {
SessionErrors.add(actionRequest, "error.geniocivilefe.pratica.allegato.dimension.valid"); SessionErrors.add(actionRequest, "error.geniocivilefe.pratica.allegato.dimension.valid");
} }
} else { } else {
SessionErrors.add(actionRequest, "error.geniocivilefe.pratica.allegato.is.request"); SessionErrors.add(actionRequest, "error.geniocivilefe.pratica.allegato.is.request");
} }
if (SessionErrors.isEmpty(actionRequest)) { if (SessionErrors.isEmpty(actionRequest)) {
// Si controlla che il tipo allegato sia di quelli che prevedono un solo file
// Si controlla che il tipo allegato sia di quelli che prevedono if (file != null && !sourceFileName.equals(StringPool.BLANK)) {
// un solo file
if (file != null && !sourceFileName.equals("")) {
byte[] bites = FileUtil.getBytes(file); byte[] bites = FileUtil.getBytes(file);
boolean praticaValidata = false; boolean praticaValidata = false;
String sha256 = DigestUtils.sha256Hex(bites); String sha256 = DigestUtils.sha256Hex(bites);
String version = "0"; String version = "0";
String descLong = sourceFileName; String descLong = sourceFileName;
boolean aggiornato = false; boolean aggiornato = false;
String jsonFirmatari = ""; String jsonFirmatari = StringPool.BLANK;
FirmeBean firmeBean = new FirmeBean(); FirmeBean firmeBean = new FirmeBean();
if (applicaFirma) { if (applicaFirma) {
jsonFirmatari = FirmeUtil.addFirma(firmeBean, user.getScreenName()); jsonFirmatari = FirmeUtil.addFirma(firmeBean, user.getScreenName());
} else { } else {
jsonFirmatari = FirmeUtil.serialize(firmeBean); jsonFirmatari = FirmeUtil.serialize(firmeBean);
} }
long intPraticaIdRimozione = 0L;
long intPraticaIdRimozione = 0; long dettPraticaIdRimozione = 0L;
long dettPraticaIdRimozione = 0;
Date dtDataRimozione = null; Date dtDataRimozione = null;
// TODO attenzione perche' questo controllo potrebbe non // TODO attenzione perche' questo controllo potrebbe non andare bene per integrazioni e varianti
// andare bene per integrazioni e
// varianti
boolean isUnivoco = DocumentiPraticaUtil.getDocUnivoci().contains(tipologia); boolean isUnivoco = DocumentiPraticaUtil.getDocUnivoci().contains(tipologia);
if (isUnivoco if (isUnivoco && DocPraticaLocalServiceUtil.countByClassPk_Tipologia(classPk, tipologia) > 0) {
&& DocPraticaLocalServiceUtil.countByClassPk_Tipologia(classPk, tipologia) > 0) {
SessionErrors.add(actionRequest, "error.geniocivilefe.allegato.univoco"); SessionErrors.add(actionRequest, "error.geniocivilefe.allegato.univoco");
} }
if (SessionErrors.isEmpty(actionRequest)) { if (SessionErrors.isEmpty(actionRequest)) {
DocPraticaServiceUtil.addDocPratica(user.getUserId(), className, classPk, DocPraticaServiceUtil.addDocPratica(user.getUserId(), className, classPk, intPraticaId, bites,
intPraticaId, bites, sourceFileName, version, praticaValidata, descLong, sourceFileName, version, praticaValidata, descLong, tipologia, sha256, aggiornato,
tipologia, sha256, aggiornato, jsonFirmatari, intPraticaIdRimozione, jsonFirmatari, intPraticaIdRimozione, dettPraticaIdRimozione, dtDataRimozione,
dettPraticaIdRimozione, dtDataRimozione, serviceContext); serviceContext);
} }
} }
} }
PortalUtil.copyRequestParameters(actionRequest, actionResponse); PortalUtil.copyRequestParameters(actionRequest, actionResponse);
@ -191,7 +159,6 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
long docPraticaId = ParamUtil.getLong(actionRequest, "docPraticaId"); long docPraticaId = ParamUtil.getLong(actionRequest, "docPraticaId");
String comingFrom = ParamUtil.getString(actionRequest, "comingFrom"); String comingFrom = ParamUtil.getString(actionRequest, "comingFrom");
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
// TODO rivedere assolutamente il controllo // TODO rivedere assolutamente il controllo
boolean controllo = false; boolean controllo = false;
if (comingFrom.equalsIgnoreCase("page_fine_lavori") || comingFrom.equalsIgnoreCase("page_collaudo") 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, controllo = DelegheUtil.hasDelegaFirma(serviceContext.getUserId(), docPraticaId,
"page_geologica".equalsIgnoreCase(comingFrom)); "page_geologica".equalsIgnoreCase(comingFrom));
} }
if (controllo) { if (controllo) {
User user = UserLocalServiceUtil.getUser(serviceContext.getUserId()); User user = UserLocalServiceUtil.getUser(serviceContext.getUserId());
DocPraticaLocalServiceUtil.addFirma(docPraticaId, user.getScreenName()); DocPraticaLocalServiceUtil.addFirma(docPraticaId, user.getScreenName());
@ -213,7 +179,6 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
long docPraticaId = ParamUtil.getLong(actionRequest, "docPraticaId"); long docPraticaId = ParamUtil.getLong(actionRequest, "docPraticaId");
String comingFrom = ParamUtil.getString(actionRequest, "comingFrom"); String comingFrom = ParamUtil.getString(actionRequest, "comingFrom");
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
// TODO rivedere assolutamente il controllo // TODO rivedere assolutamente il controllo
boolean controllo = false; boolean controllo = false;
if (comingFrom.equalsIgnoreCase("page_fine_lavori") || comingFrom.equalsIgnoreCase("page_collaudo")) { 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, controllo = DelegheUtil.hasDelegaFirma(serviceContext.getUserId(), docPraticaId,
"page_geologica".equalsIgnoreCase(comingFrom)); "page_geologica".equalsIgnoreCase(comingFrom));
} }
if (controllo) { if (controllo) {
User user = UserLocalServiceUtil.getUser(serviceContext.getUserId()); User user = UserLocalServiceUtil.getUser(serviceContext.getUserId());
DocPraticaLocalServiceUtil.removeFirma(docPraticaId, user.getScreenName()); DocPraticaLocalServiceUtil.removeFirma(docPraticaId, user.getScreenName());
} }
} }
public void invalidaAllegato(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { public void invalidaAllegato(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
@ -236,20 +199,9 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
long docPraticaId = ParamUtil.getLong(actionRequest, "docPraticaId"); long docPraticaId = ParamUtil.getLong(actionRequest, "docPraticaId");
DocPratica docPratica = DocPraticaServiceUtil.getDocPratica(docPraticaId); DocPratica docPratica = DocPraticaServiceUtil.getDocPratica(docPraticaId);
long dettPraticaIdRimozione = ParamUtil.getLong(actionRequest, "classPk"); long dettPraticaIdRimozione = ParamUtil.getLong(actionRequest, "classPk");
docPratica.setDettPraticaIdRimozione(dettPraticaIdRimozione); // setto // setto solo il dettPraticaRimozione. La rimozione diventa definitiva al completamento della variante
// solo docPratica.setDettPraticaIdRimozione(dettPraticaIdRimozione);
// il
// dettPraticaRimozione.
// La
// rimozione
// diventa
// definitiva
// al
// completamento
// della
// variante
DocPraticaLocalServiceUtil.updateDocPratica(docPratica); DocPraticaLocalServiceUtil.updateDocPratica(docPratica);
} catch (PortalException | SystemException e) { } catch (PortalException | SystemException e) {
_log.error(e, e); _log.error(e, e);
throw e; throw e;
@ -263,7 +215,6 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
DocPratica docPratica = DocPraticaServiceUtil.getDocPratica(docPraticaId); DocPratica docPratica = DocPraticaServiceUtil.getDocPratica(docPraticaId);
docPratica.setDettPraticaIdRimozione(0l); docPratica.setDettPraticaIdRimozione(0l);
DocPraticaLocalServiceUtil.updateDocPratica(docPratica); DocPraticaLocalServiceUtil.updateDocPratica(docPratica);
} catch (PortalException | SystemException e) { } catch (PortalException | SystemException e) {
_log.error(e, e); _log.error(e, e);
throw e; throw e;
@ -271,13 +222,12 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
} }
@Override @Override
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException,
throws IOException, PortletException { PortletException {
String id = resourceRequest.getResourceID(); String id = resourceRequest.getResourceID();
try { try {
if ("downloadAllDocPratica".equals(id) || "downloadAllDocPraticas".equals(id)) { if ("downloadAllDocPratica".equals(id) || "downloadAllDocPraticas".equals(id)) {
long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId"); long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId");
long classPk = ParamUtil.getLong(resourceRequest, "classPk"); long classPk = ParamUtil.getLong(resourceRequest, "classPk");
String comingFrom = ParamUtil.getString(resourceRequest, "comingFrom"); String comingFrom = ParamUtil.getString(resourceRequest, "comingFrom");
@ -285,34 +235,26 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
List<DocPratica> docs = new ArrayList<>(); List<DocPratica> docs = new ArrayList<>();
if (Validator.isNull(comingFrom)) { if (Validator.isNull(comingFrom)) {
docs = DocPraticaLocalServiceUtil.findByClassPk(classPk); docs = DocPraticaLocalServiceUtil.findByClassPk(classPk);
} else if ("page_in_allegati".equals(comingFrom) || "page_va_allegati".equals(comingFrom)) { } else if ("page_in_allegati".equals(comingFrom) || "page_va_allegati".equals(comingFrom)) {
List<String> tipologieAllegati = DocumentiPraticaUtil.getDocDomanda(); 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 { } else {
List<String> tipologieAllegati = new ArrayList<String>(); List<String> tipologieAllegati = new ArrayList<String>();
if ("page_geologica".equals(comingFrom) || "ag".equals(type)) { if ("page_geologica".equals(comingFrom) || "ag".equals(type)) {
tipologieAllegati = DocumentiPraticaUtil.getDocGeologo(); tipologieAllegati = DocumentiPraticaUtil.getDocGeologo();
} else if ("page_allegati".equals(comingFrom) || "ad".equals(type)) { } else if ("page_allegati".equals(comingFrom) || "ad".equals(type)) {
tipologieAllegati = DocumentiPraticaUtil.getDocDomanda(); tipologieAllegati = DocumentiPraticaUtil.getDocDomanda();
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId);
} else if ("page_fine_lavori".equals(comingFrom)) { } else if ("page_fine_lavori".equals(comingFrom)) {
tipologieAllegati = DocumentiPraticaUtil.getDocFineLavori(); tipologieAllegati = DocumentiPraticaUtil.getDocFineLavori();
} else if ("page_collaudo".equals(comingFrom)) { } else if ("page_collaudo".equals(comingFrom)) {
tipologieAllegati = DocumentiPraticaUtil.getDocCollaudo(); tipologieAllegati = DocumentiPraticaUtil.getDocCollaudo();
} }
docs = DocPraticaLocalServiceUtil.findByIntPratica_ClassPk_Tipologie(intPraticaId, docs = DocPraticaLocalServiceUtil.findByIntPratica_ClassPk_Tipologie(intPraticaId, classPk,
classPk, tipologieAllegati); tipologieAllegati);
} }
ZipWriter zipWriter = ZipWriterFactoryUtil.getZipWriter(); ZipWriter zipWriter = ZipWriterFactoryUtil.getZipWriter();
for (DocPratica doc : docs) { for (DocPratica doc : docs) {
InputStream inputStream = null; InputStream inputStream = null;
try { try {
if (Validator.isNull(doc.getDlFileEntryId())) { if (Validator.isNull(doc.getDlFileEntryId())) {
@ -321,9 +263,6 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(doc.getDlFileEntryId()); FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(doc.getDlFileEntryId());
inputStream = DLFileEntryLocalServiceUtil.getFileAsStream(fileEntry.getFileEntryId(), inputStream = DLFileEntryLocalServiceUtil.getFileAsStream(fileEntry.getFileEntryId(),
fileEntry.getVersion(), false); fileEntry.getVersion(), false);
// String name = fileEntry.getTitle() +
// StringPool.PERIOD + fileEntry.getExtension();
String name = fileEntry.getTitle(); String name = fileEntry.getTitle();
zipWriter.addEntry(name, inputStream); zipWriter.addEntry(name, inputStream);
} finally { } finally {
@ -332,34 +271,17 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
} }
} }
} }
resourceResponse.reset(); resourceResponse.reset();
File file = zipWriter.getFile(); File file = zipWriter.getFile();
byte[] data = Files.readAllBytes(file.toPath()); byte[] data = Files.readAllBytes(file.toPath());
resourceResponse.setContentType(ContentTypes.APPLICATION_ZIP); resourceResponse.setContentType(ContentTypes.APPLICATION_ZIP);
resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate"); resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate");
resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION,
+ file.getName() + "\""); "attachment; filename=\"" + file.getName() + StringPool.QUOTE);
resourceResponse.setContentLength(data.length); resourceResponse.setContentLength(data.length);
resourceResponse.getPortletOutputStream().write(data); resourceResponse.getPortletOutputStream().write(data);
resourceResponse.getPortletOutputStream().flush(); resourceResponse.getPortletOutputStream().flush();
resourceResponse.getPortletOutputStream().close(); 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 { } else {
super.serveResource(resourceRequest, resourceResponse); super.serveResource(resourceRequest, resourceResponse);
} }
@ -367,7 +289,6 @@ public class AllegatiPraticaPortlet extends MVCPortlet {
_log.error(e, e); _log.error(e, e);
throw new IOException(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.Delega;
import it.tref.liferay.portos.bo.model.DettPratica; import it.tref.liferay.portos.bo.model.DettPratica;
import it.tref.liferay.portos.bo.model.FineLavori; 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.IntPratica;
import it.tref.liferay.portos.bo.model.Pagamento; import it.tref.liferay.portos.bo.model.Pagamento;
import it.tref.liferay.portos.bo.model.Provincia; 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.model.Territorio;
import it.tref.liferay.portos.bo.service.AsseverazioneLocalServiceUtil; import it.tref.liferay.portos.bo.service.AsseverazioneLocalServiceUtil;
import it.tref.liferay.portos.bo.service.AsseverazioneServiceUtil; 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.CollaudoServiceUtil;
import it.tref.liferay.portos.bo.service.ComuneLocalServiceUtil; import it.tref.liferay.portos.bo.service.ComuneLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DelegaLocalServiceUtil; import it.tref.liferay.portos.bo.service.DelegaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DelegaServiceUtil; import it.tref.liferay.portos.bo.service.DelegaServiceUtil;
import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DettPraticaServiceUtil; 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.FineLavoriServiceUtil;
import it.tref.liferay.portos.bo.service.InfoFascicoloLocalServiceUtil;
import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.IntPraticaServiceUtil; import it.tref.liferay.portos.bo.service.IntPraticaServiceUtil;
import it.tref.liferay.portos.bo.service.PagamentoLocalServiceUtil; 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.Constants;
import it.tref.liferay.portos.bo.shared.util.FascicoloURLUtil; 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.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.TipoIntegrazioneUtil;
import it.tref.liferay.portos.bo.shared.util.TipoSoggettoUtil; import it.tref.liferay.portos.bo.shared.util.TipoSoggettoUtil;
import it.tref.liferay.portos.bo.util.AsseverazioniUtil; import it.tref.liferay.portos.bo.util.AsseverazioniUtil;
import it.tref.liferay.portos.bo.util.DelegheUtil; 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.MailUtil;
import it.tref.liferay.portos.bo.util.SoggettiUtil; import it.tref.liferay.portos.bo.util.SoggettiUtil;
import it.tref.liferay.portos.bo.util.ValidazionePraticaUtil; 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.language.LanguageUtil;
import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil; 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.repository.model.FileEntry;
import com.liferay.portal.kernel.servlet.ServletResponseUtil; import com.liferay.portal.kernel.servlet.ServletResponseUtil;
import com.liferay.portal.kernel.servlet.SessionErrors; import com.liferay.portal.kernel.servlet.SessionErrors;
@ -158,7 +151,7 @@ public class FascicoloFePortlet extends MVCPortlet {
} }
writeJSON(resourceRequest, resourceResponse, jsonArray); writeJSON(resourceRequest, resourceResponse, jsonArray);
} else if ("zoneFasce".equals(id)) { } else if ("zoneFasce".equals(id)) {
long comuneId = ParamUtil.getLong(resourceRequest, "comuneId", 0l); long comuneId = ParamUtil.getLong(resourceRequest, "comuneId", 0L);
JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
if (Validator.isNotNull(comuneId)) { if (Validator.isNotNull(comuneId)) {
List<Territorio> territori = TerritorioLocalServiceUtil.getActiveTerritoriByComune(comuneId); List<Territorio> territori = TerritorioLocalServiceUtil.getActiveTerritoriByComune(comuneId);
@ -177,7 +170,7 @@ public class FascicoloFePortlet extends MVCPortlet {
} }
writeJSON(resourceRequest, resourceResponse, jsonArray); writeJSON(resourceRequest, resourceResponse, jsonArray);
} else if ("soggettiDelega".equals(id)) { } else if ("soggettiDelega".equals(id)) {
long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId", 0l); long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId", 0L);
IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId); IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId);
JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
if (Validator.isNotNull(intPratica)) { if (Validator.isNotNull(intPratica)) {
@ -194,8 +187,8 @@ public class FascicoloFePortlet extends MVCPortlet {
} }
writeJSON(resourceRequest, resourceResponse, jsonArray); writeJSON(resourceRequest, resourceResponse, jsonArray);
} else if ("tipologiaDelega".equals(id)) { } else if ("tipologiaDelega".equals(id)) {
long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId", 0l); long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId", 0L);
long soggettoId = ParamUtil.getLong(resourceRequest, "soggettoId", 0l); long soggettoId = ParamUtil.getLong(resourceRequest, "soggettoId", 0L);
IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId); IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(intPraticaId);
Soggetto soggetto = SoggettoLocalServiceUtil.fetchSoggetto(soggettoId); Soggetto soggetto = SoggettoLocalServiceUtil.fetchSoggetto(soggettoId);
JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
@ -232,54 +225,6 @@ public class FascicoloFePortlet extends MVCPortlet {
jsonArray.put(jsonObject); jsonArray.put(jsonObject);
} }
writeJSON(resourceRequest, resourceResponse, jsonArray); 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)) { } else if ("isCompletedDelegaGeologo".equals(id)) {
long classPk = ParamUtil.getLong(resourceRequest, "classPk"); long classPk = ParamUtil.getLong(resourceRequest, "classPk");
JSONObject json = JSONFactoryUtil.createJSONObject(); JSONObject json = JSONFactoryUtil.createJSONObject();
@ -315,7 +260,8 @@ public class FascicoloFePortlet extends MVCPortlet {
JRDataSource dataSource = new JREmptyDataSource(); JRDataSource dataSource = new JREmptyDataSource();
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource);
// Export to PDF. // Export to PDF.
String titleDoc = intPratica.getNumeroProgetto() + "_" + new Date().getTime() + ".pdf"; String titleDoc = intPratica.getNumeroProgetto() + StringPool.UNDERLINE + new Date().getTime()
+ ".pdf";
jasperPrint.setName(titleDoc); jasperPrint.setName(titleDoc);
HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest); HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest);
HttpServletResponse response = PortalUtil.getHttpServletResponse(resourceResponse); HttpServletResponse response = PortalUtil.getHttpServletResponse(resourceResponse);
@ -344,8 +290,8 @@ public class FascicoloFePortlet extends MVCPortlet {
JRDataSource dataSource = new JREmptyDataSource(); JRDataSource dataSource = new JREmptyDataSource();
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource);
// Export to PDF. // Export to PDF.
String titleDoc = "variante_" + intPratica.getNumeroProgetto() + "_" + new Date().getTime() String titleDoc = "variante_" + intPratica.getNumeroProgetto() + StringPool.UNDERLINE
+ ".pdf"; + new Date().getTime() + ".pdf";
jasperPrint.setName(titleDoc); jasperPrint.setName(titleDoc);
HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest); HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest);
HttpServletResponse response = PortalUtil.getHttpServletResponse(resourceResponse); HttpServletResponse response = PortalUtil.getHttpServletResponse(resourceResponse);
@ -373,8 +319,8 @@ public class FascicoloFePortlet extends MVCPortlet {
JRDataSource dataSource = new JREmptyDataSource(); JRDataSource dataSource = new JREmptyDataSource();
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource);
// Export to PDF. // Export to PDF.
String titleDoc = "fine_lavori_" + intPratica.getNumeroProgetto() + "_" + new Date().getTime() String titleDoc = "fine_lavori_" + intPratica.getNumeroProgetto() + StringPool.UNDERLINE
+ ".pdf"; + new Date().getTime() + ".pdf";
jasperPrint.setName(titleDoc); jasperPrint.setName(titleDoc);
HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest); HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest);
HttpServletResponse response = PortalUtil.getHttpServletResponse(resourceResponse); HttpServletResponse response = PortalUtil.getHttpServletResponse(resourceResponse);
@ -401,8 +347,8 @@ public class FascicoloFePortlet extends MVCPortlet {
JRDataSource dataSource = new JREmptyDataSource(); JRDataSource dataSource = new JREmptyDataSource();
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource);
// Export to PDF. // Export to PDF.
String titleDoc = "collaudo_" + intPratica.getNumeroProgetto() + "_" + new Date().getTime() String titleDoc = "collaudo_" + intPratica.getNumeroProgetto() + StringPool.UNDERLINE
+ ".pdf"; + new Date().getTime() + ".pdf";
jasperPrint.setName(titleDoc); jasperPrint.setName(titleDoc);
HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest); HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest);
HttpServletResponse response = PortalUtil.getHttpServletResponse(resourceResponse); HttpServletResponse response = PortalUtil.getHttpServletResponse(resourceResponse);
@ -500,8 +446,8 @@ public class FascicoloFePortlet extends MVCPortlet {
successURL = HttpUtil.addParameter(successURL, actionResponse.getNamespace() + "dettPraticaId", successURL = HttpUtil.addParameter(successURL, actionResponse.getNamespace() + "dettPraticaId",
String.valueOf(lastDettPraticaEditableVS.getDettPraticaId())); String.valueOf(lastDettPraticaEditableVS.getDettPraticaId()));
String fragmentURL = "_1_WAR_portosfeportlet_page_soggetti"; String fragmentURL = "_1_WAR_portosfeportlet_page_soggetti";
if (successURL.contains("#")) { if (successURL.contains(StringPool.POUND)) {
successURL = successURL.substring(0, successURL.lastIndexOf("#")); successURL = successURL.substring(0, successURL.lastIndexOf(StringPool.POUND));
} }
successURL += "#_1_WAR_portosfeportlet_tab=" + fragmentURL; successURL += "#_1_WAR_portosfeportlet_tab=" + fragmentURL;
actionResponse.sendRedirect(successURL); actionResponse.sendRedirect(successURL);
@ -548,7 +494,7 @@ public class FascicoloFePortlet extends MVCPortlet {
successURL = HttpUtil.addParameter(successURL, actionResponse.getNamespace() + "dettPraticaId", successURL = HttpUtil.addParameter(successURL, actionResponse.getNamespace() + "dettPraticaId",
String.valueOf(dettPratica.getDettPraticaId())); String.valueOf(dettPratica.getDettPraticaId()));
successURL = HttpUtil.addParameter(successURL, actionResponse.getNamespace() + "isNewVariante", successURL = HttpUtil.addParameter(successURL, actionResponse.getNamespace() + "isNewVariante",
String.valueOf(true)); StringPool.TRUE);
actionResponse.sendRedirect(successURL); actionResponse.sendRedirect(successURL);
} catch (PortalException | SystemException e) { } catch (PortalException | SystemException e) {
successURL = HttpUtil.setParameter(successURL, actionResponse.getNamespace() + "mvcPath", successURL = HttpUtil.setParameter(successURL, actionResponse.getNamespace() + "mvcPath",
@ -714,7 +660,7 @@ public class FascicoloFePortlet extends MVCPortlet {
ServiceContext serviceContext = ServiceContextFactory.getInstance(DettPratica.class.getName(), actionRequest); ServiceContext serviceContext = ServiceContextFactory.getInstance(DettPratica.class.getName(), actionRequest);
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId"); long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId");
DettPratica dettPratica = DettPraticaLocalServiceUtil.getDettPratica(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"); boolean bozza = ParamUtil.getBoolean(actionRequest, "bozza");
if (bozza) { if (bozza) {
@ -733,7 +679,7 @@ public class FascicoloFePortlet extends MVCPortlet {
saveDatiDettPratica(dettPraticaId, actionRequest, actionResponse); saveDatiDettPratica(dettPraticaId, actionRequest, actionResponse);
} else { } 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); ServiceContext serviceContext = ServiceContextFactory.getInstance(DettPratica.class.getName(), actionRequest);
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId"); long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId");
DettPratica dettPratica = DettPraticaLocalServiceUtil.getDettPratica(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"); boolean bozza = ParamUtil.getBoolean(actionRequest, "bozza");
if (bozza) { if (bozza) {
@ -885,7 +831,7 @@ public class FascicoloFePortlet extends MVCPortlet {
if (ParamUtil.getBoolean(actionRequest, "asPresenti", false)) { if (ParamUtil.getBoolean(actionRequest, "asPresenti", false)) {
Map<String, Serializable> parametri = new HashMap<>(); Map<String, Serializable> parametri = new HashMap<>();
parametri.put("coniugio", ParamUtil.getBoolean(actionRequest, "asConiugio", false)); 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(); JSONSerializer serializer = JSONFactoryUtil.createJSONSerializer();
dichiarazioni = serializer.serializeDeep(parametri); dichiarazioni = serializer.serializeDeep(parametri);
@ -930,7 +876,7 @@ public class FascicoloFePortlet extends MVCPortlet {
Map<String, Serializable> parametri = new HashMap<>(); Map<String, Serializable> parametri = new HashMap<>();
if (ParamUtil.getBoolean(actionRequest, "dgPresenti", false)) { if (ParamUtil.getBoolean(actionRequest, "dgPresenti", false)) {
parametri.put("coniugio", ParamUtil.getBoolean(actionRequest, "dgConiugio", 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(); JSONSerializer serializer = JSONFactoryUtil.createJSONSerializer();
String dichiarazioni = serializer.serializeDeep(parametri); String dichiarazioni = serializer.serializeDeep(parametri);
@ -959,7 +905,7 @@ public class FascicoloFePortlet extends MVCPortlet {
ServiceContext serviceContext = ServiceContextFactory.getInstance(DettPratica.class.getName(), actionRequest); ServiceContext serviceContext = ServiceContextFactory.getInstance(DettPratica.class.getName(), actionRequest);
DettPratica dettPratica = DettPraticaServiceUtil.getDettPratica(dettPraticaId); DettPratica dettPratica = DettPraticaServiceUtil.getDettPratica(dettPraticaId);
boolean bozza = ParamUtil.getBoolean(actionRequest, "bozza", true); 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"); long integrazione = ParamUtil.getLong(actionRequest, "integrazione");
boolean disabledSubmit = ParamUtil.getBoolean(actionRequest, "disabledSubmit", true); boolean disabledSubmit = ParamUtil.getBoolean(actionRequest, "disabledSubmit", true);
boolean geoDisabledSubmit = ParamUtil.getBoolean(actionRequest, "geoDisabledSubmit", true); boolean geoDisabledSubmit = ParamUtil.getBoolean(actionRequest, "geoDisabledSubmit", true);
@ -979,11 +925,11 @@ public class FascicoloFePortlet extends MVCPortlet {
boolean isCodiceFiscaleDelegatoFineLavoriAuthorized = ParamUtil.getBoolean(actionRequest, boolean isCodiceFiscaleDelegatoFineLavoriAuthorized = ParamUtil.getBoolean(actionRequest,
"codiceFiscaleDelegatoFineLavoriEnabled"); "codiceFiscaleDelegatoFineLavoriEnabled");
String codiceFiscaleDelegatoFineLavori = isCodiceFiscaleDelegatoFineLavoriAuthorized ? ParamUtil.getString( String codiceFiscaleDelegatoFineLavori = isCodiceFiscaleDelegatoFineLavoriAuthorized ? ParamUtil.getString(
actionRequest, "codiceFiscaleDelegatoFineLavori") : ""; actionRequest, "codiceFiscaleDelegatoFineLavori") : StringPool.BLANK;
boolean isCodiceFiscaleDelegatoCollaudoAuthorized = ParamUtil.getBoolean(actionRequest, boolean isCodiceFiscaleDelegatoCollaudoAuthorized = ParamUtil.getBoolean(actionRequest,
"codiceFiscaleDelegatoCollaudoEnabled"); "codiceFiscaleDelegatoCollaudoEnabled");
String codiceFiscaleDelegatoCollaudo = isCodiceFiscaleDelegatoCollaudoAuthorized ? ParamUtil.getString( String codiceFiscaleDelegatoCollaudo = isCodiceFiscaleDelegatoCollaudoAuthorized ? ParamUtil.getString(
actionRequest, "codiceFiscaleDelegatoCollaudo") : ""; actionRequest, "codiceFiscaleDelegatoCollaudo") : StringPool.BLANK;
// FIXME A che serve??? // FIXME A che serve???
String codiceRuoloDelegato = ParamUtil.getString(actionRequest, "codiceRuoloDelegato"); String codiceRuoloDelegato = ParamUtil.getString(actionRequest, "codiceRuoloDelegato");
boolean inizioLavoriContestualeOpera = ParamUtil.getBoolean(actionRequest, "inizioLavoriContestualeOpera"); boolean inizioLavoriContestualeOpera = ParamUtil.getBoolean(actionRequest, "inizioLavoriContestualeOpera");
@ -1043,15 +989,22 @@ public class FascicoloFePortlet extends MVCPortlet {
String numeroCivico = ParamUtil.getString(actionRequest, "numeroCivico"); String numeroCivico = ParamUtil.getString(actionRequest, "numeroCivico");
String dcFoglio = ParamUtil.getString(actionRequest, "dcFoglio"); String dcFoglio = ParamUtil.getString(actionRequest, "dcFoglio");
String dcAllegato = ParamUtil.getString(actionRequest, "dcAllegato"); String dcAllegato = ParamUtil.getString(actionRequest, "dcAllegato");
String particella1 = ParamUtil.getString(actionRequest, "particella1", "").replaceAll(Pattern.quote("|"), " "); String particella1 = ParamUtil.getString(actionRequest, "particella1", StringPool.BLANK).replaceAll(
String particella2 = ParamUtil.getString(actionRequest, "particella2", "").replaceAll(Pattern.quote("|"), " "); Pattern.quote(StringPool.PIPE), StringPool.SPACE);
String particella3 = ParamUtil.getString(actionRequest, "particella3", "").replaceAll(Pattern.quote("|"), " "); String particella2 = ParamUtil.getString(actionRequest, "particella2", StringPool.BLANK).replaceAll(
String particella4 = ParamUtil.getString(actionRequest, "particella4", "").replaceAll(Pattern.quote("|"), " "); 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 String dcParticelle = particella1 + StringPool.PIPE + particella2 + StringPool.PIPE + particella3
+ StringPool.PIPE + particella4; + StringPool.PIPE + particella4;
String latitudine = ParamUtil.getString(actionRequest, "lat", "").replaceAll(Pattern.quote("|"), " "); String latitudine = ParamUtil.getString(actionRequest, "lat", StringPool.BLANK).replaceAll(
String longitudine = ParamUtil.getString(actionRequest, "long", "").replaceAll(Pattern.quote("|"), " "); Pattern.quote(StringPool.PIPE), StringPool.SPACE);
String zoom = ParamUtil.getString(actionRequest, "zoom", "").replaceAll(Pattern.quote("|"), " "); 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; String localizzazioneGeografica = latitudine + StringPool.PIPE + longitudine + StringPool.PIPE + zoom;
boolean tcNuovaCostruzione = ParamUtil.getBoolean(actionRequest, "tcNuovaCostruzione"); boolean tcNuovaCostruzione = ParamUtil.getBoolean(actionRequest, "tcNuovaCostruzione");
boolean tcAdeguamentoSismico = ParamUtil.getBoolean(actionRequest, "tcAdeguamentoSismico"); boolean tcAdeguamentoSismico = ParamUtil.getBoolean(actionRequest, "tcAdeguamentoSismico");
@ -1296,8 +1249,8 @@ public class FascicoloFePortlet extends MVCPortlet {
successURL = HttpUtil.removeParameter(successURL, actionResponse.getNamespace() + "historyKey"); successURL = HttpUtil.removeParameter(successURL, actionResponse.getNamespace() + "historyKey");
successURL = HttpUtil.addParameter(successURL, actionResponse.getNamespace() + "historyKey", successURL = HttpUtil.addParameter(successURL, actionResponse.getNamespace() + "historyKey",
"_1_WAR_portosfeportlet_tab=" + fragmentURL); "_1_WAR_portosfeportlet_tab=" + fragmentURL);
if (successURL.contains("#")) { if (successURL.contains(StringPool.POUND)) {
successURL = successURL.substring(0, successURL.lastIndexOf("#")); successURL = successURL.substring(0, successURL.lastIndexOf(StringPool.POUND));
} }
successURL += "#_1_WAR_portosfeportlet_tab=" + fragmentURL; successURL += "#_1_WAR_portosfeportlet_tab=" + fragmentURL;
} }
@ -1355,11 +1308,11 @@ public class FascicoloFePortlet extends MVCPortlet {
boolean isCodiceFiscaleDelegatoFineLavoriAuthorized = ParamUtil.getBoolean(actionRequest, boolean isCodiceFiscaleDelegatoFineLavoriAuthorized = ParamUtil.getBoolean(actionRequest,
"codiceFiscaleDelegatoFineLavoriEnabled"); "codiceFiscaleDelegatoFineLavoriEnabled");
String codiceFiscaleDelegatoFineLavori = isCodiceFiscaleDelegatoFineLavoriAuthorized ? ParamUtil.getString( String codiceFiscaleDelegatoFineLavori = isCodiceFiscaleDelegatoFineLavoriAuthorized ? ParamUtil.getString(
actionRequest, "codiceFiscaleDelegatoFineLavori") : ""; actionRequest, "codiceFiscaleDelegatoFineLavori") : StringPool.BLANK;
boolean isCodiceFiscaleDelegatoCollaudoAuthorized = ParamUtil.getBoolean(actionRequest, boolean isCodiceFiscaleDelegatoCollaudoAuthorized = ParamUtil.getBoolean(actionRequest,
"codiceFiscaleDelegatoCollaudoEnabled"); "codiceFiscaleDelegatoCollaudoEnabled");
String codiceFiscaleDelegatoCollaudo = isCodiceFiscaleDelegatoCollaudoAuthorized ? ParamUtil.getString( String codiceFiscaleDelegatoCollaudo = isCodiceFiscaleDelegatoCollaudoAuthorized ? ParamUtil.getString(
actionRequest, "codiceFiscaleDelegatoCollaudo") : ""; actionRequest, "codiceFiscaleDelegatoCollaudo") : StringPool.BLANK;
boolean inizioLavoriContestualeOpera = ParamUtil.getBoolean(actionRequest, "inizioLavoriContestualeOpera"); boolean inizioLavoriContestualeOpera = ParamUtil.getBoolean(actionRequest, "inizioLavoriContestualeOpera");
long pagamentoId = ParamUtil.getLong(actionRequest, "pagamentoId"); long pagamentoId = ParamUtil.getLong(actionRequest, "pagamentoId");
Date dataEffettuazione = ParamUtil.getDate(actionRequest, "dataEffettuazione", Date dataEffettuazione = ParamUtil.getDate(actionRequest, "dataEffettuazione",
@ -1423,10 +1376,14 @@ public class FascicoloFePortlet extends MVCPortlet {
String numeroCivico = ParamUtil.getString(actionRequest, "numeroCivico"); String numeroCivico = ParamUtil.getString(actionRequest, "numeroCivico");
String dcFoglio = ParamUtil.getString(actionRequest, "dcFoglio"); String dcFoglio = ParamUtil.getString(actionRequest, "dcFoglio");
String dcAllegato = ParamUtil.getString(actionRequest, "dcAllegato"); String dcAllegato = ParamUtil.getString(actionRequest, "dcAllegato");
String particella1 = ParamUtil.getString(actionRequest, "particella1", "").replaceAll(Pattern.quote("|"), " "); String particella1 = ParamUtil.getString(actionRequest, "particella1", StringPool.BLANK).replaceAll(
String particella2 = ParamUtil.getString(actionRequest, "particella2", "").replaceAll(Pattern.quote("|"), " "); Pattern.quote(StringPool.PIPE), StringPool.SPACE);
String particella3 = ParamUtil.getString(actionRequest, "particella3", "").replaceAll(Pattern.quote("|"), " "); String particella2 = ParamUtil.getString(actionRequest, "particella2", StringPool.BLANK).replaceAll(
String particella4 = ParamUtil.getString(actionRequest, "particella4", "").replaceAll(Pattern.quote("|"), " "); 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 String dcParticelle = particella1 + StringPool.PIPE + particella2 + StringPool.PIPE + particella3
+ StringPool.PIPE + particella4; + StringPool.PIPE + particella4;
boolean tcNuovaCostruzione = ParamUtil.getBoolean(actionRequest, "tcNuovaCostruzione"); boolean tcNuovaCostruzione = ParamUtil.getBoolean(actionRequest, "tcNuovaCostruzione");
@ -1686,8 +1643,8 @@ public class FascicoloFePortlet extends MVCPortlet {
successURL = HttpUtil.addParameter(successURL, actionResponse.getNamespace() + "historyKey", successURL = HttpUtil.addParameter(successURL, actionResponse.getNamespace() + "historyKey",
"_1_WAR_portosfeportlet_tab=" + fragmentURL); "_1_WAR_portosfeportlet_tab=" + fragmentURL);
if (successURL.contains("#")) { if (successURL.contains(StringPool.POUND)) {
successURL = successURL.substring(0, successURL.lastIndexOf("#")); successURL = successURL.substring(0, successURL.lastIndexOf(StringPool.POUND));
} }
successURL += "#_1_WAR_portosfeportlet_tab=" + fragmentURL; successURL += "#_1_WAR_portosfeportlet_tab=" + fragmentURL;
} }
@ -1747,8 +1704,8 @@ public class FascicoloFePortlet extends MVCPortlet {
successURL = HttpUtil.addParameter(successURL, actionResponse.getNamespace() + "verifyArea", successURL = HttpUtil.addParameter(successURL, actionResponse.getNamespace() + "verifyArea",
String.valueOf(verifyArea)); String.valueOf(verifyArea));
String fragmentURL = "_1_WAR_portosfeportlet_page_soggetti"; String fragmentURL = "_1_WAR_portosfeportlet_page_soggetti";
if (successURL.contains("#")) { if (successURL.contains(StringPool.POUND)) {
successURL = successURL.substring(0, successURL.lastIndexOf("#")); successURL = successURL.substring(0, successURL.lastIndexOf(StringPool.POUND));
} }
successURL += "#_1_WAR_portosfeportlet_tab=" + fragmentURL; successURL += "#_1_WAR_portosfeportlet_tab=" + fragmentURL;
actionResponse.sendRedirect(successURL); actionResponse.sendRedirect(successURL);
@ -1942,10 +1899,10 @@ public class FascicoloFePortlet extends MVCPortlet {
SessionErrors.add(actionRequest, "error.geniocivilefe.asseverazione.allegato.firma.valid"); SessionErrors.add(actionRequest, "error.geniocivilefe.asseverazione.allegato.firma.valid");
// Impostazione parametri di rendering per messaggio di errore. // Impostazione parametri di rendering per messaggio di errore.
List<String> firmatari = ValidazionePraticaUtil.gatherSignatures(sourceFileName, content, List<String> firmatari = ValidazionePraticaUtil.gatherSignatures(sourceFileName, content,
serviceContext.getCompanyId(), ""); serviceContext.getCompanyId(), StringPool.BLANK);
String firme = StringUtils.join(firmatari, ", ").toLowerCase(); String firme = StringUtils.join(firmatari, StringPool.COMMA_AND_SPACE).toLowerCase();
dettagliFirme = "<br>Firma richiesta [" + asseverazione.getCodiceFiscale() + "]<br>Firme trovate [" dettagliFirme = "<br>Firma richiesta [" + asseverazione.getCodiceFiscale() + "]<br>Firme trovate ["
+ firme + "]"; + firme + StringPool.CLOSE_BRACKET;
} }
} }
if (!SessionErrors.isEmpty(actionRequest)) { if (!SessionErrors.isEmpty(actionRequest)) {
@ -1973,6 +1930,7 @@ public class FascicoloFePortlet extends MVCPortlet {
public void confermaAsseverazione(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, public void confermaAsseverazione(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException,
PortalException, SystemException { PortalException, SystemException {
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
long asseverazioneId = ParamUtil.getLong(actionRequest, "asseverazioneId"); long asseverazioneId = ParamUtil.getLong(actionRequest, "asseverazioneId");
if (AsseverazioniUtil.hasCambioStatoAsseverazione(serviceContext.getUserId(), asseverazioneId)) { if (AsseverazioniUtil.hasCambioStatoAsseverazione(serviceContext.getUserId(), asseverazioneId)) {
@ -2129,11 +2087,12 @@ public class FascicoloFePortlet extends MVCPortlet {
long delegaId = ParamUtil.getLong(actionRequest, "delegaId"); long delegaId = ParamUtil.getLong(actionRequest, "delegaId");
Delega delega = DelegaLocalServiceUtil.getDelega(delegaId); Delega delega = DelegaLocalServiceUtil.getDelega(delegaId);
List<Soggetto> soggetti = SoggettoLocalServiceUtil.getValidTmpByIntPratica_CodiceFiscale( List<Soggetto> soggetti = SoggettoLocalServiceUtil.getValidTmpByIntPratica_CodiceFiscale(
delega.getIntPraticaId(), delega.getCodiceFiscale(), 0l); delega.getIntPraticaId(), delega.getCodiceFiscale(), 0L);
Soggetto soggetto = soggetti.get(0); Soggetto soggetto = soggetti.get(0);
String roles = StringPool.BLANK; String roles = StringPool.BLANK;
for (Soggetto role : soggetti) { 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()); IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(delega.getIntPraticaId());
String[] to = { soggetto.getEmail() }; String[] to = { soggetto.getEmail() };
@ -2181,7 +2140,7 @@ public class FascicoloFePortlet extends MVCPortlet {
long asseverazioneId = ParamUtil.getLong(actionRequest, "asseverazioneId"); long asseverazioneId = ParamUtil.getLong(actionRequest, "asseverazioneId");
Asseverazione asseverazione = AsseverazioneLocalServiceUtil.getAsseverazione(asseverazioneId); Asseverazione asseverazione = AsseverazioneLocalServiceUtil.getAsseverazione(asseverazioneId);
Soggetto soggetto = SoggettoLocalServiceUtil.getValidTmpByIntPratica_CodiceFiscale( 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()); IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(asseverazione.getIntPraticaId());
_log.debug("Sending asseverazione mail to " + soggetto.getEmail()); _log.debug("Sending asseverazione mail to " + soggetto.getEmail());
String[] to = { soggetto.getEmail() }; String[] to = { soggetto.getEmail() };
@ -2241,13 +2200,8 @@ public class FascicoloFePortlet extends MVCPortlet {
PortalUtil.copyRequestParameters(actionRequest, actionResponse); PortalUtil.copyRequestParameters(actionRequest, actionResponse);
} else { } else {
byte[] content = FileUtil.getBytes(file); byte[] content = FileUtil.getBytes(file);
// DettPraticaServiceUtil.updatePagamentoManuale(pagamentoId,
// pagamento.getDettPraticaId(),
// content,
// sourceFileName, serviceContext);
PagamentoServiceUtil.updatePagamentoManuale(pagamentoId, content, sourceFileName, serviceContext); PagamentoServiceUtil.updatePagamentoManuale(pagamentoId, content, sourceFileName, serviceContext);
} }
} catch (Exception e) { } catch (Exception e) {
PortalUtil.copyRequestParameters(actionRequest, actionResponse); PortalUtil.copyRequestParameters(actionRequest, actionResponse);
_log.error("Error", e); _log.error("Error", e);
@ -2261,7 +2215,6 @@ public class FascicoloFePortlet extends MVCPortlet {
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId"); long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId");
long fineLavoriId = ParamUtil.getLong(actionRequest, "fineLavoriId"); long fineLavoriId = ParamUtil.getLong(actionRequest, "fineLavoriId");
long collaudoId = ParamUtil.getLong(actionRequest, "collaudoId"); long collaudoId = ParamUtil.getLong(actionRequest, "collaudoId");
if (Validator.isNotNull(dettPraticaId)) { if (Validator.isNotNull(dettPraticaId)) {
DettPraticaServiceUtil.updateEsito(dettPraticaId, WorkflowConstants.STATUS_APPROVED); DettPraticaServiceUtil.updateEsito(dettPraticaId, WorkflowConstants.STATUS_APPROVED);
} else if (Validator.isNotNull(fineLavoriId)) { } else if (Validator.isNotNull(fineLavoriId)) {
@ -2277,7 +2230,6 @@ public class FascicoloFePortlet extends MVCPortlet {
PortalException, SystemException { PortalException, SystemException {
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId"); long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId");
if (Validator.isNotNull(dettPraticaId)) { if (Validator.isNotNull(dettPraticaId)) {
DettPraticaServiceUtil.updateEsitoIntegrazione(dettPraticaId, WorkflowConstants.STATUS_APPROVED); DettPraticaServiceUtil.updateEsitoIntegrazione(dettPraticaId, WorkflowConstants.STATUS_APPROVED);
} else { } else {
@ -2289,14 +2241,11 @@ public class FascicoloFePortlet extends MVCPortlet {
PortalException, SystemException { PortalException, SystemException {
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId"); long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId");
if (Validator.isNotNull(dettPraticaId)) { if (Validator.isNotNull(dettPraticaId)) {
DettPraticaServiceUtil.updateEsito(dettPraticaId, WorkflowConstants.STATUS_APPROVED); DettPraticaServiceUtil.updateEsito(dettPraticaId, WorkflowConstants.STATUS_APPROVED);
} else { } else {
SessionErrors.add(actionRequest, "completamento-cambio-soggetti-non-possibile"); SessionErrors.add(actionRequest, "completamento-cambio-soggetti-non-possibile");
} }
} }
public void completeAnnullamento(ActionRequest actionRequest, ActionResponse actionResponse) 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); private static Log _log = LogFactoryUtil.getLog(SoggettiPraticaPortlet.class);
public void deleteSoggetto(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { public void deleteSoggetto(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
try { try {
long soggettoId = ParamUtil.getLong(actionRequest, "soggettoId"); long soggettoId = ParamUtil.getLong(actionRequest, "soggettoId");
SoggettoServiceUtil.deleteSoggetto(soggettoId); SoggettoServiceUtil.deleteSoggetto(soggettoId);
@ -73,6 +74,7 @@ public class SoggettiPraticaPortlet extends MVCPortlet {
} }
public void invalidaSoggetto(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { public void invalidaSoggetto(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
try { try {
long soggettoId = ParamUtil.getLong(actionRequest, "soggettoId"); long soggettoId = ParamUtil.getLong(actionRequest, "soggettoId");
long dettPraticaIdRimozione = ParamUtil.getLong(actionRequest, "dettPraticaId"); long dettPraticaIdRimozione = ParamUtil.getLong(actionRequest, "dettPraticaId");
@ -84,6 +86,7 @@ public class SoggettiPraticaPortlet extends MVCPortlet {
} }
public void validaSoggetto(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { public void validaSoggetto(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
try { try {
long soggettoId = ParamUtil.getLong(actionRequest, "soggettoId"); long soggettoId = ParamUtil.getLong(actionRequest, "soggettoId");
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId"); long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId");
@ -95,6 +98,7 @@ public class SoggettiPraticaPortlet extends MVCPortlet {
} }
public void makePrincipale(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { public void makePrincipale(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
try { try {
long soggettoId = ParamUtil.getLong(actionRequest, "soggettoId"); long soggettoId = ParamUtil.getLong(actionRequest, "soggettoId");
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId"); long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId");
@ -108,6 +112,7 @@ public class SoggettiPraticaPortlet extends MVCPortlet {
} }
public void removePrincipale(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { public void removePrincipale(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
try { try {
long soggettoId = ParamUtil.getLong(actionRequest, "soggettoId"); long soggettoId = ParamUtil.getLong(actionRequest, "soggettoId");
Soggetto soggetto = SoggettoServiceUtil.getSoggetto(soggettoId); Soggetto soggetto = SoggettoServiceUtil.getSoggetto(soggettoId);
@ -120,6 +125,7 @@ public class SoggettiPraticaPortlet extends MVCPortlet {
} }
public void updateSoggetto(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { public void updateSoggetto(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
boolean requiredDoc = ParamUtil.getBoolean(actionRequest, "requiredDoc"); boolean requiredDoc = ParamUtil.getBoolean(actionRequest, "requiredDoc");
long soggettoId = ParamUtil.getLong(actionRequest, "soggettoId"); long soggettoId = ParamUtil.getLong(actionRequest, "soggettoId");
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId"); long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId");
@ -225,6 +231,7 @@ public class SoggettiPraticaPortlet extends MVCPortlet {
} }
public void updateAllegatoSoggetto(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { public void updateAllegatoSoggetto(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long soggettoId = ParamUtil.getLong(actionRequest, "soggettoId"); long soggettoId = ParamUtil.getLong(actionRequest, "soggettoId");
Soggetto soggetto = SoggettoLocalServiceUtil.getSoggetto(soggettoId); Soggetto soggetto = SoggettoLocalServiceUtil.getSoggetto(soggettoId);
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId"); long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId");
@ -330,6 +337,7 @@ public class SoggettiPraticaPortlet extends MVCPortlet {
@Override @Override
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException,
PortletException { PortletException {
String id = resourceRequest.getResourceID(); String id = resourceRequest.getResourceID();
try { try {
ServiceContext serviceContext = ServiceContextFactory.getInstance(resourceRequest); 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"> <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> <dependency-type>uses</dependency-type>
</dependent-module> </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="context-root" value="portos-kaleo-controller-portlet"/>
<property name="java-output-path" value="/portos-kaleo-controller-portlet/docroot/WEB-INF/classes"/> <property name="java-output-path" value="/portos-kaleo-controller-portlet/docroot/WEB-INF/classes"/>
</wb-module> </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 { public void run(String[] ids) throws ActionException {
for (String id : ids) { for (String id : ids) {
long companyId = GetterUtil.getLong(id); long companyId = GetterUtil.getLong(id);
try { try {
Company company = CompanyLocalServiceUtil.getCompany(companyId); Company company = CompanyLocalServiceUtil.getCompany(companyId);
Group companyGroup = company.getGroup(); Group companyGroup = company.getGroup();
User userDefault = company.getDefaultUser(); User userDefault = company.getDefaultUser();
// Folders // Folders
String[] groupActions = { ActionKeys.VIEW }; String[] groupActions = { ActionKeys.VIEW };
String[] guestActions = { ActionKeys.VIEW }; String[] guestActions = { ActionKeys.VIEW };
addDLFolderIfNotExists(userDefault.getUserId(), companyGroup.getGroupId(), companyGroup.getGroupId(),
addDLFolderIfNotExists(userDefault.getUserId(), companyGroup.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, EmailConstants.DEFAULT_ATTACHMENTS_FOLDER_NAME,
companyGroup.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, true, groupActions, guestActions);
EmailConstants.DEFAULT_ATTACHMENTS_FOLDER_NAME, true, groupActions, guestActions);
} catch (Exception e) { } catch (Exception e) {
_log.error(e, e); _log.error(e, e);
} }
} }
} }
private DLFolder addDLFolderIfNotExists(long userId, long groupId, long repositoryId, private DLFolder addDLFolderIfNotExists(long userId, long groupId, long repositoryId, long parentFolderId,
long parentFolderId, String name, boolean hidden, String[] groupActions, String[] guestActions) String name, boolean hidden, String[] groupActions, String[] guestActions) throws PortalException,
throws PortalException, SystemException { SystemException {
DLFolder dlFolder = null; DLFolder dlFolder = null;
try { try {
dlFolder = DLFolderLocalServiceUtil.getFolder(groupId, parentFolderId, name); dlFolder = DLFolderLocalServiceUtil.getFolder(groupId, parentFolderId, name);
} catch (PortalException e) { } catch (PortalException e) {
ServiceContext serviceContext = new ServiceContext(); ServiceContext serviceContext = new ServiceContext();
if (groupActions != null) { if (groupActions != null) {
serviceContext.setGroupPermissions(groupActions); serviceContext.setGroupPermissions(groupActions);
} }
if (guestActions != null) { if (guestActions != null) {
serviceContext.setGuestPermissions(guestActions); serviceContext.setGuestPermissions(guestActions);
} }
dlFolder = DLFolderLocalServiceUtil.addFolder(userId, groupId, repositoryId, false, parentFolderId, name,
dlFolder = DLFolderLocalServiceUtil.addFolder(userId, groupId, repositoryId, false, StringPool.BLANK, hidden, serviceContext);
parentFolderId, name, StringPool.BLANK, hidden, serviceContext);
} }
return dlFolder; 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 { public void onBeforeRemove(DLFileEntry model) throws ModelListenerException {
try { try {
EmailAttachment emailAttachment = EmailAttachmentLocalServiceUtil.fetchByFileEntryId(model EmailAttachment emailAttachment = EmailAttachmentLocalServiceUtil
.getFileEntryId()); .fetchByFileEntryId(model.getFileEntryId());
if (emailAttachment != null) { if (emailAttachment != null) {
throw new ModelListenerException(); throw new ModelListenerException();
} }
@ -23,5 +23,4 @@ public class DLFileEntryListener extends BaseModelListener<DLFileEntry> {
throw new ModelListenerException(e); 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; 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.DuplicateLockException;
import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery; import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery;
import com.liferay.portal.kernel.dao.orm.DynamicQuery; 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.model.Lock;
import com.liferay.portal.service.LockLocalServiceUtil; 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 { public class SendMailMessageListener implements MessageListener {
private static final String _LOCK_CLASS_NAME = SendMailMessageListener.class.getName(); 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 { public void receive(Message message) throws MessageListenerException {
try { try {
ActionableDynamicQuery actionableDynamicQuery = new EmailActionableDynamicQuery() { ActionableDynamicQuery actionableDynamicQuery = new EmailActionableDynamicQuery() {
@Override @Override
@ -46,26 +45,18 @@ public class SendMailMessageListener implements MessageListener {
protected void performAction(Object obj) throws PortalException, SystemException { protected void performAction(Object obj) throws PortalException, SystemException {
Email email = (Email) obj; Email email = (Email) obj;
try { try {
MailSenderUtil.sendMail(email); MailSenderUtil.sendMail(email);
EmailLocalServiceUtil.markAsSent(email.getEmailId(), new Date(), StringPool.BLANK); EmailLocalServiceUtil.markAsSent(email.getEmailId(), new Date(), StringPool.BLANK);
} catch (Exception e) { } catch (Exception e) {
EmailLocalServiceUtil.updateStatusMessage(email.getEmailId(), e.getMessage()); EmailLocalServiceUtil.updateStatusMessage(email.getEmailId(), e.getMessage());
} }
} }
}; };
long count = actionableDynamicQuery.performCount(); long count = actionableDynamicQuery.performCount();
if (count > 0) { if (count > 0) {
String owner = PortalUUIDUtil.generate(); String owner = PortalUUIDUtil.generate();
if (tryLock(owner)) { if (tryLock(owner)) {
try { try {
actionableDynamicQuery.performActions(); actionableDynamicQuery.performActions();
} finally { } finally {
@ -73,7 +64,6 @@ public class SendMailMessageListener implements MessageListener {
} }
} }
} }
} catch (Exception e) { } catch (Exception e) {
_log.error(e, e); _log.error(e, e);
} }
@ -82,31 +72,24 @@ public class SendMailMessageListener implements MessageListener {
private boolean tryLock(String owner) { private boolean tryLock(String owner) {
try { try {
Lock lock = null; Lock lock = null;
while (true) { while (true) {
try { try {
lock = LockLocalServiceUtil.lock(_LOCK_CLASS_NAME, _LOCK_CLASS_NAME, owner); lock = LockLocalServiceUtil.lock(_LOCK_CLASS_NAME, _LOCK_CLASS_NAME, owner);
break; break;
} catch (SystemException se) { } catch (SystemException se) {
try { try {
Thread.sleep(50); Thread.sleep(50);
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
} }
} }
} }
if (!lock.isNew()) { if (!lock.isNew()) {
throw new DuplicateLockException(lock); throw new DuplicateLockException(lock);
} }
} catch (DuplicateLockException e) { } catch (DuplicateLockException e) {
return false; return false;
} }
return true; 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; 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.PortalException;
import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log; 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.portal.service.ServiceContextFactory;
import com.liferay.util.bridges.mvc.MVCPortlet; 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 { public class EmailPortlet extends MVCPortlet {
private static Log _log = LogFactoryUtil.getLog(EmailPortlet.class); 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 { public void editEmail(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
_log.debug("editEmail - Inizio metodo"); _log.debug("editEmail - Inizio metodo");
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
long emailId = ParamUtil.getLong(actionRequest, "emailId"); long emailId = ParamUtil.getLong(actionRequest, "emailId");
String from = ParamUtil.getString(actionRequest, "from"); String from = ParamUtil.getString(actionRequest, "from");
String[] to = StringUtil.splitAndTrim(ParamUtil.getString(actionRequest, "to")); String[] to = StringUtil.splitAndTrim(ParamUtil.getString(actionRequest, "to"));
String[] cc = StringUtil.splitAndTrim(ParamUtil.getString(actionRequest, "cc")); String[] cc = StringUtil.splitAndTrim(ParamUtil.getString(actionRequest, "cc"));
String[] ccn = StringUtil.splitAndTrim(ParamUtil.getString(actionRequest, "ccn")); String[] ccn = StringUtil.splitAndTrim(ParamUtil.getString(actionRequest, "ccn"));
String subject = ParamUtil.getString(actionRequest, "subject"); String subject = ParamUtil.getString(actionRequest, "subject");
String body = ParamUtil.getString(actionRequest, "body"); String body = ParamUtil.getString(actionRequest, "body");
EmailServiceUtil.updateEmail(emailId, from, to, cc, ccn, subject, body, serviceContext); EmailServiceUtil.updateEmail(emailId, from, to, cc, ccn, subject, body, serviceContext);
} }
public void annullaEmail(ActionRequest actionRequest, ActionResponse actionResponse) public void annullaEmail(ActionRequest actionRequest, ActionResponse actionResponse)
throws PortalException, SystemException { throws PortalException, SystemException {
_log.debug("annullaEmail - inizio metodo"); _log.debug("annullaEmail - inizio metodo");
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
long emailId = ParamUtil.getLong(actionRequest, "emailId"); long emailId = ParamUtil.getLong(actionRequest, "emailId");
EmailServiceUtil.cancelEmail(emailId, serviceContext); EmailServiceUtil.cancelEmail(emailId, serviceContext);
@ -55,10 +45,8 @@ public class EmailPortlet extends MVCPortlet {
public void resendEmail(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { public void resendEmail(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
_log.debug("reinviaEmail - Inizio metodo"); _log.debug("reinviaEmail - Inizio metodo");
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
long emailId = ParamUtil.getLong(actionRequest, "emailId"); long emailId = ParamUtil.getLong(actionRequest, "emailId");
EmailServiceUtil.resendEmail(emailId, serviceContext); 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; 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.PortalException;
import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSONFactoryUtil; 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.portal.util.PortalUtil;
import com.liferay.util.bridges.mvc.MVCPortlet; 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 * Portlet implementation class EmailTemplates
*/ */
@ -38,43 +38,34 @@ public class EmailTemplatesPortlet extends MVCPortlet {
private static Log _log = LogFactoryUtil.getLog(EmailTemplatesPortlet.class); private static Log _log = LogFactoryUtil.getLog(EmailTemplatesPortlet.class);
public void editTemplateEmail(ActionRequest actionRequest, ActionResponse actionResponse) public void editTemplateEmail(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException,
throws PortalException, SystemException { SystemException {
String cmd = ParamUtil.getString(actionRequest, Constants.CMD); String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
long emailTemplateId = ParamUtil.getLong(actionRequest, "emailTemplateId"); long emailTemplateId = ParamUtil.getLong(actionRequest, "emailTemplateId");
String templateName = ParamUtil.getString(actionRequest, "templateName"); String templateName = ParamUtil.getString(actionRequest, "templateName");
String from = ParamUtil.getString(actionRequest, "from"); String from = ParamUtil.getString(actionRequest, "from");
String[] to = StringUtil.splitAndTrim(ParamUtil.getString(actionRequest, "to")); String[] to = StringUtil.splitAndTrim(ParamUtil.getString(actionRequest, "to"));
String[] cc = StringUtil.splitAndTrim(ParamUtil.getString(actionRequest, "cc")); String[] cc = StringUtil.splitAndTrim(ParamUtil.getString(actionRequest, "cc"));
String[] ccn = StringUtil.splitAndTrim(ParamUtil.getString(actionRequest, "ccn")); String[] ccn = StringUtil.splitAndTrim(ParamUtil.getString(actionRequest, "ccn"));
String subject = ParamUtil.getString(actionRequest, "subject"); String subject = ParamUtil.getString(actionRequest, "subject");
String body = ParamUtil.getString(actionRequest, "body"); String body = ParamUtil.getString(actionRequest, "body");
Boolean attachmentPermitted = ParamUtil.getBoolean(actionRequest, "attachmentPermitted"); Boolean attachmentPermitted = ParamUtil.getBoolean(actionRequest, "attachmentPermitted");
try { try {
EmailTemplate emailTemplate = null; EmailTemplate emailTemplate = null;
if (cmd.equals(Constants.ADD)) { if (cmd.equals(Constants.ADD)) {
emailTemplate = EmailTemplateServiceUtil.addEmailTemplate(templateName, from, to, cc, ccn, emailTemplate = EmailTemplateServiceUtil.addEmailTemplate(templateName, from, to, cc, ccn, subject,
subject, body, attachmentPermitted, serviceContext); body, attachmentPermitted, serviceContext);
emailTemplateId = emailTemplate.getEmailTemplateId(); emailTemplateId = emailTemplate.getEmailTemplateId();
} else if (cmd.equals(Constants.UPDATE)) { } else if (cmd.equals(Constants.UPDATE)) {
emailTemplate = EmailTemplateServiceUtil.updateEmailTemplate(emailTemplateId, templateName, emailTemplate = EmailTemplateServiceUtil.updateEmailTemplate(emailTemplateId, templateName, from, to,
from, to, cc, ccn, subject, body, attachmentPermitted, serviceContext); cc, ccn, subject, body, attachmentPermitted, serviceContext);
} }
emailTemplateId = emailTemplate.getEmailTemplateId(); emailTemplateId = emailTemplate.getEmailTemplateId();
} catch (PortalException e) { } catch (PortalException e) {
SessionErrors.add(actionRequest, e.getClass()); SessionErrors.add(actionRequest, e.getClass());
} }
if (SessionErrors.isEmpty(actionRequest)) { if (SessionErrors.isEmpty(actionRequest)) {
actionResponse.setRenderParameter("emailTemplateId", String.valueOf(emailTemplateId)); actionResponse.setRenderParameter("emailTemplateId", String.valueOf(emailTemplateId));
actionResponse.setRenderParameter("mvcPath", "/html/email_templates/edit.jsp"); 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"); actionResponse.setRenderParameter("mvcPath", "/html/email_templates/edit.jsp");
PortalUtil.copyRequestParameters(actionRequest, actionResponse); PortalUtil.copyRequestParameters(actionRequest, actionResponse);
} }
} }
public void deleteEmailTemplate(ActionRequest actionRequest, ActionResponse actionResponse) public void deleteEmailTemplate(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException,
throws PortalException, SystemException { SystemException {
long emailTemplateId = ParamUtil.getLong(actionRequest, "emailTemplateId"); long emailTemplateId = ParamUtil.getLong(actionRequest, "emailTemplateId");
EmailTemplateServiceUtil.deleteEmailTemplate(emailTemplateId); EmailTemplateServiceUtil.deleteEmailTemplate(emailTemplateId);
} }
public void addEmailByTemplate(ActionRequest actionRequest, ActionResponse actionResponse) public void addEmailByTemplate(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException,
throws PortalException, SystemException { SystemException {
UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest); UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest);
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
long emailTemplateId = ParamUtil.getLong(actionRequest, "emailTemplateId"); long emailTemplateId = ParamUtil.getLong(actionRequest, "emailTemplateId");
EmailTemplate emailTemplate = EmailTemplateLocalServiceUtil.getEmailTemplate(emailTemplateId); EmailTemplate emailTemplate = EmailTemplateLocalServiceUtil.getEmailTemplate(emailTemplateId);
String sendModeStr = ParamUtil.getString(actionRequest, "sendMode"); String sendModeStr = ParamUtil.getString(actionRequest, "sendMode");
SendTemplateMode sendMode = SendTemplateMode.parse(sendModeStr); SendTemplateMode sendMode = SendTemplateMode.parse(sendModeStr);
String className = ParamUtil.getString(actionRequest, "className"); String className = ParamUtil.getString(actionRequest, "className");
long classPK = ParamUtil.getLong(actionRequest, "classPK"); long classPK = ParamUtil.getLong(actionRequest, "classPK");
try { try {
// eventuali allegati email // eventuali allegati email
List<com.liferay.mail.model.FileAttachment> fileAttachments = null; List<com.liferay.mail.model.FileAttachment> fileAttachments = null;
if (emailTemplate.getAttachmentPermitted()) { if (emailTemplate.getAttachmentPermitted()) {
fileAttachments = MailUtil.getEmailFileAttachments(uploadPortletRequest); fileAttachments = MailUtil.getEmailFileAttachments(uploadPortletRequest);
} }
if (sendMode == SendTemplateMode.REVIEW) { if (sendMode == SendTemplateMode.REVIEW) {
String templateParamJSON = ParamUtil.getString(actionRequest, "templateParamJSON"); String templateParamJSON = ParamUtil.getString(actionRequest, "templateParamJSON");
JSONObject templateParamJSONObj = JSONFactoryUtil.createJSONObject(templateParamJSON); JSONObject templateParamJSONObj = JSONFactoryUtil.createJSONObject(templateParamJSON);
MailManagerUtil.addEmailByTemplate(className, classPK, emailTemplateId, templateParamJSONObj, MailManagerUtil.addEmailByTemplate(className, classPK, emailTemplateId, templateParamJSONObj,
fileAttachments, serviceContext); fileAttachments, serviceContext);
} else if (sendMode == SendTemplateMode.EDIT) { } else if (sendMode == SendTemplateMode.EDIT) {
String from = ParamUtil.getString(actionRequest, "from"); String from = ParamUtil.getString(actionRequest, "from");
String to = ParamUtil.getString(actionRequest, "to"); String to = ParamUtil.getString(actionRequest, "to");
String cc = ParamUtil.getString(actionRequest, "cc"); String cc = ParamUtil.getString(actionRequest, "cc");
String ccn = ParamUtil.getString(actionRequest, "ccn"); String ccn = ParamUtil.getString(actionRequest, "ccn");
String subject = ParamUtil.getString(actionRequest, "subject"); String subject = ParamUtil.getString(actionRequest, "subject");
String body = ParamUtil.getString(actionRequest, "body"); String body = ParamUtil.getString(actionRequest, "body");
EmailLocalServiceUtil.addEmail(className, classPK, from, StringUtil.split(to, StringPool.COMMA),
EmailLocalServiceUtil.addEmail(className, classPK, from, StringUtil.split(cc, StringPool.COMMA), StringUtil.split(ccn, StringPool.COMMA), subject, body,
StringUtil.split(to, StringPool.COMMA), StringUtil.split(cc, StringPool.COMMA), true, fileAttachments, serviceContext);
StringUtil.split(ccn, StringPool.COMMA), subject, body, true, fileAttachments,
serviceContext);
} }
UploadPortletRequestUtil.copyRequestParameters(uploadPortletRequest, actionResponse); UploadPortletRequestUtil.copyRequestParameters(uploadPortletRequest, actionResponse);
actionResponse.setRenderParameter("mvcPath", "/html/email_templates/send_popup/close_popup.jsp"); actionResponse.setRenderParameter("mvcPath", "/html/email_templates/send_popup/close_popup.jsp");
@ -143,7 +121,5 @@ public class EmailTemplatesPortlet extends MVCPortlet {
UploadPortletRequestUtil.copyRequestParameters(uploadPortletRequest, actionResponse); UploadPortletRequestUtil.copyRequestParameters(uploadPortletRequest, actionResponse);
throw new SystemException("Error add email by template.", ex); 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. * 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 * The contents of this file are subject to the terms of the Liferay Enterprise Subscription License ("License"). You
* ("License"). You may not use this file except in compliance with the License. You can obtain a * may not use this file except in compliance with the License. You can obtain a copy of the License by contacting
* copy of the License by contacting Liferay, Inc. See the License for the specific language * Liferay, Inc. See the License for the specific language governing permissions and limitations under the License,
* governing permissions and limitations under the License, including but not limited to * including but not limited to distribution rights of the Software.
* distribution rights of the Software.
* *
* *
* *
@ -13,6 +12,16 @@
package it.tref.liferay.portos.mailmanager.service.impl; 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.PortalException;
import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.repository.model.FileEntry; 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.security.permission.ActionKeys;
import com.liferay.portal.service.ServiceContext; 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. * The implementation of the email attachment local service.
* *
* <p> * <p>
* All custom service methods should be put in this class. Whenever methods are * All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy
* added, rerun ServiceBuilder to copy their definitions into the * their definitions into the {@link it.noovle.azimut.icf.mailmanager.service.EmailAttachmentLocalService} interface.
* {@link it.noovle.azimut.icf.mailmanager.service.EmailAttachmentLocalService}
* interface.
* *
* <p> * <p>
* This is a local service. Methods of this service will not have security * This is a local service. Methods of this service will not have security checks based on the propagated JAAS
* checks based on the propagated JAAS credentials because this service can only * credentials because this service can only be accessed from within the same VM.
* be accessed from within the same VM.
* </p> * </p>
* *
* @author * @author
@ -57,54 +53,46 @@ import java.util.List;
*/ */
public class EmailAttachmentLocalServiceImpl extends EmailAttachmentLocalServiceBaseImpl { public class EmailAttachmentLocalServiceImpl extends EmailAttachmentLocalServiceBaseImpl {
/* /*
* NOTE FOR DEVELOPERS: * NOTE FOR DEVELOPERS: Never reference this interface directly. Always use {@link
* * it.noovle.azimut.icf.mailmanager.service.EmailAttachmentLocalServiceUtil} to access the email attachment local
* Never reference this interface directly. Always use {@link * service.
* it.noovle.azimut.icf.mailmanager.service.EmailAttachmentLocalServiceUtil}
* to access the email attachment local service.
*/ */
public EmailAttachment addEmailAttachment(long companyId, long emailId, long folderId, String fileName, @Override
File file) throws PortalException, SystemException { public EmailAttachment addEmailAttachment(long companyId, long emailId, long folderId, String fileName, File file)
throws PortalException, SystemException {
Company company = companyLocalService.getCompany(companyId); Company company = companyLocalService.getCompany(companyId);
User defaultUser = company.getDefaultUser(); User defaultUser = company.getDefaultUser();
validate(emailId, fileName, file); validate(emailId, fileName, file);
Folder folder = dlAppLocalService.getFolder(folderId); Folder folder = dlAppLocalService.getFolder(folderId);
String sourceFileName = file.getName(); String sourceFileName = file.getName();
String mimeType = MimeTypesUtil.getContentType(sourceFileName); String mimeType = MimeTypesUtil.getContentType(sourceFileName);
String title = fileName; String title = fileName;
if (Validator.isNull(title)) { if (Validator.isNull(title)) {
title = file.getName(); title = file.getName();
} }
ServiceContext serviceContext = new ServiceContext(); ServiceContext serviceContext = new ServiceContext();
serviceContext.setGroupPermissions(new String[] { ActionKeys.VIEW }); serviceContext.setGroupPermissions(new String[] { ActionKeys.VIEW });
serviceContext.setGuestPermissions(new String[] { ActionKeys.VIEW }); serviceContext.setGuestPermissions(new String[] { ActionKeys.VIEW });
FileEntry fileEntry = dlAppLocalService.addFileEntry(defaultUser.getUserId(), folder.getRepositoryId(),
FileEntry fileEntry = dlAppLocalService.addFileEntry(defaultUser.getUserId(), folder.getFolderId(), sourceFileName, mimeType, title, StringPool.BLANK, StringPool.BLANK, file,
folder.getRepositoryId(), folder.getFolderId(), sourceFileName, mimeType, title, serviceContext);
StringPool.BLANK, StringPool.BLANK, file, serviceContext); EmailAttachment emailAttachment = emailAttachmentLocalService.createEmailAttachment(new EmailAttachmentPK(
emailId, fileEntry.getFileEntryId()));
EmailAttachment emailAttachment = emailAttachmentLocalService
.createEmailAttachment(new EmailAttachmentPK(emailId, fileEntry.getFileEntryId()));
return emailAttachmentLocalService.addEmailAttachment(emailAttachment); return emailAttachmentLocalService.addEmailAttachment(emailAttachment);
} }
@Override @Override
public EmailAttachment deleteEmailAttachment(EmailAttachmentPK emailAttachmentPK) throws PortalException, public EmailAttachment deleteEmailAttachment(EmailAttachmentPK emailAttachmentPK) throws PortalException,
SystemException { SystemException {
EmailAttachment emailAttachment = emailAttachmentLocalService.getEmailAttachment(emailAttachmentPK); EmailAttachment emailAttachment = emailAttachmentLocalService.getEmailAttachment(emailAttachmentPK);
return deleteEmailAttachment(emailAttachment); return deleteEmailAttachment(emailAttachment);
} }
@Override @Override
public EmailAttachment deleteEmailAttachment(EmailAttachment emailAttachment) throws SystemException { public EmailAttachment deleteEmailAttachment(EmailAttachment emailAttachment) throws SystemException {
try { try {
dlAppLocalService.deleteFileEntry(emailAttachment.getFileEntryId()); dlAppLocalService.deleteFileEntry(emailAttachment.getFileEntryId());
} catch (PortalException e) { } catch (PortalException e) {
@ -113,19 +101,27 @@ public class EmailAttachmentLocalServiceImpl extends EmailAttachmentLocalService
return emailAttachment; return emailAttachment;
} }
@Override
public List<EmailAttachment> findByEmailId(long emailId) throws SystemException { public List<EmailAttachment> findByEmailId(long emailId) throws SystemException {
return emailAttachmentPersistence.findByEmailId(emailId); return emailAttachmentPersistence.findByEmailId(emailId);
} }
@Override
public List<EmailAttachment> findByEmailId(long emailId, int start, int end) throws SystemException { public List<EmailAttachment> findByEmailId(long emailId, int start, int end) throws SystemException {
return emailAttachmentPersistence.findByEmailId(emailId); return emailAttachmentPersistence.findByEmailId(emailId);
} }
@Override
public int countByEmailId(long emailId) throws SystemException { public int countByEmailId(long emailId) throws SystemException {
return emailAttachmentPersistence.countByEmailId(emailId); return emailAttachmentPersistence.countByEmailId(emailId);
} }
@Override
public EmailAttachment fetchByFileEntryId(long fileEntryId) throws SystemException { public EmailAttachment fetchByFileEntryId(long fileEntryId) throws SystemException {
return emailAttachmentPersistence.fetchByFileEntryId(fileEntryId); return emailAttachmentPersistence.fetchByFileEntryId(fileEntryId);
} }
@ -134,11 +130,9 @@ public class EmailAttachmentLocalServiceImpl extends EmailAttachmentLocalService
if (Validator.isNull(emailId)) { if (Validator.isNull(emailId)) {
throw new NoSuchEmailException(); throw new NoSuchEmailException();
} }
if (Validator.isNull(fileName) && Validator.isNull(file)) { if (Validator.isNull(fileName) && Validator.isNull(file)) {
throw new EmailAttachmentTitleException(); throw new EmailAttachmentTitleException();
} }
if (Validator.isNull(file) || (Validator.isNotNull(file) && !FileUtil.exists(file))) { if (Validator.isNull(file) || (Validator.isNotNull(file) && !FileUtil.exists(file))) {
throw new EmailAttachmentFileException(); 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. * 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 * The contents of this file are subject to the terms of the Liferay Enterprise Subscription License ("License"). You
* ("License"). You may not use this file except in compliance with the License. You can obtain a * may not use this file except in compliance with the License. You can obtain a copy of the License by contacting
* copy of the License by contacting Liferay, Inc. See the License for the specific language * Liferay, Inc. See the License for the specific language governing permissions and limitations under the License,
* governing permissions and limitations under the License, including but not limited to * including but not limited to distribution rights of the Software.
* distribution rights of the Software.
* *
* *
* *
@ -13,24 +12,6 @@
package it.tref.liferay.portos.mailmanager.service.impl; 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.EmailBccException;
import it.tref.liferay.portos.mailmanager.EmailBulkAddressesException; import it.tref.liferay.portos.mailmanager.EmailBulkAddressesException;
import it.tref.liferay.portos.mailmanager.EmailCcException; import it.tref.liferay.portos.mailmanager.EmailCcException;
@ -51,18 +32,34 @@ import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; 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. * The implementation of the email local service.
* *
* <p> * <p>
* All custom service methods should be put in this class. Whenever methods are * All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy
* added, rerun ServiceBuilder to copy their definitions into the * their definitions into the {@link it.noovle.azimut.icf.mailmanager.service.EmailLocalService} interface.
* {@link it.noovle.azimut.icf.mailmanager.service.EmailLocalService} interface.
* *
* <p> * <p>
* This is a local service. Methods of this service will not have security * This is a local service. Methods of this service will not have security checks based on the propagated JAAS
* checks based on the propagated JAAS credentials because this service can only * credentials because this service can only be accessed from within the same VM.
* be accessed from within the same VM.
* </p> * </p>
* *
* @author * @author
@ -71,70 +68,69 @@ import java.util.List;
*/ */
public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl { public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
/* /*
* NOTE FOR DEVELOPERS: * NOTE FOR DEVELOPERS: Never reference this interface directly. Always use {@link
* * it.noovle.azimut.icf.mailmanager.service.EmailLocalServiceUtil} to access the email local service.
* 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); private final static Log _log = LogFactoryUtil.getLog(EmailLocalServiceImpl.class);
public Email addEmail(String className, long classPK, String from, String to[], String cc[], @Override
String bcc[], String subject, String body, boolean htmlFormat, ServiceContext serviceContext) public Email addEmail(String className, long classPK, String from, String to[], String cc[], String bcc[],
throws Exception { 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);
}
public Email addEmail(String className, long classPK, String from, String to[], String cc[], return addEmail(className, classPK, from, to, cc, bcc, null, subject, body, htmlFormat, null, null, null, null,
String bcc[], String subject, String body, boolean htmlFormat, 0, false, null, null, Collections.<FileAttachment> emptyList(), serviceContext);
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[], @Override
String bcc[], String[] bulkAddresses, String subject, String body, boolean htmlFormat, public Email addEmail(String className, long classPK, String from, String to[], String cc[], String bcc[],
String[] replyTo, String messageId, String inReplyTo, String smtpHost, int smtpPort, String subject, String body, boolean htmlFormat, List<FileAttachment> fileAttachments,
boolean smtpSecure, String smtpUsername, String smtpPassword, ServiceContext serviceContext) throws Exception {
List<FileAttachment> fileAttachments, ServiceContext serviceContext) throws Exception {
return addEmail(className, classPK, from, to, cc, bcc, bulkAddresses, subject, body, htmlFormat, return addEmail(className, classPK, from, to, cc, bcc, null, subject, body, htmlFormat, null, null, null, null,
replyTo, messageId, inReplyTo, smtpHost, smtpPort, smtpSecure, smtpUsername, smtpPassword, 0, false, null, null, fileAttachments, false, null, serviceContext);
fileAttachments, false, null, serviceContext);
} }
public Email addEmail(String className, long classPK, String from, String to[], String cc[], @Override
String bcc[], String subject, String body, boolean htmlFormat, public Email addEmail(String className, long classPK, String from, String to[], String cc[], String bcc[],
List<FileAttachment> fileAttachments, boolean sendSync, ServiceContext serviceContext) String[] bulkAddresses, String subject, String body, boolean htmlFormat, String[] replyTo,
throws Exception { String messageId, String inReplyTo, String smtpHost, int smtpPort, boolean smtpSecure, String smtpUsername,
return addEmail(className, classPK, from, to, cc, bcc, null, subject, body, htmlFormat, null, null, String smtpPassword, List<FileAttachment> fileAttachments, ServiceContext serviceContext) throws Exception {
null, null, 0, false, null, null, fileAttachments, sendSync, null, serviceContext);
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[], @Override
String bcc[], String subject, String body, boolean htmlFormat, public Email addEmail(String className, long classPK, String from, String to[], String cc[], String bcc[],
List<FileAttachment> fileAttachments, boolean sendSync, String templateName, String subject, String body, boolean htmlFormat, List<FileAttachment> fileAttachments, boolean sendSync,
ServiceContext serviceContext) throws Exception { 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[], @Override
String bcc[], String[] bulkAddresses, String subject, String body, boolean htmlFormat, public Email addEmail(String className, long classPK, String from, String to[], String cc[], String bcc[],
String[] replyTo, String messageId, String inReplyTo, String smtpHost, int smtpPort, String subject, String body, boolean htmlFormat, List<FileAttachment> fileAttachments, boolean sendSync,
boolean smtpSecure, String smtpUsername, String smtpPassword, String templateName, ServiceContext serviceContext) throws Exception {
List<FileAttachment> fileAttachments, boolean sendSync, String templateName,
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 { ServiceContext serviceContext) throws Exception {
User user = userLocalService.getUser(serviceContext.getUserId()); User user = userLocalService.getUser(serviceContext.getUserId());
Date now = new Date(); Date now = new Date();
validate(from, to, cc, bcc, bulkAddresses, subject, body, replyTo); validate(from, to, cc, bcc, bulkAddresses, subject, body, replyTo);
Email email = emailLocalService.createEmail(counterLocalService.increment(Email.class.getName())); Email email = emailLocalService.createEmail(counterLocalService.increment(Email.class.getName()));
email.setGroupId(serviceContext.getScopeGroupId()); email.setGroupId(serviceContext.getScopeGroupId());
email.setCompanyId(serviceContext.getCompanyId()); email.setCompanyId(serviceContext.getCompanyId());
email.setCreateDate(serviceContext.getCreateDate(now)); email.setCreateDate(serviceContext.getCreateDate(now));
@ -143,7 +139,6 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
email.setClassPK(classPK); email.setClassPK(classPK);
email.setUserId(user.getUserId()); email.setUserId(user.getUserId());
email.setUserName(user.getFullName()); email.setUserName(user.getFullName());
email.setFrom(from); email.setFrom(from);
email.setTo(StringUtil.merge(to, StringPool.COMMA)); email.setTo(StringUtil.merge(to, StringPool.COMMA));
email.setCc(StringUtil.merge(cc, 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.setBulkAddresses(StringUtil.merge(bulkAddresses, StringPool.COMMA));
email.setSubject(subject); email.setSubject(subject);
email.setBody(body); email.setBody(body);
email.setHtmlFormat(htmlFormat); email.setHtmlFormat(htmlFormat);
email.setReplyTo(StringUtil.merge(replyTo, StringPool.COMMA)); email.setReplyTo(StringUtil.merge(replyTo, StringPool.COMMA));
email.setMessageId(messageId); email.setMessageId(messageId);
email.setInReplyTo(inReplyTo); email.setInReplyTo(inReplyTo);
email.setSmtpHost(smtpHost); email.setSmtpHost(smtpHost);
email.setSmtpPort(smtpPort); email.setSmtpPort(smtpPort);
email.setSmtpSecure(smtpSecure); email.setSmtpSecure(smtpSecure);
@ -164,47 +157,33 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
email.setSmtpPassword(smtpPassword); email.setSmtpPassword(smtpPassword);
email.setCancel(false); email.setCancel(false);
email.setTemplateName(templateName); email.setTemplateName(templateName);
email = addEmail(email); email = addEmail(email);
// Email Attachments // Email Attachments
if (fileAttachments != null && !fileAttachments.isEmpty()) { if (fileAttachments != null && !fileAttachments.isEmpty()) {
Folder folder = addEmailAttachmentsFolder(serviceContext.getCompanyId(), email.getEmailId()); Folder folder = addEmailAttachmentsFolder(serviceContext.getCompanyId(), email.getEmailId());
for (FileAttachment fileAttachment : fileAttachments) { for (FileAttachment fileAttachment : fileAttachments) {
if (fileAttachment instanceof FileAttachment) { if (fileAttachment instanceof FileAttachment) {
((it.tref.liferay.portos.mailmanager.shared.model.FileAttachment) fileAttachment) ((it.tref.liferay.portos.mailmanager.shared.model.FileAttachment) fileAttachment).generateFile();
.generateFile();
} }
emailAttachmentLocalService.addEmailAttachment(serviceContext.getCompanyId(), emailAttachmentLocalService.addEmailAttachment(serviceContext.getCompanyId(), email.getEmailId(),
email.getEmailId(), folder.getFolderId(), fileAttachment.getFileName(), folder.getFolderId(), fileAttachment.getFileName(), fileAttachment.getFile());
fileAttachment.getFile());
FileUtil.delete(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; sendSync = true;
if (sendSync) { if (sendSync) {
MailSenderUtil.sendMail(email); MailSenderUtil.sendMail(email);
markAsSent(email.getEmailId(), new Date(), StringPool.BLANK); markAsSent(email.getEmailId(), new Date(), StringPool.BLANK);
} }
return email; return email;
} }
public Email updateEmail(long emailId, String from, String to[], String cc[], String bcc[], @Override
String subject, String body, ServiceContext serviceContext) throws Exception { 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); Email email = emailLocalService.getEmail(emailId);
validate(from, to, cc, bcc, null, subject, body, null); validate(from, to, cc, bcc, null, subject, body, null);
email.setModifiedDate(new Date()); email.setModifiedDate(new Date());
email.setFrom(from); email.setFrom(from);
email.setTo(StringUtil.merge(to, StringPool.COMMA)); email.setTo(StringUtil.merge(to, StringPool.COMMA));
@ -212,59 +191,53 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
email.setBcc(StringUtil.merge(bcc, StringPool.COMMA)); email.setBcc(StringUtil.merge(bcc, StringPool.COMMA));
email.setSubject(subject); email.setSubject(subject);
email.setBody(body); email.setBody(body);
return updateEmail(email); return updateEmail(email);
} }
public Email markAsSent(long emailId, Date sentDate, String statusMessage) throws PortalException, @Override
SystemException { public Email markAsSent(long emailId, Date sentDate, String statusMessage) throws PortalException, SystemException {
Email email = emailLocalService.getEmail(emailId); Email email = emailLocalService.getEmail(emailId);
email.setModifiedDate(new Date()); email.setModifiedDate(new Date());
email.setSent(true); email.setSent(true);
email.setSentDate(sentDate); email.setSentDate(sentDate);
email.setStatusMessage(statusMessage); email.setStatusMessage(statusMessage);
return updateEmail(email); return updateEmail(email);
} }
public Email updateStatusMessage(long emailId, String statusMessage) throws PortalException, @Override
SystemException { public Email updateStatusMessage(long emailId, String statusMessage) throws PortalException, SystemException {
Email email = emailLocalService.getEmail(emailId); Email email = emailLocalService.getEmail(emailId);
email.setModifiedDate(new Date()); email.setModifiedDate(new Date());
email.setStatusMessage(statusMessage); email.setStatusMessage(statusMessage);
return updateEmail(email); return updateEmail(email);
} }
@Override
public Email resendEmail(long emailId) throws PortalException, SystemException { public Email resendEmail(long emailId) throws PortalException, SystemException {
Email email = emailLocalService.getEmail(emailId); Email email = emailLocalService.getEmail(emailId);
email.setModifiedDate(new Date()); email.setModifiedDate(new Date());
email.setStatusMessage(StringPool.BLANK);
email.setStatusMessage("");
email.setSent(false); email.setSent(false);
email.setSentDate(null); email.setSentDate(null);
email.setCancel(false); email.setCancel(false);
return updateEmail(email); return updateEmail(email);
} }
@Override
public Email cancelEmail(long emailId) throws PortalException, SystemException { public Email cancelEmail(long emailId) throws PortalException, SystemException {
Email email = emailLocalService.getEmail(emailId); Email email = emailLocalService.getEmail(emailId);
email.setModifiedDate(new Date()); email.setModifiedDate(new Date());
email.setCancel(true); email.setCancel(true);
return updateEmail(email); return updateEmail(email);
} }
@Override @Override
public Email deleteEmail(long emailId) throws PortalException, SystemException { public Email deleteEmail(long emailId) throws PortalException, SystemException {
Email email = emailLocalService.getEmail(emailId); Email email = emailLocalService.getEmail(emailId);
return deleteEmail(email); return deleteEmail(email);
} }
@ -273,108 +246,125 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
public Email deleteEmail(Email email) throws SystemException { public Email deleteEmail(Email email) throws SystemException {
super.deleteEmail(email); super.deleteEmail(email);
// Email Attachments // Email Attachments
List<EmailAttachment> emailAttachments = emailAttachmentLocalService.findByEmailId(email.getEmailId());
List<EmailAttachment> emailAttachments = emailAttachmentLocalService
.findByEmailId(email.getEmailId());
for (EmailAttachment emailAttachment : emailAttachments) { for (EmailAttachment emailAttachment : emailAttachments) {
emailAttachmentLocalService.deleteEmailAttachment(emailAttachment); emailAttachmentLocalService.deleteEmailAttachment(emailAttachment);
} }
return email; return email;
} }
@Override
public List<Email> findByCompany(long companyId) throws SystemException { public List<Email> findByCompany(long companyId) throws SystemException {
return emailPersistence.findByCompany(companyId); return emailPersistence.findByCompany(companyId);
} }
@Override
public List<Email> findByCompany(long companyId, int start, int end) throws SystemException { public List<Email> findByCompany(long companyId, int start, int end) throws SystemException {
return emailPersistence.findByCompany(companyId, start, end); return emailPersistence.findByCompany(companyId, start, end);
} }
@Override
public List<Email> findByCompany(long companyId, int start, int end, OrderByComparator orderByComparator) public List<Email> findByCompany(long companyId, int start, int end, OrderByComparator orderByComparator)
throws SystemException { throws SystemException {
return emailPersistence.findByCompany(companyId, start, end, orderByComparator); return emailPersistence.findByCompany(companyId, start, end, orderByComparator);
} }
@Override
public int countByCompany(long companyId) throws SystemException { public int countByCompany(long companyId) throws SystemException {
return emailPersistence.countByCompany(companyId); return emailPersistence.countByCompany(companyId);
} }
@Override
public List<Email> findByC_G(long companyId, long groupId) throws SystemException { public List<Email> findByC_G(long companyId, long groupId) throws SystemException {
return emailPersistence.findByC_G(companyId, groupId); return emailPersistence.findByC_G(companyId, groupId);
} }
@Override
public List<Email> findByC_G(long companyId, long groupId, int start, int end) throws SystemException { public List<Email> findByC_G(long companyId, long groupId, int start, int end) throws SystemException {
return emailPersistence.findByC_G(companyId, groupId, start, end); return emailPersistence.findByC_G(companyId, groupId, start, end);
} }
public List<Email> findByC_G(long companyId, long groupId, int start, int end, @Override
OrderByComparator orderByComparator) throws SystemException { 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); return emailPersistence.findByC_G(companyId, groupId, start, end, orderByComparator);
} }
@Override
public int countByC_G(long companyId, long groupId) throws SystemException { public int countByC_G(long companyId, long groupId) throws SystemException {
return emailPersistence.countByC_G(companyId, groupId); return emailPersistence.countByC_G(companyId, groupId);
} }
@Override
public List<Email> findByC_G_T(long companyId, long groupId, String templateName) throws SystemException { public List<Email> findByC_G_T(long companyId, long groupId, String templateName) throws SystemException {
return emailPersistence.findByC_G_T(companyId, groupId, templateName); 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) public List<Email> findByC_G_T(long companyId, long groupId, String templateName, int start, int end)
throws SystemException { throws SystemException {
return emailPersistence.findByC_G_T(companyId, groupId, templateName, start, end); return emailPersistence.findByC_G_T(companyId, groupId, templateName, start, end);
} }
@Override
public int countByC_G_T(long companyId, long groupId, String templateName) throws SystemException { public int countByC_G_T(long companyId, long groupId, String templateName) throws SystemException {
return emailPersistence.countByC_G_T(companyId, groupId, templateName); return emailPersistence.countByC_G_T(companyId, groupId, templateName);
} }
@Override
public List<Email> findByC_G_C_C(long companyId, long groupId, long classNameId, long classPK) public List<Email> findByC_G_C_C(long companyId, long groupId, long classNameId, long classPK)
throws SystemException { throws SystemException {
return emailPersistence.findByC_G_C_C(companyId, groupId, classNameId, classPK); 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, @Override
int end) throws SystemException { 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); 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) @Override
throws SystemException { 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); return emailPersistence.countByC_G_C_C(companyId, groupId, classNameId, classPK);
} }
private Folder addEmailAttachmentsFolder(long companyId, long emailId) throws PortalException, private Folder addEmailAttachmentsFolder(long companyId, long emailId) throws PortalException, SystemException {
SystemException {
Company company = companyLocalService.getCompany(companyId); Company company = companyLocalService.getCompany(companyId);
Group companyGroup = company.getGroup(); Group companyGroup = company.getGroup();
User defaultUser = company.getDefaultUser(); User defaultUser = company.getDefaultUser();
Folder folder = dlAppLocalService.getFolder(companyGroup.getGroupId(), Folder folder = dlAppLocalService.getFolder(companyGroup.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, EmailConstants.DEFAULT_ATTACHMENTS_FOLDER_NAME); DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, EmailConstants.DEFAULT_ATTACHMENTS_FOLDER_NAME);
ServiceContext serviceContext = new ServiceContext(); ServiceContext serviceContext = new ServiceContext();
serviceContext.setGroupPermissions(new String[] { ActionKeys.VIEW }); serviceContext.setGroupPermissions(new String[] { ActionKeys.VIEW });
serviceContext.setGuestPermissions(new String[] { ActionKeys.VIEW }); serviceContext.setGuestPermissions(new String[] { ActionKeys.VIEW });
return dlAppLocalService.addFolder(defaultUser.getUserId(), folder.getRepositoryId(), folder.getFolderId(),
return dlAppLocalService.addFolder(defaultUser.getUserId(), folder.getRepositoryId(), String.valueOf(emailId), StringPool.BLANK, serviceContext);
folder.getFolderId(), String.valueOf(emailId), StringPool.BLANK, serviceContext);
} }
private void validate(String from, String to[], String cc[], String bcc[], String[] bulkAddresses, private void validate(String from, String to[], String cc[], String bcc[], String[] bulkAddresses, String subject,
String subject, String body, String[] replyTo) throws PortalException { String body, String[] replyTo) throws PortalException {
if (Validator.isNull(from)) { if (Validator.isNull(from)) {
throw new RequiredEmailFromException(); throw new RequiredEmailFromException();
} else if (!Validator.isEmailAddress(from)) { } else if (!Validator.isEmailAddress(from)) {
throw new EmailFromException(); throw new EmailFromException();
} }
if (to == null || (to != null && to.length == 0)) { if (to == null || (to != null && to.length == 0)) {
throw new RequiredEmailToException(); throw new RequiredEmailToException();
} else { } else {
@ -384,7 +374,6 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
} }
} }
} }
if (cc != null && cc.length > 0) { if (cc != null && cc.length > 0) {
for (String emailAddress : cc) { for (String emailAddress : cc) {
if (!Validator.isEmailAddress(emailAddress)) { if (!Validator.isEmailAddress(emailAddress)) {
@ -392,7 +381,6 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
} }
} }
} }
if (bcc != null && bcc.length > 0) { if (bcc != null && bcc.length > 0) {
for (String emailAddress : bcc) { for (String emailAddress : bcc) {
if (!Validator.isEmailAddress(emailAddress)) { if (!Validator.isEmailAddress(emailAddress)) {
@ -400,7 +388,6 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
} }
} }
} }
if (bulkAddresses != null && bulkAddresses.length > 0) { if (bulkAddresses != null && bulkAddresses.length > 0) {
for (String emailAddress : bulkAddresses) { for (String emailAddress : bulkAddresses) {
if (!Validator.isEmailAddress(emailAddress)) { if (!Validator.isEmailAddress(emailAddress)) {
@ -408,15 +395,12 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
} }
} }
} }
if (Validator.isNull(subject)) { if (Validator.isNull(subject)) {
throw new RequiredEmailSubjectException(); throw new RequiredEmailSubjectException();
} }
if (Validator.isNull(body)) { if (Validator.isNull(body)) {
throw new RequiredEmailBodyException(); throw new RequiredEmailBodyException();
} }
if (replyTo != null && replyTo.length == 0) { if (replyTo != null && replyTo.length == 0) {
for (String emailAddress : replyTo) { for (String emailAddress : replyTo) {
if (!Validator.isEmailAddress(emailAddress)) { 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. * 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 * The contents of this file are subject to the terms of the Liferay Enterprise Subscription License ("License"). You
* ("License"). You may not use this file except in compliance with the License. You can obtain a * may not use this file except in compliance with the License. You can obtain a copy of the License by contacting
* copy of the License by contacting Liferay, Inc. See the License for the specific language * Liferay, Inc. See the License for the specific language governing permissions and limitations under the License,
* governing permissions and limitations under the License, including but not limited to * including but not limited to distribution rights of the Software.
* distribution rights of the Software.
* *
* *
* *
@ -13,26 +12,25 @@
package it.tref.liferay.portos.mailmanager.service.impl; 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.model.Email;
import it.tref.liferay.portos.mailmanager.permission.ActionKeys; import it.tref.liferay.portos.mailmanager.permission.ActionKeys;
import it.tref.liferay.portos.mailmanager.permission.EmailPermission; import it.tref.liferay.portos.mailmanager.permission.EmailPermission;
import it.tref.liferay.portos.mailmanager.service.base.EmailServiceBaseImpl; 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. * The implementation of the email remote service.
* *
* <p> * <p>
* All custom service methods should be put in this class. Whenever methods are added, rerun * All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy
* ServiceBuilder to copy their definitions into the * their definitions into the {@link it.tref.liferay.portos.mailmanager.service.EmailService} interface.
* {@link it.tref.liferay.portos.mailmanager.service.EmailService} interface.
* *
* <p> * <p>
* This is a remote service. Methods of this service are expected to have security checks based on * This is a remote service. Methods of this service are expected to have security checks based on the propagated JAAS
* the propagated JAAS credentials because this service can be accessed remotely. * credentials because this service can be accessed remotely.
* </p> * </p>
* *
* @author * @author
@ -41,25 +39,28 @@ import it.tref.liferay.portos.mailmanager.service.base.EmailServiceBaseImpl;
*/ */
public class EmailServiceImpl extends EmailServiceBaseImpl { public class EmailServiceImpl extends EmailServiceBaseImpl {
/* /*
* NOTE FOR DEVELOPERS: * NOTE FOR DEVELOPERS: Never reference this interface directly. Always use {@link
* * it.tref.liferay.portos.mailmanager.service.EmailServiceUtil} to access the email remote service.
* 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, public Email updateEmail(long emailId, String from, String to[], String cc[], String bcc[], String subject,
String body, ServiceContext serviceContext) throws Exception { String body, ServiceContext serviceContext) throws Exception {
EmailPermission.check(getPermissionChecker(), serviceContext.getScopeGroupId(), ActionKeys.ADMIN_EMAIL); EmailPermission.check(getPermissionChecker(), serviceContext.getScopeGroupId(), ActionKeys.ADMIN_EMAIL);
return emailLocalService.updateEmail(emailId, from, to, cc, bcc, subject, body, serviceContext); return emailLocalService.updateEmail(emailId, from, to, cc, bcc, subject, body, serviceContext);
} }
@Override
public Email resendEmail(long emailId, ServiceContext serviceContext) throws PortalException, SystemException { public Email resendEmail(long emailId, ServiceContext serviceContext) throws PortalException, SystemException {
EmailPermission.check(getPermissionChecker(), serviceContext.getScopeGroupId(), ActionKeys.ADMIN_EMAIL); EmailPermission.check(getPermissionChecker(), serviceContext.getScopeGroupId(), ActionKeys.ADMIN_EMAIL);
return emailLocalService.resendEmail(emailId); return emailLocalService.resendEmail(emailId);
} }
@Override
public Email cancelEmail(long emailId, ServiceContext serviceContext) throws PortalException, SystemException { public Email cancelEmail(long emailId, ServiceContext serviceContext) throws PortalException, SystemException {
EmailPermission.check(getPermissionChecker(), serviceContext.getScopeGroupId(), ActionKeys.ADMIN_EMAIL); EmailPermission.check(getPermissionChecker(), serviceContext.getScopeGroupId(), ActionKeys.ADMIN_EMAIL);
return emailLocalService.cancelEmail(emailId); 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. * 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 * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
* GNU Lesser General Public License as published by the Free Software Foundation; either version * Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option)
* 2.1 of the License, or (at your option) any later version. * any later version.
* *
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* Lesser General Public License for more details. * details.
*/ */
package it.tref.liferay.portos.mailmanager.service.impl; 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.EmailTemplateCcException;
import it.tref.liferay.portos.mailmanager.EmailTemplateCcnException; import it.tref.liferay.portos.mailmanager.EmailTemplateCcnException;
import it.tref.liferay.portos.mailmanager.EmailTemplateFromException; 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.Date;
import java.util.List; 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. * The implementation of the email template local service.
* *
* <p> * <p>
* All custom service methods should be put in this class. Whenever methods are added, rerun * All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy
* ServiceBuilder to copy their definitions into the * their definitions into the {@link it.noovle.azimut.icf.mailmanager.service.EmailTemplateLocalService} interface.
* {@link it.noovle.azimut.icf.mailmanager.service.EmailTemplateLocalService} interface.
* *
* <p> * <p>
* This is a local service. Methods of this service will not have security checks based on the * This is a local service. Methods of this service will not have security checks based on the propagated JAAS
* propagated JAAS credentials because this service can only be accessed from within the same VM. * credentials because this service can only be accessed from within the same VM.
* </p> * </p>
* *
* @author * @author
@ -56,82 +55,65 @@ import java.util.List;
*/ */
public class EmailTemplateLocalServiceImpl extends EmailTemplateLocalServiceBaseImpl { public class EmailTemplateLocalServiceImpl extends EmailTemplateLocalServiceBaseImpl {
/* /*
* NOTE FOR DEVELOPERS: * NOTE FOR DEVELOPERS: Never reference this interface directly. Always use {@link
* * it.noovle.azimut.icf.mailmanager.service.EmailTemplateLocalServiceUtil} to access the email template local
* Never reference this interface directly. Always use {@link * service.
* it.noovle.azimut.icf.mailmanager.service.EmailTemplateLocalServiceUtil} to access the email
* template local service.
*/ */
@Override @Override
public EmailTemplate addEmailTemplate(String templateName, String from, String[] to, String[] cc, String[] ccn, public EmailTemplate addEmailTemplate(String templateName, String from, String[] to, String[] cc, String[] ccn,
String subject, String body, boolean attachmentPermitted, ServiceContext serviceContext) throws SystemException, String subject, String body, boolean attachmentPermitted, ServiceContext serviceContext)
PortalException { throws SystemException, PortalException {
User user = userLocalService.getUser(serviceContext.getUserId()); User user = userLocalService.getUser(serviceContext.getUserId());
Date now = new Date(); Date now = new Date();
validate(templateName, from, to, cc, ccn, subject, body); validate(templateName, from, to, cc, ccn, subject, body);
EmailTemplate emailTemplate = emailTemplateLocalService.createEmailTemplate(counterLocalService
EmailTemplate emailTemplate = .increment(EmailTemplate.class.getName()));
emailTemplateLocalService.createEmailTemplate(counterLocalService.increment(EmailTemplate.class.getName()));
emailTemplate.setCompanyId(serviceContext.getCompanyId()); emailTemplate.setCompanyId(serviceContext.getCompanyId());
emailTemplate.setUserId(user.getUserId()); emailTemplate.setUserId(user.getUserId());
emailTemplate.setUserName(user.getFullName()); emailTemplate.setUserName(user.getFullName());
emailTemplate.setCreateDate(serviceContext.getCreateDate(now)); emailTemplate.setCreateDate(serviceContext.getCreateDate(now));
emailTemplate.setModifiedDate(serviceContext.getModifiedDate(now)); emailTemplate.setModifiedDate(serviceContext.getModifiedDate(now));
emailTemplate.setGroupId(serviceContext.getScopeGroupId()); emailTemplate.setGroupId(serviceContext.getScopeGroupId());
emailTemplate.setTemplateName(templateName); emailTemplate.setTemplateName(templateName);
emailTemplate.setFrom(from); emailTemplate.setFrom(from);
emailTemplate.setTo(StringUtil.merge(to, StringPool.COMMA)); emailTemplate.setTo(StringUtil.merge(to, StringPool.COMMA));
emailTemplate.setCc(StringUtil.merge(cc, StringPool.COMMA)); emailTemplate.setCc(StringUtil.merge(cc, StringPool.COMMA));
emailTemplate.setCcn(StringUtil.merge(ccn, StringPool.COMMA)); emailTemplate.setCcn(StringUtil.merge(ccn, StringPool.COMMA));
emailTemplate.setSubject(subject); emailTemplate.setSubject(subject);
emailTemplate.setBody(body); emailTemplate.setBody(body);
emailTemplate.setAttachmentPermitted(attachmentPermitted); emailTemplate.setAttachmentPermitted(attachmentPermitted);
emailTemplate = emailTemplateLocalService.addEmailTemplate(emailTemplate); emailTemplate = emailTemplateLocalService.addEmailTemplate(emailTemplate);
// Resource // Resource
resourceLocalService.addResources(emailTemplate.getCompanyId(), emailTemplate.getGroupId(), 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; return emailTemplate;
} }
@Override @Override
public EmailTemplate updateEmailTemplate(long emailTemplateId, String templateName, String from, String[] to, public EmailTemplate updateEmailTemplate(long emailTemplateId, String templateName, String from, String[] to,
String[] cc, String[] ccn, String subject, String body, boolean attachmentPermitted, ServiceContext serviceContext) String[] cc, String[] ccn, String subject, String body, boolean attachmentPermitted,
throws SystemException, PortalException { ServiceContext serviceContext) throws SystemException, PortalException {
EmailTemplate emailTemplate = emailTemplateLocalService.getEmailTemplate(emailTemplateId); EmailTemplate emailTemplate = emailTemplateLocalService.getEmailTemplate(emailTemplateId);
validate(templateName, from, to, cc, ccn, subject, body); validate(templateName, from, to, cc, ccn, subject, body);
emailTemplate.setModifiedDate(serviceContext.getModifiedDate(new Date())); emailTemplate.setModifiedDate(serviceContext.getModifiedDate(new Date()));
emailTemplate.setFrom(from); emailTemplate.setFrom(from);
emailTemplate.setTo(StringUtil.merge(to, StringPool.COMMA)); emailTemplate.setTo(StringUtil.merge(to, StringPool.COMMA));
emailTemplate.setCc(StringUtil.merge(cc, StringPool.COMMA)); emailTemplate.setCc(StringUtil.merge(cc, StringPool.COMMA));
emailTemplate.setCcn(StringUtil.merge(ccn, StringPool.COMMA)); emailTemplate.setCcn(StringUtil.merge(ccn, StringPool.COMMA));
emailTemplate.setSubject(subject); emailTemplate.setSubject(subject);
emailTemplate.setBody(body); emailTemplate.setBody(body);
emailTemplate.setAttachmentPermitted(attachmentPermitted); emailTemplate.setAttachmentPermitted(attachmentPermitted);
emailTemplate = emailTemplateLocalService.updateEmailTemplate(emailTemplate); emailTemplate = emailTemplateLocalService.updateEmailTemplate(emailTemplate);
return emailTemplate; return emailTemplate;
} }
@Override @Override
public EmailTemplate deleteEmailTemplate(long emailTemplateId) throws PortalException, SystemException { public EmailTemplate deleteEmailTemplate(long emailTemplateId) throws PortalException, SystemException {
EmailTemplate emailTemplate = emailTemplateLocalService.getEmailTemplate(emailTemplateId); EmailTemplate emailTemplate = emailTemplateLocalService.getEmailTemplate(emailTemplateId);
return deleteEmailTemplate(emailTemplate); return deleteEmailTemplate(emailTemplate);
} }
@ -140,59 +122,65 @@ public class EmailTemplateLocalServiceImpl extends EmailTemplateLocalServiceBase
public EmailTemplate deleteEmailTemplate(EmailTemplate emailTemplate) throws SystemException { public EmailTemplate deleteEmailTemplate(EmailTemplate emailTemplate) throws SystemException {
super.deleteEmailTemplate(emailTemplate); super.deleteEmailTemplate(emailTemplate);
// Resource // Resource
try { try {
resourceLocalService.deleteResource(emailTemplate.getCompanyId(), EmailTemplate.class.getName(), resourceLocalService.deleteResource(emailTemplate.getCompanyId(), EmailTemplate.class.getName(),
ResourceConstants.SCOPE_INDIVIDUAL, emailTemplate.getPrimaryKey()); ResourceConstants.SCOPE_INDIVIDUAL, emailTemplate.getPrimaryKey());
} catch (PortalException e) { } catch (PortalException e) {
} }
return emailTemplate; return emailTemplate;
} }
@Override @Override
public int countByC_GroupId(long companyId, long groupId) throws SystemException { public int countByC_GroupId(long companyId, long groupId) throws SystemException {
return emailTemplatePersistence.countByC_GroupId(companyId, groupId); return emailTemplatePersistence.countByC_GroupId(companyId, groupId);
} }
@Override @Override
public List<EmailTemplate> findByC_GroupId(long companyId, long groupId, int start, int end, OrderByComparator orderBy) public List<EmailTemplate> findByC_GroupId(long companyId, long groupId, int start, int end,
throws SystemException { OrderByComparator orderBy) throws SystemException {
return emailTemplatePersistence.findByC_GroupId(companyId, groupId, start, end, orderBy); return emailTemplatePersistence.findByC_GroupId(companyId, groupId, start, end, orderBy);
} }
@Override @Override
public EmailTemplate findByC_GroupId_Name(long companyId, long groupId, String templateName) public EmailTemplate findByC_GroupId_Name(long companyId, long groupId, String templateName)
throws NoSuchEmailTemplateException, SystemException { throws NoSuchEmailTemplateException, SystemException {
return emailTemplatePersistence.findByC_GroupId_Name(companyId, groupId, templateName); return emailTemplatePersistence.findByC_GroupId_Name(companyId, groupId, templateName);
} }
@Override @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); return emailTemplatePersistence.fetchByC_GroupId_Name(companyId, groupId, templateName);
} }
@Override @Override
public int countByCompany(long companyId) throws SystemException { public int countByCompany(long companyId) throws SystemException {
return emailTemplatePersistence.countByCompany(companyId); return emailTemplatePersistence.countByCompany(companyId);
} }
@Override @Override
public List<EmailTemplate> findByCompany(long companyId, int start, int end, OrderByComparator orderBy) public List<EmailTemplate> findByCompany(long companyId, int start, int end, OrderByComparator orderBy)
throws SystemException { throws SystemException {
return emailTemplatePersistence.findByCompany(companyId, start, end, orderBy); return emailTemplatePersistence.findByCompany(companyId, start, end, orderBy);
} }
@Override @Override
public int countByC_Name(long companyId, String name) throws SystemException { public int countByC_Name(long companyId, String name) throws SystemException {
return emailTemplatePersistence.countByC_Name(companyId, name); return emailTemplatePersistence.countByC_Name(companyId, name);
} }
@Override @Override
public EmailTemplate findByC_Name(long companyId, String templateName) throws SystemException, public EmailTemplate findByC_Name(long companyId, String templateName) throws SystemException,
NoSuchEmailTemplateException { NoSuchEmailTemplateException {
return emailTemplatePersistence.findByC_Name(companyId, templateName); return emailTemplatePersistence.findByC_Name(companyId, templateName);
} }
@ -202,13 +190,11 @@ public class EmailTemplateLocalServiceImpl extends EmailTemplateLocalServiceBase
if (Validator.isNull(templateName)) { if (Validator.isNull(templateName)) {
throw new RequiredEmailTemplateNameException(); throw new RequiredEmailTemplateNameException();
} }
if (Validator.isNull(from)) { if (Validator.isNull(from)) {
throw new RequiredEmailTemplateFromException(); throw new RequiredEmailTemplateFromException();
} else if (!Validator.isEmailAddress(from)) { } else if (!Validator.isEmailAddress(from)) {
throw new EmailTemplateFromException(); throw new EmailTemplateFromException();
} }
if (to != null && to.length > 0) { if (to != null && to.length > 0) {
for (String emailAddress : to) { for (String emailAddress : to) {
if (!Validator.isEmailAddress(emailAddress)) { if (!Validator.isEmailAddress(emailAddress)) {
@ -216,7 +202,6 @@ public class EmailTemplateLocalServiceImpl extends EmailTemplateLocalServiceBase
} }
} }
} }
if (cc != null && cc.length > 0) { if (cc != null && cc.length > 0) {
for (String emailAddress : cc) { for (String emailAddress : cc) {
if (!Validator.isEmailAddress(emailAddress)) { if (!Validator.isEmailAddress(emailAddress)) {
@ -224,7 +209,6 @@ public class EmailTemplateLocalServiceImpl extends EmailTemplateLocalServiceBase
} }
} }
} }
if (ccn != null && ccn.length > 0) { if (ccn != null && ccn.length > 0) {
for (String emailAddress : ccn) { for (String emailAddress : ccn) {
if (!Validator.isEmailAddress(emailAddress)) { if (!Validator.isEmailAddress(emailAddress)) {
@ -232,14 +216,11 @@ public class EmailTemplateLocalServiceImpl extends EmailTemplateLocalServiceBase
} }
} }
} }
if (Validator.isNull(subject)) { if (Validator.isNull(subject)) {
throw new RequiredEmailTemplateSubjectException(); throw new RequiredEmailTemplateSubjectException();
} }
if (Validator.isNull(body)) { if (Validator.isNull(body)) {
throw new RequiredEmailTemplateBodyException(); 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. * 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 * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
* GNU Lesser General Public License as published by the Free Software Foundation; either version * Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option)
* 2.1 of the License, or (at your option) any later version. * any later version.
* *
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* Lesser General Public License for more details. * details.
*/ */
package it.tref.liferay.portos.mailmanager.service.impl; 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.model.EmailTemplate;
import it.tref.liferay.portos.mailmanager.permission.EmailTemplateEntryPermission; import it.tref.liferay.portos.mailmanager.permission.EmailTemplateEntryPermission;
import it.tref.liferay.portos.mailmanager.permission.EmailTemplatePermission; import it.tref.liferay.portos.mailmanager.permission.EmailTemplatePermission;
import it.tref.liferay.portos.mailmanager.service.base.EmailTemplateServiceBaseImpl; 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. * The implementation of the email template remote service.
* *
* <p> * <p>
* All custom service methods should be put in this class. Whenever methods are * All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy
* added, rerun ServiceBuilder to copy their definitions into the * their definitions into the {@link it.noovle.azimut.icf.mailmanager.service.EmailTemplateService} interface.
* {@link it.noovle.azimut.icf.mailmanager.service.EmailTemplateService}
* interface.
* *
* <p> * <p>
* This is a remote service. Methods of this service are expected to have * This is a remote service. Methods of this service are expected to have security checks based on the propagated JAAS
* security checks based on the propagated JAAS credentials because this service * credentials because this service can be accessed remotely.
* can be accessed remotely.
* </p> * </p>
* *
* @author * @author
@ -43,39 +40,34 @@ import it.tref.liferay.portos.mailmanager.service.base.EmailTemplateServiceBaseI
*/ */
public class EmailTemplateServiceImpl extends EmailTemplateServiceBaseImpl { public class EmailTemplateServiceImpl extends EmailTemplateServiceBaseImpl {
/* /*
* NOTE FOR DEVELOPERS: * 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.
* 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, @Override
String[] ccn, String subject, String body, boolean attachmentPermitted, public EmailTemplate addEmailTemplate(String templateName, String from, String[] to, String[] cc, String[] ccn,
ServiceContext serviceContext) throws SystemException, PortalException { String subject, String body, boolean attachmentPermitted, ServiceContext serviceContext)
throws SystemException, PortalException {
EmailTemplatePermission.check(getPermissionChecker(), serviceContext.getScopeGroupId(),
ActionKeys.ADD_ENTRY);
EmailTemplatePermission.check(getPermissionChecker(), serviceContext.getScopeGroupId(), ActionKeys.ADD_ENTRY);
return emailTemplateLocalService.addEmailTemplate(templateName, from, to, cc, ccn, subject, body, return emailTemplateLocalService.addEmailTemplate(templateName, from, to, cc, ccn, subject, body,
attachmentPermitted, serviceContext); attachmentPermitted, serviceContext);
} }
public EmailTemplate updateEmailTemplate(long emailTemplateId, String templateName, String from, @Override
String[] to, String[] cc, String[] ccn, String subject, String body, boolean attachmentPermitted, 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 { ServiceContext serviceContext) throws SystemException, PortalException {
EmailTemplateEntryPermission.check(getPermissionChecker(), emailTemplateId, ActionKeys.UPDATE); EmailTemplateEntryPermission.check(getPermissionChecker(), emailTemplateId, ActionKeys.UPDATE);
return emailTemplateLocalService.updateEmailTemplate(emailTemplateId, templateName, from, to, cc, ccn, subject,
return emailTemplateLocalService.updateEmailTemplate(emailTemplateId, templateName, from, to, cc, body, attachmentPermitted, serviceContext);
ccn, subject, body, attachmentPermitted, serviceContext);
} }
@Override
public EmailTemplate deleteEmailTemplate(long emailTemplateId) throws PortalException, SystemException { public EmailTemplate deleteEmailTemplate(long emailTemplateId) throws PortalException, SystemException {
EmailTemplateEntryPermission.check(getPermissionChecker(), emailTemplateId, ActionKeys.DELETE); EmailTemplateEntryPermission.check(getPermissionChecker(), emailTemplateId, ActionKeys.DELETE);
return emailTemplateLocalService.deleteEmailTemplate(emailTemplateId); 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 { public static void send(byte[] bytes) throws MailEngineException {
try { try {
Session session = getSession(); Session session = getSession();
Message message = new MimeMessage(session, new UnsyncByteArrayInputStream(bytes)); 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) private static void _send(Session session, Message message, InternetAddress[] bulkAddresses, int batchSize)
throws MailEngineException { throws MailEngineException {
try { try {
boolean smtpAuth = GetterUtil.getBoolean(_getSMTPProperty(session, "auth"), false); boolean smtpAuth = GetterUtil.getBoolean(_getSMTPProperty(session, "auth"), false);
String smtpHost = _getSMTPProperty(session, "host"); 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); private static final Log _log = LogFactoryUtil.getLog(MailSenderUtil.class);
public static void sendMail(Email email) throws Exception { 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 from = toInternetAddress(email.getFrom());
InternetAddress[] to = toInternetAddresses(email.getToArray()); InternetAddress[] to = toInternetAddresses(email.getToArray());
InternetAddress[] cc = toInternetAddresses(email.getCcArray()); InternetAddress[] cc = toInternetAddresses(email.getCcArray());
@ -70,6 +71,7 @@ public class MailSenderUtil {
} }
private static InternetAddress toInternetAddress(String address) throws AddressException { private static InternetAddress toInternetAddress(String address) throws AddressException {
if (Validator.isNull(address)) { if (Validator.isNull(address)) {
return null; return null;
} }
@ -77,6 +79,7 @@ public class MailSenderUtil {
} }
private static InternetAddress[] toInternetAddresses(String[] addresses) throws AddressException { private static InternetAddress[] toInternetAddresses(String[] addresses) throws AddressException {
if (addresses == null || addresses.length == 0) { if (addresses == null || addresses.length == 0) {
return null; return null;
} }
@ -89,6 +92,7 @@ public class MailSenderUtil {
private static List<FileAttachment> toFileAttachments(List<EmailAttachment> emailAttachments) private static List<FileAttachment> toFileAttachments(List<EmailAttachment> emailAttachments)
throws PortalException, SystemException, IOException { throws PortalException, SystemException, IOException {
List<FileAttachment> fileAttachments = new ArrayList<>(emailAttachments.size()); List<FileAttachment> fileAttachments = new ArrayList<>(emailAttachments.size());
for (EmailAttachment emailAttachment : emailAttachments) { for (EmailAttachment emailAttachment : emailAttachments) {
InputStream inputStream = null; 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; 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 java.util.Iterator;
import org.apache.velocity.VelocityContext; import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine; import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.runtime.RuntimeConstants; 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 class VelocityUtil {
public static VelocityContext fromJSONObjectOneLevelDepth(JSONObject jsonObject) { public static VelocityContext fromJSONObjectOneLevelDepth(JSONObject jsonObject) {
VelocityContext velocityContext = new VelocityContext(); VelocityContext velocityContext = new VelocityContext();
while (jsonObject.keys().hasNext()) { while (jsonObject.keys().hasNext()) {
String key = jsonObject.keys().next(); String key = jsonObject.keys().next();
velocityContext.put(key, jsonObject.getString(key)); velocityContext.put(key, jsonObject.getString(key));
} }
return velocityContext; return velocityContext;
} }
public static String evaluate(String input) throws Exception { public static String evaluate(String input) throws Exception {
return evaluate(input, null); return evaluate(input, null);
} }
public static String evaluate(String input, JSONObject variables) throws Exception { public static String evaluate(String input, JSONObject variables) throws Exception {
VelocityEngine velocityEngine = new VelocityEngine(); VelocityEngine velocityEngine = new VelocityEngine();
velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
com.liferay.portal.kernel.util.PropsUtil.get(PropsKeys.VELOCITY_ENGINE_LOGGER)); com.liferay.portal.kernel.util.PropsUtil.get(PropsKeys.VELOCITY_ENGINE_LOGGER));
velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM + ".log4j.category", velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM + ".log4j.category",
com.liferay.portal.kernel.util.PropsUtil.get(PropsKeys.VELOCITY_ENGINE_LOGGER_CATEGORY)); com.liferay.portal.kernel.util.PropsUtil.get(PropsKeys.VELOCITY_ENGINE_LOGGER_CATEGORY));
velocityEngine.init(); velocityEngine.init();
VelocityContext velocityContext = new VelocityContext(); VelocityContext velocityContext = new VelocityContext();
if (variables != null) { if (variables != null) {
Iterator<String> iteratiorKeys = variables.keys(); Iterator<String> iteratiorKeys = variables.keys();
while (iteratiorKeys.hasNext()) { while (iteratiorKeys.hasNext()) {
String key = iteratiorKeys.next(); String key = iteratiorKeys.next();
if (Validator.isNotNull(key)) { if (Validator.isNotNull(key)) {
@ -58,12 +46,8 @@ public class VelocityUtil {
} }
} }
} }
UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter(); UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter();
velocityEngine.evaluate(velocityContext, unsyncStringWriter, VelocityUtil.class.getName(), input); velocityEngine.evaluate(velocityContext, unsyncStringWriter, VelocityUtil.class.getName(), input);
return unsyncStringWriter.toString(); 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"> <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> <dependency-type>uses</dependency-type>
</dependent-module> </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="context-root" value="portos-report-engine-portlet"/>
<property name="java-output-path" value="/portos-report-engine-portlet/docroot/WEB-INF/classes"/> <property name="java-output-path" value="/portos-report-engine-portlet/docroot/WEB-INF/classes"/>
</wb-module> </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; 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.MailTemplateMessage;
import it.tref.liferay.portos.mailmanager.shared.messaging.dto.TemplateMessage; import it.tref.liferay.portos.mailmanager.shared.messaging.dto.TemplateMessage;
import it.tref.liferay.portos.mailmanager.shared.model.FileAttachment; 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.AddressException;
import javax.mail.internet.InternetAddress; 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, public static boolean sendMail(String messageId, String inReplyTo, String from, String[] to, String[] cc,
String[] bcc, String subject, String body, boolean htmlFormat, boolean async, String[] bcc, String subject, String body, boolean htmlFormat, boolean async,
boolean checkPermission, ServiceContext serviceContext) throws AddressException, SystemException { boolean checkPermission, ServiceContext serviceContext) throws AddressException, SystemException {
InternetAddress fromInternetAddress = new InternetAddress(from, true); InternetAddress fromInternetAddress = new InternetAddress(from, true);
InternetAddress[] toInternetAddress = MailUtil.fromStringAddress(to); InternetAddress[] toInternetAddress = MailUtil.fromStringAddress(to);
InternetAddress[] ccInternetAddress = MailUtil.fromStringAddress(cc); InternetAddress[] ccInternetAddress = MailUtil.fromStringAddress(cc);
InternetAddress[] bccInternetAddress = MailUtil.fromStringAddress(bcc); InternetAddress[] bccInternetAddress = MailUtil.fromStringAddress(bcc);
MailMessage mailMessage = new MailMessage(fromInternetAddress, subject, body, htmlFormat); MailMessage mailMessage = new MailMessage(fromInternetAddress, subject, body, htmlFormat);
mailMessage.setTo(toInternetAddress); mailMessage.setTo(toInternetAddress);
mailMessage.setCC(ccInternetAddress); mailMessage.setCC(ccInternetAddress);
mailMessage.setBCC(bccInternetAddress); mailMessage.setBCC(bccInternetAddress);
Message message = new Message(); Message message = new Message();
message.put("serviceContext", serviceContext); message.put("serviceContext", serviceContext);
message.setPayload(JSONFactoryUtil.looseSerializeDeep(mailMessage)); message.setPayload(JSONFactoryUtil.looseSerializeDeep(mailMessage));
try { try {
if (async) { if (async) {
message.put("mode", MailManagerConstants.MESSAGING_SEND_MODE_ASYNC); message.put("mode", MailManagerConstants.MESSAGING_SEND_MODE_ASYNC);
MessageBusUtil.sendMessage(DestinationNames.SEND_MAIL, message); MessageBusUtil.sendMessage(DestinationNames.SEND_MAIL, message);
@ -63,15 +52,14 @@ public class MailManagerUtil {
return GetterUtil.getBoolean(MessageBusUtil.sendSynchronousMessage( return GetterUtil.getBoolean(MessageBusUtil.sendSynchronousMessage(
DestinationNames.SEND_MAIL_SYNC, message, TimeUnit.SECONDS.toMillis(30))); DestinationNames.SEND_MAIL_SYNC, message, TimeUnit.SECONDS.toMillis(30)));
} }
} catch (MessageBusException e) { } catch (MessageBusException e) {
throw new SystemException(e); throw new SystemException(e);
} }
} }
public static boolean sendMailByTemplateId(String className, long classPK, long templateId, public static boolean sendMailByTemplateId(String className, long classPK, long templateId,
JSONObject templateVariables, ServiceContext serviceContext) throws SystemException { JSONObject templateVariables, ServiceContext serviceContext) throws SystemException {
return sendMailByTemplate(className, classPK, templateId, StringPool.BLANK, null, null, null, return sendMailByTemplate(className, classPK, templateId, StringPool.BLANK, null, null, null,
templateVariables, Collections.<FileAttachment> emptyList(), true, true, serviceContext); templateVariables, Collections.<FileAttachment> emptyList(), true, true, serviceContext);
} }
@ -79,6 +67,7 @@ public class MailManagerUtil {
public static boolean sendMailByTemplateId(String className, long classPK, long templateId, public static boolean sendMailByTemplateId(String className, long classPK, long templateId,
JSONObject templateVariables, List<FileAttachment> fileAttachments, ServiceContext serviceContext) JSONObject templateVariables, List<FileAttachment> fileAttachments, ServiceContext serviceContext)
throws SystemException { throws SystemException {
return sendMailByTemplate(className, classPK, templateId, StringPool.BLANK, null, null, null, return sendMailByTemplate(className, classPK, templateId, StringPool.BLANK, null, null, null,
templateVariables, fileAttachments, true, true, serviceContext); templateVariables, fileAttachments, true, true, serviceContext);
} }
@ -86,27 +75,31 @@ public class MailManagerUtil {
public static boolean sendMailByTemplateId(String className, long classPK, long templateId, String[] to, public static boolean sendMailByTemplateId(String className, long classPK, long templateId, String[] to,
String[] cc, String[] ccn, JSONObject templateVariables, List<FileAttachment> fileAttachments, String[] cc, String[] ccn, JSONObject templateVariables, List<FileAttachment> fileAttachments,
ServiceContext serviceContext) throws SystemException { ServiceContext serviceContext) throws SystemException {
return sendMailByTemplate(className, classPK, templateId, StringPool.BLANK, to, cc, ccn, return sendMailByTemplate(className, classPK, templateId, StringPool.BLANK, to, cc, ccn,
templateVariables, fileAttachments, true, true, serviceContext); templateVariables, fileAttachments, true, true, serviceContext);
} }
public static boolean sendMailByTemplateName(String className, long classPK, String templateName, public static boolean sendMailByTemplateName(String className, long classPK, String templateName,
JSONObject templateVariables, ServiceContext serviceContext) throws SystemException { 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); Collections.<FileAttachment> emptyList(), true, true, serviceContext);
} }
public static boolean sendMailByTemplateName(String className, long classPK, String templateName, public static boolean sendMailByTemplateName(String className, long classPK, String templateName,
JSONObject templateVariables, List<FileAttachment> fileAttachments, ServiceContext serviceContext) JSONObject templateVariables, List<FileAttachment> fileAttachments, ServiceContext serviceContext)
throws SystemException { 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); fileAttachments, true, true, serviceContext);
} }
public static boolean sendMailByTemplatName(String className, long classPK, String templateName, public static boolean sendMailByTemplatName(String className, long classPK, String templateName,
String[] to, String[] cc, String[] ccn, JSONObject templateVariables, String[] to, String[] cc, String[] ccn, JSONObject templateVariables,
List<FileAttachment> fileAttachments, ServiceContext serviceContext) throws SystemException { 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); fileAttachments, true, true, serviceContext);
} }
@ -117,7 +110,6 @@ public class MailManagerUtil {
JSONObject templateParam = JSONFactoryUtil.createJSONObject(); JSONObject templateParam = JSONFactoryUtil.createJSONObject();
templateParam.put(MailManagerConstants.TEMPLATE_PARAMETER_VARIABLES_KEY, templateVariables); templateParam.put(MailManagerConstants.TEMPLATE_PARAMETER_VARIABLES_KEY, templateVariables);
if (to != null && to.length > 0) { if (to != null && to.length > 0) {
templateParam.put(MailManagerConstants.TEMPLATE_PARAMETER_TO_KEY, templateParam.put(MailManagerConstants.TEMPLATE_PARAMETER_TO_KEY,
StringUtil.merge(to, StringPool.COMMA)); StringUtil.merge(to, StringPool.COMMA));
@ -130,21 +122,17 @@ public class MailManagerUtil {
templateParam.put(MailManagerConstants.TEMPLATE_PARAMETER_CCN_KEY, templateParam.put(MailManagerConstants.TEMPLATE_PARAMETER_CCN_KEY,
StringUtil.merge(ccn, StringPool.COMMA)); StringUtil.merge(ccn, StringPool.COMMA));
} }
MailTemplateMessage mailTemplateMessage = new MailTemplateMessage(); MailTemplateMessage mailTemplateMessage = new MailTemplateMessage();
mailTemplateMessage.setTemplateId(templateId); mailTemplateMessage.setTemplateId(templateId);
mailTemplateMessage.setTemplateName(templateName); mailTemplateMessage.setTemplateName(templateName);
mailTemplateMessage.setTemplateParam(templateParam.toString()); mailTemplateMessage.setTemplateParam(templateParam.toString());
mailTemplateMessage.setFileAttachments(fileAttachments); mailTemplateMessage.setFileAttachments(fileAttachments);
Message message = new Message(); Message message = new Message();
message.put("serviceContext", serviceContext); message.put("serviceContext", serviceContext);
message.put("className", className); message.put("className", className);
message.put("classPK", classPK); message.put("classPK", classPK);
message.setPayload(JSONFactoryUtil.looseSerializeDeep(mailTemplateMessage)); message.setPayload(JSONFactoryUtil.looseSerializeDeep(mailTemplateMessage));
try { try {
if (async) { if (async) {
message.put("mode", MailManagerConstants.MESSAGING_SEND_MODE_ASYNC); message.put("mode", MailManagerConstants.MESSAGING_SEND_MODE_ASYNC);
MessageBusUtil.sendMessage(DestinationNames.SEND_TEMPLATE_MAIL, message); MessageBusUtil.sendMessage(DestinationNames.SEND_TEMPLATE_MAIL, message);
@ -154,7 +142,6 @@ public class MailManagerUtil {
return GetterUtil.getBoolean(MessageBusUtil.sendSynchronousMessage( return GetterUtil.getBoolean(MessageBusUtil.sendSynchronousMessage(
DestinationNames.SEND_TEMPLATE_MAIL_SYNC, message, TimeUnit.SECONDS.toMillis(30))); DestinationNames.SEND_TEMPLATE_MAIL_SYNC, message, TimeUnit.SECONDS.toMillis(30)));
} }
} catch (MessageBusException e) { } catch (MessageBusException e) {
throw new SystemException(e); throw new SystemException(e);
} }
@ -163,7 +150,8 @@ public class MailManagerUtil {
public static boolean addMailTemplate(String templateName, String from, String[] to, String[] cc, public static boolean addMailTemplate(String templateName, String from, String[] to, String[] cc,
String[] ccn, String subject, String body, boolean attachmentPermitted, String[] ccn, String subject, String body, boolean attachmentPermitted,
ServiceContext serviceContext) throws SystemException { 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); serviceContext);
} }
@ -181,11 +169,9 @@ public class MailManagerUtil {
templateMessage.setCcn(ccn); templateMessage.setCcn(ccn);
templateMessage.setSubject(subject); templateMessage.setSubject(subject);
templateMessage.setBody(body); templateMessage.setBody(body);
Message message = new Message(); Message message = new Message();
message.put("serviceContext", serviceContext); message.put("serviceContext", serviceContext);
message.setPayload(JSONFactoryUtil.looseSerializeDeep(templateMessage)); message.setPayload(JSONFactoryUtil.looseSerializeDeep(templateMessage));
try { try {
return GetterUtil.getBoolean(MessageBusUtil.sendSynchronousMessage( return GetterUtil.getBoolean(MessageBusUtil.sendSynchronousMessage(
DestinationNames.EDIT_EMAIL_TEMPLATE, message, TimeUnit.SECONDS.toMillis(30))); DestinationNames.EDIT_EMAIL_TEMPLATE, message, TimeUnit.SECONDS.toMillis(30)));
@ -193,5 +179,4 @@ public class MailManagerUtil {
throw new SystemException(e); 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; 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.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.repository.model.FileEntry; 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.DLAppLocalServiceUtil;
import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil; 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 class FileAttachment extends com.liferay.mail.model.FileAttachment {
public static final Log _log = LogFactoryUtil.getLog(FileAttachment.class); 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; private String fileName;
public FileAttachment() { public FileAttachment() {
super(); super();
} }
public FileAttachment(File file, String fileName, String tipologia, long fileEntryId, byte[] bytes) { public FileAttachment(File file, String fileName, String tipologia, long fileEntryId, byte[] bytes) {
super(file, fileName); super(file, fileName);
this.setTipologia(tipologia); this.setTipologia(tipologia);
this.fileEntryId = fileEntryId; this.fileEntryId = fileEntryId;
this.setBytes(bytes); this.setBytes(bytes);
} }
@Override
public String getFileName() { public String getFileName() {
return fileName; return fileName;
} }
@Override
public void setFileName(String fileName) { public void setFileName(String fileName) {
this.fileName = fileName; this.fileName = fileName;
super.setFileName(fileName); super.setFileName(fileName);
} }
public long getFileEntryId() { public long getFileEntryId() {
return fileEntryId; return fileEntryId;
} }
public void setFileEntryId(long fileEntryId) { public void setFileEntryId(long fileEntryId) {
this.fileEntryId = fileEntryId; this.fileEntryId = fileEntryId;
} }
public byte[] getBytes() { public byte[] getBytes() {
return bytes; return bytes;
} }
public void setBytes(byte[] bytes) { public void setBytes(byte[] bytes) {
this.bytes = bytes; this.bytes = bytes;
} }
public String getTipologia() { public String getTipologia() {
return tipologia; return tipologia;
} }
public void setTipologia(String tipologia) { public void setTipologia(String tipologia) {
this.tipologia = tipologia; this.tipologia = tipologia;
} }
public File generateFile() { public File generateFile() {
File result = null; File result = null;
try { try {
if (Validator.isNotNull(super.getFile())) { if (Validator.isNotNull(super.getFile())) {
result = super.getFile(); result = super.getFile();
} else if (Validator.isNotNull(fileEntryId)) { } else if (Validator.isNotNull(fileEntryId)) {
FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(fileEntryId); FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(fileEntryId);
setFileName(fileEntry.getTitle() setFileName(fileEntry.getTitle()
+ (Validator.isNotNull(fileEntry.getExtension()) ? "." + fileEntry.getExtension() + (Validator.isNotNull(fileEntry.getExtension()) ? StringPool.PERIOD + fileEntry.getExtension()
: StringPool.BLANK)); : StringPool.BLANK));
InputStream is = DLFileEntryLocalServiceUtil.getFileAsStream(fileEntry.getFileEntryId(), InputStream is = DLFileEntryLocalServiceUtil.getFileAsStream(fileEntry.getFileEntryId(),
fileEntry.getVersion(), false); fileEntry.getVersion(), false);
@ -87,12 +97,10 @@ public class FileAttachment extends com.liferay.mail.model.FileAttachment {
result = FileUtil.createTempFile(bytes); result = FileUtil.createTempFile(bytes);
result.deleteOnExit(); result.deleteOnExit();
} }
} catch (Exception e) { } catch (Exception e) {
_log.error("Error during getFile()", e); _log.error("Error during getFile()", e);
} }
setFile(result); setFile(result);
return result; return result;
} }
} }

Caricamento…
Annulla
Salva