diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/SismicaAdministrationPortlet.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/SismicaAdministrationPortlet.java index faf57c0a..58bcb744 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/SismicaAdministrationPortlet.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/SismicaAdministrationPortlet.java @@ -7,18 +7,27 @@ import it.tref.liferay.portos.bo.model.ControlloPratica; import it.tref.liferay.portos.bo.model.DettPratica; import it.tref.liferay.portos.bo.model.DocPratica; import it.tref.liferay.portos.bo.model.Pagamento; +import it.tref.liferay.portos.bo.model.Soggetto; import it.tref.liferay.portos.bo.service.ConfigurazioneLocalServiceUtil; import it.tref.liferay.portos.bo.service.ConfigurazioneServiceUtil; +import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.PagamentoLocalServiceUtil; +import it.tref.liferay.portos.bo.service.SoggettoLocalServiceUtil; +import it.tref.liferay.portos.bo.service.SoggettoServiceUtil; +import it.tref.liferay.portos.bo.shared.bean.FirmeBean; import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants; +import it.tref.liferay.portos.bo.shared.util.FirmeUtil; +import it.tref.liferay.portos.bo.shared.util.TipoSoggettoUtil; import it.tref.liferay.portos.bo.util.PraticaUtil; +import it.tref.liferay.portos.bo.util.ValidazionePraticaUtil; import java.io.File; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.Map; @@ -34,15 +43,19 @@ import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.repository.model.FileEntry; import com.liferay.portal.kernel.repository.model.Folder; +import com.liferay.portal.kernel.servlet.SessionErrors; import com.liferay.portal.kernel.upload.UploadPortletRequest; +import com.liferay.portal.kernel.util.HttpUtil; import com.liferay.portal.kernel.util.MimeTypesUtil; import com.liferay.portal.kernel.util.ParamUtil; import com.liferay.portal.kernel.util.FileUtil; import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.util.WebKeys; +import com.liferay.portal.model.User; import com.liferay.portal.service.ServiceContext; import com.liferay.portal.service.ServiceContextFactory; +import com.liferay.portal.service.UserLocalServiceUtil; import com.liferay.portal.theme.ThemeDisplay; import com.liferay.portal.util.PortalUtil; import com.liferay.portlet.documentlibrary.NoSuchFolderException; @@ -54,10 +67,11 @@ import com.liferay.util.bridges.mvc.MVCPortlet; */ 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) - throws SystemException { + public void mostraConfigurazione(ActionRequest actionRequest, + ActionResponse actionResponse) throws SystemException { List esito = new ArrayList(); esito.add("

Env

"); @@ -66,24 +80,29 @@ public class SismicaAdministrationPortlet extends MVCPortlet { } esito.add("

Properties

"); - for (Map.Entry entry : System.getProperties().entrySet()) { + for (Map.Entry entry : System.getProperties() + .entrySet()) { esito.add(entry.getKey() + "=" + 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) { - ThemeDisplay td = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); + public void generaDocumenti(ActionRequest actionRequest, + ActionResponse actionResponse) { + ThemeDisplay td = (ThemeDisplay) actionRequest + .getAttribute(WebKeys.THEME_DISPLAY); List esito = new ArrayList<>(); try { esito = SismicaUtil.generaDocumenti(td.getCompanyId()); } catch (PortalException | SystemException e) { 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()])); } - - public void sostituisciDL(ActionRequest actionRequest, ActionResponse actionResponse) throws SystemException, PortalException, IOException { + + public void sostituisciDL(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { SismicaUtil.sostituisciDL(actionRequest, actionResponse); long userId = 0; @@ -140,12 +159,6 @@ public class SismicaAdministrationPortlet extends MVCPortlet { description = sourceFileName; mimeType = MimeTypesUtil.getContentType(sourceFileName); - /*try { - DLAppLocalServiceUtil.deleteFileEntry(pratica.getDlFileEntryId()); - } catch(PortalException e){ - - }*/ - try { fileEntry = DLAppLocalServiceUtil.getFileEntry(pratica.getDlFileEntryId()); fileEntry = DLAppLocalServiceUtil.updateFileEntry(userId, fileEntry.getFileEntryId(), @@ -189,13 +202,7 @@ public class SismicaAdministrationPortlet extends MVCPortlet { + pagamento.getPagamentoId() + StringPool.UNDERLINE + sourceFileName; description = StringPool.BLANK; mimeType = MimeTypesUtil.getContentType(sourceFileName); - - /*try { - DLAppLocalServiceUtil.deleteFileEntry(pagamento.getFileEntryId()); - } catch(PortalException e){ - - }*/ - + try { fileEntry = DLAppLocalServiceUtil.getFileEntry(pagamento.getFileEntryId()); fileEntry = DLAppLocalServiceUtil.updateFileEntry(userId, fileEntry.getFileEntryId(), @@ -210,6 +217,99 @@ public class SismicaAdministrationPortlet extends MVCPortlet { PagamentoLocalServiceUtil.updatePagamento(pagamento); break; + case "var_soggetti_no_docpratica": + Soggetto soggetto = SoggettoLocalServiceUtil.getSoggetto(idOggetto); + DettPratica dettPratica = DettPraticaLocalServiceUtil.getDettPratica(soggetto.getDettPraticaId()); + long intPraticaId = dettPratica.getIntPraticaId(); + serviceContext = ServiceContextFactory.getInstance(Soggetto.class.getName(), actionRequest); + + byte[] content = null; + String jsonFirmatari = ""; + boolean isSigned = false; + FirmeBean firmeBean = new FirmeBean(); + + + User user = UserLocalServiceUtil.getUser(serviceContext.getUserId()); + + if (!firmeBean.allSignatures().contains(user.getScreenName())) { + jsonFirmatari = FirmeUtil.addFirma(firmeBean, user.getScreenName()); + } else { + jsonFirmatari = FirmeUtil.serialize(firmeBean); + } + + if (file.exists()) { + + if (Validator.isNotNull(sourceFileName) && file != null) { + // validazione: solo alcune estensioni + String ext = FileUtil.getExtension(sourceFileName); + if (!ext.equalsIgnoreCase("p7m") + && !ext.equalsIgnoreCase("pdf")) { + SessionErrors + .add(actionRequest, + "error.geniocivilefe.variazione-soggetto.allegato.ext.valid"); + } + // lunghezza fissata a 200 + if (sourceFileName.length() > 200) { + SessionErrors + .add(actionRequest, + "error.geniocivilefe.variazione-soggetto.allegato.length.valid"); + } + } else if (!TipoSoggettoUtil.COMMITTENTE + .equalsIgnoreCase(soggetto.getTipologiaSoggetto())) { + SessionErrors + .add(actionRequest, + "error.geniocivilefe.variazione-soggetto.allegato.is.request"); + } + + if (!SessionErrors.isEmpty(actionRequest)) { + throw new SystemException( + "error.geniocivilefe.variazione-soggetto.allegato"); + } else if (file != null) { + content = FileUtil.getBytes(file); + } + + } + + if (TipoSoggettoUtil.COMMITTENTE.equals(soggetto + .getTipologiaSoggetto())) { + String[] titolare = new String[] { dettPratica + .getCodiceFiscaleDelegatoCommittente() }; + isSigned = ValidazionePraticaUtil.isAllegatoSignedBySubjects( + sourceFileName, content, serviceContext.getCompanyId(), + Arrays.asList(titolare), jsonFirmatari); + } else { + List soggettiValidi = SoggettoServiceUtil + .getValidTmpByIntPratica(intPraticaId); + List codiciFiscaliValidi = new ArrayList(); + for (Soggetto valido : soggettiValidi) { + if (!codiciFiscaliValidi + .contains(valido.getCodiceFiscale()) + && !valido.getCodiceFiscale().equalsIgnoreCase( + soggetto.getCodiceFiscale())) { + codiciFiscaliValidi.add(valido.getCodiceFiscale()); + } + } + isSigned = ValidazionePraticaUtil + .isAllegatoSignedBySubjectsAndPerson(sourceFileName, + content, serviceContext.getCompanyId(), + codiciFiscaliValidi, + soggetto.getCodiceFiscale(), jsonFirmatari); + } + + if(isSigned){ + userId = PortalUtil.getUserId(actionRequest); + + try { + SoggettoServiceUtil.allegaFileModifica(soggetto.getSoggettoId(), userId, intPraticaId, content, sourceFileName, jsonFirmatari, + serviceContext); + } catch (PortalException e) { + _log.error(e, e); + throw e; + } + } + + break; + default: break; @@ -218,79 +318,103 @@ public class SismicaAdministrationPortlet extends MVCPortlet { } - public void resetFirme(ActionRequest actionRequest, ActionResponse actionResponse) { - ThemeDisplay td = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); - String numeroProgetto = ParamUtil.getString(actionRequest, "numeroProgetto"); + public void resetFirme(ActionRequest actionRequest, + ActionResponse actionResponse) { + ThemeDisplay td = (ThemeDisplay) actionRequest + .getAttribute(WebKeys.THEME_DISPLAY); + String numeroProgetto = ParamUtil.getString(actionRequest, + "numeroProgetto"); List esito = new ArrayList<>(); try { esito = SismicaUtil.resetFirme(td.getCompanyId(), numeroProgetto); } catch (SystemException | PortalException e) { 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()])); } - public void reIndexFasciolo(ActionRequest actionRequest, ActionResponse actionResponse) - throws PortalException, SystemException { + public void reIndexFasciolo(ActionRequest actionRequest, + ActionResponse actionResponse) throws PortalException, + SystemException { - ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); + ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest + .getAttribute(WebKeys.THEME_DISPLAY); long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId"); if (Validator.isNotNull(intPraticaId)) { - IntPraticaLocalServiceUtil.reIndexFasciolo(intPraticaId, themeDisplay.getCompanyId()); + IntPraticaLocalServiceUtil.reIndexFasciolo(intPraticaId, + themeDisplay.getCompanyId()); } - String numeroProgetto = ParamUtil.getString(actionRequest, "numeroProgetto"); + String numeroProgetto = ParamUtil.getString(actionRequest, + "numeroProgetto"); if (Validator.isNotNull(numeroProgetto)) { - IntPraticaLocalServiceUtil.reIndexFasciolo(numeroProgetto, themeDisplay.getCompanyId()); + IntPraticaLocalServiceUtil.reIndexFasciolo(numeroProgetto, + themeDisplay.getCompanyId()); } } - public void reIndexFascicoli(ActionRequest actionRequest, ActionResponse actionResponse) { - ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); + public void reIndexFascicoli(ActionRequest actionRequest, + ActionResponse actionResponse) { + ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest + .getAttribute(WebKeys.THEME_DISPLAY); List esito = null; esito = SismicaUtil.reIndexFascicoli(themeDisplay.getCompanyId()); if (esito != null) - actionResponse.setRenderParameter("esito", esito.toArray(new String[esito.size()])); + actionResponse.setRenderParameter("esito", + esito.toArray(new String[esito.size()])); } - public void lanciaSorteggio(ActionRequest actionRequest, ActionResponse actionResponse) { - ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); + public void lanciaSorteggio(ActionRequest actionRequest, + ActionResponse actionResponse) { + ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest + .getAttribute(WebKeys.THEME_DISPLAY); List esito = null; _log.info("Sorteggio lanciato manualmente"); try { - esito = SorteggioPraticaUtil.sorteggio(themeDisplay.getCompanyId(), new Date()); + esito = SorteggioPraticaUtil.sorteggio(themeDisplay.getCompanyId(), + new Date()); } catch (PortalException | SystemException e) { _log.error("error", e); } if (esito != null) - actionResponse.setRenderParameter("esito", esito.toArray(new String[esito.size()])); + actionResponse.setRenderParameter("esito", + esito.toArray(new String[esito.size()])); } - public void manutenzioneDatabase(ActionRequest actionRequest, ActionResponse actionResponse) - throws PortalException, SystemException { - ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); + public void manutenzioneDatabase(ActionRequest actionRequest, + ActionResponse actionResponse) throws PortalException, + SystemException { + ServiceContext serviceContext = ServiceContextFactory + .getInstance(actionRequest); List esito = PuliziaDatabase.pulisci(serviceContext); - 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) throws SystemException { + + public void inviaAvviso(ActionRequest actionRequest, + ActionResponse actionResponse) throws SystemException { SismicaUtil.inviaAvviso(actionRequest, actionResponse); } - public void salvaDataProssimoSorteggio(ActionRequest actionRequest, ActionResponse actionResponse) - throws PortalException, SystemException { + public void salvaDataProssimoSorteggio(ActionRequest actionRequest, + ActionResponse actionResponse) throws PortalException, + SystemException { - ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); + ServiceContext serviceContext = ServiceContextFactory + .getInstance(actionRequest); serviceContext.setScopeGroupId(-1L); serviceContext.setCompanyId(serviceContext.getCompanyId()); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); - Date dataProssimoSorteggio = ParamUtil.getDate(actionRequest, "dataProssimoSorteggio", sdf); + Date dataProssimoSorteggio = ParamUtil.getDate(actionRequest, + "dataProssimoSorteggio", sdf); - ConfigurazioneServiceUtil.storeConfig("conf.geniocivile.sorteggio.data.prossimo.sorteggio", + ConfigurazioneServiceUtil.storeConfig( + "conf.geniocivile.sorteggio.data.prossimo.sorteggio", sdf.format(dataProssimoSorteggio), serviceContext); } diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/sismica_administration/view.jsp b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/sismica_administration/view.jsp index 61383eab..81644b38 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/sismica_administration/view.jsp +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/html/sismica_administration/view.jsp @@ -176,6 +176,10 @@ String dataProssimoSorteggio = value="<%=DocPratica.class.getName()%>"> + +