diff --git a/liferay-plugins-sdk-6.2/build.portos.properties b/liferay-plugins-sdk-6.2/build.portos.properties index 29a42a94..726a9c5f 100644 --- a/liferay-plugins-sdk-6.2/build.portos.properties +++ b/liferay-plugins-sdk-6.2/build.portos.properties @@ -1,7 +1,3 @@ -# Managed by Liferay IDE (remove this comment to prevent future updates) - -#Managed by Liferay IDE (remove this comment to prevent future updates) -#Fri Sep 27 09:42:25 CEST 2019 app.server.tomcat.lib.global.dir = /home/portos/bin/liferay-portal-6.2-ce-ga6/tomcat-7.0.62/lib/ext app.server.tomcat.deploy.dir = /home/portos/bin/liferay-portal-6.2-ce-ga6/tomcat-7.0.62/webapps app.server.parent.dir = /home/portos/bin/liferay-portal-6.2-ce-ga6 diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/axis.jar b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/axis.jar deleted file mode 100644 index a4ad0aa8..00000000 Binary files a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/axis.jar and /dev/null differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/commons-discovery.jar b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/commons-discovery.jar deleted file mode 100644 index 8355f0be..00000000 Binary files a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/commons-discovery.jar and /dev/null differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/commons-logging.jar b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/commons-logging.jar deleted file mode 100644 index 8758a96b..00000000 Binary files a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/commons-logging.jar and /dev/null differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpclient.jar b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpclient.jar deleted file mode 100644 index 970c9891..00000000 Binary files a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpclient.jar and /dev/null differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/jaxrpc.jar b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/jaxrpc.jar deleted file mode 100644 index a2c13d9a..00000000 Binary files a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/jaxrpc.jar and /dev/null differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/jstl-api.jar b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/jstl-api.jar deleted file mode 100644 index 80a5737f..00000000 Binary files a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/jstl-api.jar and /dev/null differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/jstl-impl.jar b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/jstl-impl.jar deleted file mode 100644 index e5a9342f..00000000 Binary files a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/jstl-impl.jar and /dev/null differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/log4j.jar b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/log4j.jar deleted file mode 100644 index 068867eb..00000000 Binary files a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/log4j.jar and /dev/null differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/util-bridges.jar b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/util-bridges.jar deleted file mode 100644 index 7d7435fe..00000000 Binary files a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/util-bridges.jar and /dev/null differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/util-java.jar b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/util-java.jar deleted file mode 100644 index 1155f26e..00000000 Binary files a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/util-java.jar and /dev/null differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/util-taglib.jar b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/util-taglib.jar deleted file mode 100644 index fbba5f0a..00000000 Binary files a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/util-taglib.jar and /dev/null differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/wsdl4j.jar b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/wsdl4j.jar deleted file mode 100644 index 67a35fcb..00000000 Binary files a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/wsdl4j.jar and /dev/null differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/xml-apis.jar b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/xml-apis.jar deleted file mode 100644 index 46733464..00000000 Binary files a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/xml-apis.jar and /dev/null differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/liferay-plugin-package.properties b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/liferay-plugin-package.properties index c2c0f663..4080ad0f 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/liferay-plugin-package.properties +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/liferay-plugin-package.properties @@ -10,14 +10,15 @@ author=Liferay, Inc. licenses=LGPL liferay-versions=6.2.0+ portal-dependency-jars=\ + axis.jar,\ + commons-discovery.jar,\ + httpclient.jar,\ + jaxrpc.jar,\ jstl-api.jar,\ jstl-impl.jar,\ - jaxrpc.jar,\ - commons-discovery.jar,\ + util-java.jar,\ wsdl4j.jar,\ - axis.jar,\ - xml-apis.jar,\ - httpclient.jar + xml-apis.jar portal-dependency-tlds=\ c.tld required-deployment-contexts=\ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaService.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaService.java index c6a3af41..c96e4b80 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaService.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaService.java @@ -341,8 +341,5 @@ public interface DettPraticaService extends BaseService, InvokableService { java.io.IOException; public void sendToVersioning(long dettPraticaId, long companyId) - throws com.liferay.portal.kernel.exception.PortalException, - com.liferay.portal.kernel.exception.SystemException, - java.io.IOException, java.lang.NoSuchFieldException, - java.lang.SecurityException; + throws java.lang.Exception; } \ No newline at end of file diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaServiceClp.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaServiceClp.java index ee844d98..d07cbb42 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaServiceClp.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaServiceClp.java @@ -1740,10 +1740,7 @@ public class DettPraticaServiceClp implements DettPraticaService { @Override public void sendToVersioning(long dettPraticaId, long companyId) - throws com.liferay.portal.kernel.exception.PortalException, - com.liferay.portal.kernel.exception.SystemException, - java.io.IOException, java.lang.NoSuchFieldException, - java.lang.SecurityException { + throws java.lang.Exception { try { _invokableService.invokeMethod(_methodName26, _methodParameterTypes26, @@ -1752,24 +1749,8 @@ public class DettPraticaServiceClp implements DettPraticaService { catch (Throwable t) { t = ClpSerializer.translateThrowable(t); - if (t instanceof com.liferay.portal.kernel.exception.PortalException) { - throw (com.liferay.portal.kernel.exception.PortalException)t; - } - - if (t instanceof com.liferay.portal.kernel.exception.SystemException) { - throw (com.liferay.portal.kernel.exception.SystemException)t; - } - - if (t instanceof java.io.IOException) { - throw (java.io.IOException)t; - } - - if (t instanceof java.lang.NoSuchFieldException) { - throw (java.lang.NoSuchFieldException)t; - } - - if (t instanceof java.lang.SecurityException) { - throw (java.lang.SecurityException)t; + if (t instanceof java.lang.Exception) { + throw (java.lang.Exception)t; } if (t instanceof RuntimeException) { diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaServiceUtil.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaServiceUtil.java index 4c4e43f3..4f206d68 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaServiceUtil.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaServiceUtil.java @@ -483,10 +483,7 @@ public class DettPraticaServiceUtil { } public static void sendToVersioning(long dettPraticaId, long companyId) - throws com.liferay.portal.kernel.exception.PortalException, - com.liferay.portal.kernel.exception.SystemException, - java.io.IOException, java.lang.NoSuchFieldException, - java.lang.SecurityException { + throws java.lang.Exception { getService().sendToVersioning(dettPraticaId, companyId); } diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaServiceWrapper.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaServiceWrapper.java index 6d09b31d..f1a0fa0c 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaServiceWrapper.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaServiceWrapper.java @@ -493,10 +493,7 @@ public class DettPraticaServiceWrapper implements DettPraticaService, @Override public void sendToVersioning(long dettPraticaId, long companyId) - throws com.liferay.portal.kernel.exception.PortalException, - com.liferay.portal.kernel.exception.SystemException, - java.io.IOException, java.lang.NoSuchFieldException, - java.lang.SecurityException { + throws java.lang.Exception { _dettPraticaService.sendToVersioning(dettPraticaId, companyId); } diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/ProtocolloUtil.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/ProtocolloUtil.java index 7c6f00c6..98f7a07f 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/ProtocolloUtil.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/ProtocolloUtil.java @@ -1,119 +1,79 @@ package it.tref.liferay.portos.bo.util; +import it.mwg.sismica.bo.util.HttpServiceUtil; import it.tref.liferay.portos.bo.model.Avviso; import it.tref.liferay.portos.bo.service.AvvisoLocalServiceUtil; -import it.tref.liferay.portos.bo.service.ConfigurazioneLocalServiceUtil; import it.tref.liferay.portos.bo.shared.protocollo.model.File; import it.tref.liferay.portos.bo.shared.protocollo.model.Protocollo; import it.tref.liferay.portos.bo.shared.protocollo.model.Protocollo.TipoProtocollo; -import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants; - -import java.io.InputStream; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import javax.servlet.http.HttpServletResponse; - import org.apache.commons.codec.digest.DigestUtils; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.SystemException; -import com.liferay.portal.kernel.json.JSONFactoryUtil; import com.liferay.portal.kernel.json.JSONObject; -import com.liferay.portal.kernel.util.ContentTypes; -import com.liferay.portal.kernel.util.Http.Body; -import com.liferay.portal.kernel.util.Http.Options; -import com.liferay.portal.kernel.util.HttpUtil; -import com.liferay.portal.kernel.util.StreamUtil; -import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.Validator; public class ProtocolloUtil { - public static String protocollaPartenzaAccessoAtti(long accessoAttiId, long intPraticaId, long groupId, String className, long companyId, String screenName) throws Exception { + public static String protocollaPartenzaAccessoAtti(long accessoAttiId, long intPraticaId, long groupId, + String className, long companyId, String screenName) throws Exception { - String protocollo = null; + File allegato = new File(); - InputStream inputStream = null; + String doc = String.valueOf(accessoAttiId); - try { + String sha256 = DigestUtils.sha256Hex(doc); - File allegato = new File(); - - String doc = String.valueOf(accessoAttiId); - - String sha256 = DigestUtils.sha256Hex(doc); - - allegato.setFileId("0"); - allegato.setFileSha256(sha256); - - // utilizzato anche come discriminate tra la 1a e la 2a chiamata - // 1a recupero numero protocollo -> 1 allegato finto - // 2a aggiorno dati del documento prodotto -> 2 allegati, il 1o giusto e il 2o per recupero - // num protocollo - - Protocollo protocolloBean = new Protocollo(); - protocolloBean.setOggetto(generaOggettoProtocollo(className, accessoAttiId)); - protocolloBean.setChiuso(false); - protocolloBean.setTipo(TipoProtocollo.USCITA); - protocolloBean.setUtenteId(screenName); - protocolloBean.setUfficioId(String.valueOf(groupId)); - protocolloBean.setPraticaId(String.valueOf(accessoAttiId)); - protocolloBean.setFiles(Collections.singletonList(allegato)); - Options options = createCall(companyId, protocolloBean, true); - - String responseBody = HttpUtil.URLtoString(options); - if (options.getResponse().getResponseCode() == HttpServletResponse.SC_OK - || options.getResponse().getResponseCode() == HttpServletResponse.SC_CREATED) { - JSONObject risposta = JSONFactoryUtil.createJSONObject(responseBody); - protocollo = risposta.getString("anno") + String.format("%07d", risposta.getInt("numero")); - } else { - throw new Exception(options.getResponse().getResponseCode() + StringPool.SPACE + responseBody); - } + allegato.setFileId("0"); + allegato.setFileSha256(sha256); - } finally { - StreamUtil.cleanUp(inputStream); - } + // utilizzato anche come discriminate tra la 1a e la 2a chiamata 1a + // recupero numero protocollo -> 1 allegato finto 2a aggiorno dati del + // documento prodotto -> 2 allegati, il 1o giusto e il 2o per recupero + // num protocollo + + Protocollo protocolloBean = new Protocollo(); + protocolloBean.setOggetto(generaOggettoProtocollo(className, accessoAttiId)); + protocolloBean.setChiuso(false); + protocolloBean.setTipo(TipoProtocollo.USCITA); + protocolloBean.setUtenteId(screenName); + protocolloBean.setUfficioId(String.valueOf(groupId)); + protocolloBean.setPraticaId(String.valueOf(accessoAttiId)); + protocolloBean.setFiles(Collections.singletonList(allegato)); + JSONObject risposta = HttpServiceUtil.postProtocolloBean(companyId, protocolloBean); + return risposta.getString("anno") + String.format("%07d", risposta.getInt("numero")); + } + + public static String protocollaArrivoAccessoAtti(long groupId, long companyId, String userName, + long accessoAttiId, String className) throws Exception { + + String protocollo = null; - return protocollo; + List allegati = new ArrayList(); + File allegato = new File(); + String doc = String.valueOf(accessoAttiId); + String sha256 = DigestUtils.sha256Hex(doc); + allegato.setFileId("0"); + allegato.setFileSha256(sha256); + allegati.add(allegato); + + Protocollo protocolloBean = new Protocollo(); + protocolloBean.setOggetto(generaOggettoProtocollo(className, accessoAttiId)); + protocolloBean.setChiuso(false); + protocolloBean.setTipo(TipoProtocollo.INGRESSO); + protocolloBean.setUtenteId(userName); + protocolloBean.setUfficioId(String.valueOf(groupId)); + protocolloBean.setPraticaId(String.valueOf(accessoAttiId)); + + protocolloBean.setFiles(allegati); + + JSONObject risposta = HttpServiceUtil.postProtocolloBean(companyId, protocolloBean); + return risposta.getString("anno") + String.format("%07d", risposta.getInt("numero")); } - - public static String protocollaArrivoAccessoAtti(long groupId, long companyId, String userName, long accessoAttiId, String className) throws Exception { - - String protocollo = null; - - List allegati = new ArrayList(); - File allegato = new File(); - String doc = String.valueOf(accessoAttiId); - String sha256 = DigestUtils.sha256Hex(doc); - allegato.setFileId("0"); - allegato.setFileSha256(sha256); - allegati.add(allegato); - - Protocollo protocolloBean = new Protocollo(); - protocolloBean.setOggetto(generaOggettoProtocollo(className, accessoAttiId)); - protocolloBean.setChiuso(false); - protocolloBean.setTipo(TipoProtocollo.INGRESSO); - protocolloBean.setUtenteId(userName); - protocolloBean.setUfficioId(String.valueOf(groupId)); - protocolloBean.setPraticaId(String.valueOf(accessoAttiId)); - - protocolloBean.setFiles(allegati); - Options options = createCall(companyId, protocolloBean, true); - - - String responseBody = HttpUtil.URLtoString(options); - if (options.getResponse().getResponseCode() == HttpServletResponse.SC_OK - || options.getResponse().getResponseCode() == HttpServletResponse.SC_CREATED) { - JSONObject risposta = JSONFactoryUtil.createJSONObject(responseBody); - protocollo = risposta.getString("anno") + String.format("%07d", risposta.getInt("numero")); - } else { - throw new Exception(options.getResponse().getResponseCode() + StringPool.SPACE + responseBody); - } - - return protocollo; - } public static String generaOggettoProtocollo(String className, long classPk) { @@ -128,26 +88,4 @@ public class ProtocolloUtil { return "Oggetto: " + className + " " + classPk; } - private static Options createCall(long companyId, Protocollo protocolloBean, boolean post) throws SystemException { - - String url = - ConfigurazioneLocalServiceUtil.findByC_ChiaveString(companyId, - ConfigurazioneConstants.PROTOCOLLAZIONE_SERVICE_URL); - - Options options = new Options(); - options.setLocation(url); - options.setPost(post); - - flexjson.JSONSerializer serialize = new flexjson.JSONSerializer(); - serialize.exclude("*.class"); - String protocollo = serialize.serialize(protocolloBean); - Body body = new Body(protocollo, ContentTypes.APPLICATION_JSON, "UTF-8"); - - options.setBody(body); - - - return options; - - } - } diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/FascicoloPortlet.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/FascicoloPortlet.java index f78b57f1..e74e1402 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/FascicoloPortlet.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/FascicoloPortlet.java @@ -101,654 +101,698 @@ import com.liferay.util.bridges.mvc.MVCPortlet; */ public class FascicoloPortlet extends MVCPortlet { - private Log _log = LogFactoryUtil.getLog(FascicoloPortlet.class); - - @Override - public void render(RenderRequest request, RenderResponse response) throws PortletException, IOException { - - HttpServletRequest httpReq = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(request)); - String intPraticaId = httpReq.getParameter("intPraticaId"); - - if (Validator.isNotNull(intPraticaId) && !intPraticaId.equals("")) { - request.setAttribute("intPraticaId", intPraticaId); - } - - super.render(request, response); - } - - public void toggleWorkflow(ActionRequest actionRequest, ActionResponse actionResponse) { - - - ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); - User user = themeDisplay.getUser(); - - boolean attivare = ParamUtil.getBoolean(actionRequest, "avviare"); - boolean sospendere = ParamUtil.getBoolean(actionRequest, "sospendere"); - long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0); - String stato_pratica= ParamUtil.getString(actionRequest, "seleziona_stato"); - - try { - - IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId); - Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()); - DettPratica dettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(intPraticaId); - ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); - - if (attivare && !sospendere) { - WorkflowUtil.attivaWorkflow(intPraticaId, territorio.getGroupId(), serviceContext.getUserId(), - dettPratica.getDettPraticaId(), serviceContext, true); - - addRowHistoryWorkflowAction(intPraticaId, dettPratica.getDettPraticaId(), - themeDisplay.getCompanyId(), intPratica.getGroupId(), user, true); - - SessionMessages.add(actionRequest, "success-workflow-ripreso"); - } else if (!attivare && sospendere) { - WorkflowUtil.attivaWorkflow(intPraticaId, territorio.getGroupId(), serviceContext.getUserId(), - dettPratica.getDettPraticaId(), serviceContext, false); - - addRowHistoryWorkflowAction(intPraticaId, dettPratica.getDettPraticaId(), - themeDisplay.getCompanyId(), intPratica.getGroupId(), user, false); - - SessionMessages.add(actionRequest, "success-workflow-sospeso"); - } else { - SessionErrors.add(actionRequest, "error-workflow-stato-incosistente"); - } - - String redirectURL = ParamUtil.getString(actionRequest, "redirect"); - if (Validator.isNotNull(redirectURL)) { - actionResponse.sendRedirect(redirectURL); - } - - if(!attivare){ - intPratica.setStatoPratica(stato_pratica); - IntPraticaLocalServiceUtil.updateStatoPratica(intPraticaId, 0, stato_pratica); - } else { - intPratica.setStatoPratica(StatoPraticaConstants.SOTTOPOSTA_A_PARERE); - IntPraticaLocalServiceUtil.updateStatoPratica(intPraticaId, 0, StatoPraticaConstants.SOTTOPOSTA_A_PARERE); - } - - - IntPraticaLocalServiceUtil.reIndexFasciolo(intPraticaId, intPratica.getCompanyId()); - - } catch (Exception e) { - _log.error("error-workflow-sospeso", e); - SessionErrors.add(actionRequest, attivare ? "error-workflow-sospeso" : "error-workflow-ripreso"); - } - - } - - private void addRowHistoryWorkflowAction(long intPraticaId, long dettPraticaId, long companyId, long groupId, User user, boolean attivato) throws SystemException{ - - HistoryWorkflowAction historyWorkflowAction = HistoryWorkflowActionLocalServiceUtil.createHistoryWorkflowAction( - CounterLocalServiceUtil.increment(HistoryWorkflowAction.class.getName())); - - historyWorkflowAction.setAttivato(attivato); - historyWorkflowAction.setCompanyId(companyId); - historyWorkflowAction.setCreateDate(new Date()); - historyWorkflowAction.setModifiedDate(new Date()); - historyWorkflowAction.setUserId(user.getUserId()); - historyWorkflowAction.setUserName(user.getScreenName()); - historyWorkflowAction.setIntPraticaId(intPraticaId); - historyWorkflowAction.setDettPraticaId(dettPraticaId); - historyWorkflowAction.setGroupId(groupId); - - HistoryWorkflowActionLocalServiceUtil.updateHistoryWorkflowAction(historyWorkflowAction); - - } - - public void toggleSospensione(ActionRequest actionRequest, ActionResponse actionResponse) { - - long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0); - boolean sospesa = ParamUtil.getBoolean(actionRequest, "sospesa"); - - try { - - IntPraticaServiceUtil.sospendiPratica(intPraticaId, sospesa); - SessionMessages.add(actionRequest, sospesa ? "success-sospesa" : "success-ripresa"); - - } catch (PortalException | SystemException e) { - _log.error("error-workflow-sospeso", e); - SessionErrors.add(actionRequest, sospesa ? "error-sospesa" : "error-ripresa"); - } - - } - - public void cambiaStato(ActionRequest actionRequest, ActionResponse actionResponse) { - - long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0); - String statoPratica = ParamUtil.getString(actionRequest, "nuovoStatoPratica"); - - _log.info("cambiaSospendiRiprendi: INTPRATICAID" + intPraticaId); - try { - _log.info("cambiaSospendiRiprendi: INTPRATICAID" + intPraticaId + " NUOVO STATO: " + statoPratica); - IntPraticaServiceUtil.updateStatoPratica(intPraticaId, statoPratica); - SessionMessages.add(actionRequest, "success-cambio-stato"); - } catch (PortalException | SystemException e) { - _log.error("error-workflow-sospeso", e); - SessionErrors.add(actionRequest, "error-cambio-stato"); - } - - } - - public void aggiungiRichiestaParere(ActionRequest actionRequest, ActionResponse actionResponse) { - - long geologoId = ParamUtil.getLong(actionRequest, "geologoId"); - long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId"); - long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId"); - - try { - ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); - serviceContext.setCreateDate(new Date()); - serviceContext.setModifiedDate(new Date()); - ParereGeologoServiceUtil.addParereGeologo(geologoId, intPraticaId, dettPraticaId, serviceContext); - } catch (PortalException | SystemException e) { - _log.error("error-workflow-sospeso", e); - SessionErrors.add(actionRequest, "error-aggiunta-richiesta-parere"); - } - } - - public void cambiaTitolare(ActionRequest actionRequest, ActionResponse actionResponse) { - - String nuovoSoggettoCF = ParamUtil.getString(actionRequest, "nuovoSoggettoCF"); - long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0); - long companyId = ParamUtil.getLong(actionRequest, "companyId"); - - - try { - ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); - User user = UserLocalServiceUtil.fetchUserByScreenName(companyId, nuovoSoggettoCF); - if (Validator.isNotNull(user)) { - if (!ValidazionePraticaUtil.praticaInProgress(intPraticaId)) { - _log.info("cambiaTitolare: cfNuovoTitolare " + nuovoSoggettoCF + " intpratica" + intPraticaId); - IntPraticaServiceUtil.cambiaTitolare(intPraticaId, user.getUserId(), serviceContext); - SessionMessages.add(actionRequest, "success-cambio-titolare"); - } else { - SessionErrors.add(actionRequest, "error-cambio-titolare-pratica-in-progress"); - } - } else { - _log.error("[FASCICOLO ACTION - CAMBIO TITOLARE] Nessun utente trovato con company " + companyId - + " e codice fiscale " + nuovoSoggettoCF); - SessionErrors.add(actionRequest, "error-cambio-titolare-no-such-user"); - } - } catch (PortalException | SystemException e) { - _log.error("error-cambio-titolare", e); - SessionErrors.add(actionRequest, "error-cambio-titolare"); - } - - } - - public void searchURL(ActionRequest actionRequest, ActionResponse actionResponse) { - - String numeroProgetto = actionRequest.getParameter("numeroProgetto"); - String protocollo = actionRequest.getParameter("protocollo"); - String tipoPratica = actionRequest.getParameter("tipoPratica"); - String statoPratica = actionRequest.getParameter("statoPratica"); - String committente = actionRequest.getParameter("committente"); - String descInterventoSearch = actionRequest.getParameter("descIntervento"); - String tecnicoIstruttore = actionRequest.getParameter("tecnicoIstruttore"); - String titolareDigitale = actionRequest.getParameter("titolareDigitale"); - String soggettiInterconnessi = actionRequest.getParameter("soggettiInterconnessi"); - String dataRichiestaInizio = actionRequest.getParameter("dataRichiestaInizio"); - String dataRichiestaFine = actionRequest.getParameter("dataRichiestaFine"); - String provincia = actionRequest.getParameter("provincia"); - String praticaAperta = actionRequest.getParameter("praticaAperta"); - String comune = actionRequest.getParameter("comune"); - String tipoIntervento = actionRequest.getParameter("tipoIntervento"); - String indirizzo = actionRequest.getParameter("indirizzo"); - - if (dataRichiestaInizio != null && !dataRichiestaInizio.equals("")) { - String[] dataRichiestaInizioSplitted = dataRichiestaInizio.split("/"); - - int mounth = Integer.valueOf(dataRichiestaInizioSplitted[1]) -1; - - actionResponse.setRenderParameter("dataRichiestaInizioDay", dataRichiestaInizioSplitted[0]); - actionResponse.setRenderParameter("dataRichiestaInizioMonth", mounth+""); - actionResponse.setRenderParameter("dataRichiestaInizioYear", dataRichiestaInizioSplitted[2]); - } - - if (dataRichiestaFine != null && !dataRichiestaFine.equals("")) { - String[] dataRichiestaFineSplitted = dataRichiestaFine.split("/"); - - int mounth = Integer.valueOf(dataRichiestaFineSplitted[1]) -1; - - actionResponse.setRenderParameter("dataRichiestaFineDay", dataRichiestaFineSplitted[0]); - actionResponse.setRenderParameter("dataRichiestaFineMonth", mounth+""); - actionResponse.setRenderParameter("dataRichiestaFineYear", dataRichiestaFineSplitted[2]); - } - - - String ufficio = actionRequest.getParameter("ufficio"); - String ordinaPer = actionRequest.getParameter("ordinaPer"); - String ordinaTipo = actionRequest.getParameter("ordinaTipo"); - - if (tipoIntervento != null && !tipoIntervento.equals("")) { - actionResponse.setRenderParameter("tipoIntervento", tipoIntervento); - } - - actionResponse.setRenderParameter("numeroProgetto", numeroProgetto); - actionResponse.setRenderParameter("praticaAperta", praticaAperta); - actionResponse.setRenderParameter("descIntervento", descInterventoSearch); - actionResponse.setRenderParameter("protocollo", protocollo); - actionResponse.setRenderParameter("tipoPratica", tipoPratica); - actionResponse.setRenderParameter("tipoPratica", tipoPratica); - actionResponse.setRenderParameter("statoPratica", statoPratica); - actionResponse.setRenderParameter("committente", committente); - - if(provincia != null && !provincia.equals("")){ - actionResponse.setRenderParameter("provincia", provincia); - } - - if(comune != null && !comune.equals("")){ - actionResponse.setRenderParameter("comune", comune); - } - - actionResponse.setRenderParameter("indirizzo", indirizzo); - - if (tecnicoIstruttore != null && !tecnicoIstruttore.equals("")) { - actionResponse.setRenderParameter("tecnicoIstruttore", tecnicoIstruttore); - } else { - actionResponse.setRenderParameter("tecnicoIstruttore", StringPool.BLANK); - } - - actionResponse.setRenderParameter("titolareDigitale", titolareDigitale); - actionResponse.setRenderParameter("soggettiInterconnessi", soggettiInterconnessi); - actionResponse.setRenderParameter("dataRichiestaInizio", dataRichiestaInizio); - actionResponse.setRenderParameter("dataRichiestaFine", dataRichiestaFine); - - if (ufficio != null && !ufficio.equals("")) { - actionResponse.setRenderParameter("ufficio", ufficio); - } else { - actionResponse.setRenderParameter("ufficio", -1 + ""); - } - - - actionResponse.setRenderParameter("ordinaPer", ordinaPer); - actionResponse.setRenderParameter("ordinaTipo", ordinaTipo); - - } - - public void versiona(ActionRequest actionRequest, ActionResponse actionResponse) { - - long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId", 0); - long companyId = ParamUtil.getLong(actionRequest, "companyId"); - - - try { - DettPraticaServiceUtil.sendToVersioning(dettPraticaId, companyId); - - } catch (PortalException | SystemException | IOException | NoSuchFieldException | SecurityException e) { - _log.error("error-versioning", e); - SessionErrors.add(actionRequest, "error-versioning"); - } - - PortalUtil.copyRequestParameters(actionRequest, actionResponse); - - } - - @Override - public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, - PortletException { - - String id = resourceRequest.getResourceID(); - ServiceContext serviceContext; - try { - serviceContext = ServiceContextFactory.getInstance(resourceRequest); - if ("downloadAllDocPratica".equals(id)) { - - long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId"); - long classPk = ParamUtil.getLong(resourceRequest, "classPk"); - String comingFrom = ParamUtil.getString(resourceRequest, "comingFrom"); - List docs = new ArrayList<>(); - if (Validator.isNull(comingFrom)) { - docs = DocPraticaLocalServiceUtil.findByClassPk(classPk); - } else { - List tipologieAllegati = new ArrayList(); - if ("page_geologica".equals(comingFrom)) { - tipologieAllegati = DocumentiPraticaUtil.getDocGeologo(); - } else if ("page_allegati".equals(comingFrom)) { - tipologieAllegati = DocumentiPraticaUtil.getDocDomanda(); - IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId); - if (Validator.isNotNull(intPratica.getOldIntPraticaId())) { - tipologieAllegati.addAll(0, DocumentiPraticaUtil.getDocDomandaPortos1()); - } - } else if ("page_fine_lavori".equals(comingFrom)) { - tipologieAllegati = DocumentiPraticaUtil.getDocFineLavori(); - } else if ("page_collaudo".equals(comingFrom)) { - tipologieAllegati = DocumentiPraticaUtil.getDocCollaudo(); - } - docs = - DocPraticaLocalServiceUtil.findByIntPratica_ClassPk_Tipologie(intPraticaId, classPk, tipologieAllegati); - } - - ZipWriter zipWriter = ZipWriterFactoryUtil.getZipWriter(); - - for (DocPratica doc : docs) { - - InputStream inputStream = null; - try { - if (Validator.isNull(doc.getDlFileEntryId())) { - continue; - } - FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(doc.getDlFileEntryId()); - inputStream = - DLFileEntryLocalServiceUtil.getFileAsStream(fileEntry.getFileEntryId(), fileEntry.getVersion(), false); - - // String name = fileEntry.getTitle() + StringPool.PERIOD + fileEntry.getExtension(); - String name = fileEntry.getTitle(); - zipWriter.addEntry(name, inputStream); - } finally { - StreamUtil.cleanUp(inputStream); - } - } - - resourceResponse.reset(); - - File file = zipWriter.getFile(); - byte[] data = Files.readAllBytes(file.toPath()); - - resourceResponse.setContentType(ContentTypes.APPLICATION_ZIP); - resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate"); - resourceResponse - .addProperty(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getName() + "\""); - resourceResponse.setContentLength(data.length); - - resourceResponse.getPortletOutputStream().write(data); - resourceResponse.getPortletOutputStream().flush(); - resourceResponse.getPortletOutputStream().close(); - - } else if ("importFile".equals(id)) { - - long classPk = ParamUtil.getLong(resourceRequest, "classPk"); - String className = ParamUtil.getString(resourceRequest, "className"); - - FilesImporter.importaFile(classPk, className); - - // if (DocPratica.class.getName().equalsIgnoreCase(className)) { - // DocPratica docPratica = DocPraticaLocalServiceUtil.getDocPratica(classPk); - // if (docPratica.getDlFileEntryId() == 0L && docPratica.getOldDlFileEntryId() != 0L) { - // FilesImporter.handleFileImportDocPratica(docPratica); - // } - // } else if (Avviso.class.getName().equalsIgnoreCase(className)) { - // Avviso avviso = AvvisoLocalServiceUtil.getAvviso(classPk); - // if (avviso.getFileEntryIdBase() == 0L && avviso.getOldFileEntryIdBase() != 0L) { - // FilesImporter.handleFileImportAvviso(avviso, true); - // } - // if (avviso.getFileEntryIdInvio() == 0L && avviso.getOldFileEntryIdInvio() != 0L) { - // FilesImporter.handleFileImportAvviso(avviso, false); - // } - // } else if (Pagamento.class.getName().equalsIgnoreCase(className)) { - // Pagamento pagamento = PagamentoLocalServiceUtil.getPagamento(classPk); - // if (pagamento.getFileEntryId() == 0L && pagamento.getOldFileEntryId() != 0L) { - // FilesImporter.handleFileImportPagamento(pagamento); - // } - // } else if (DocAggiuntiva.class.getName().equalsIgnoreCase(className)) { - // DocAggiuntiva docAggiuntiva = DocAggiuntivaLocalServiceUtil.getDocAggiuntiva(classPk); - // if (docAggiuntiva.getFileEntryId() == 0L && docAggiuntiva.getOldFileEntryId() != 0L) { - // FilesImporter.handleFileImportDocAggiuntiva(docAggiuntiva); - // } - // } else if (AllegatoManuale.class.getName().equalsIgnoreCase(className)) { - // AllegatoManuale allegatoManuale = - // AllegatoManualeLocalServiceUtil.getAllegatoManuale(classPk); - // if (allegatoManuale.getFileEntryId() == 0L && allegatoManuale.getOldFileEntryId() != 0L) - // { - // FilesImporter.handleFileImportAllegatoManuale(allegatoManuale); - // } - // } - - PortletResponseUtil - .write( - resourceResponse, - "

Completato

Refresh"); - - } 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 listaDet = DettPraticaLocalServiceUtil.findByIntPraticaId(intPraticaId); - for (DettPratica dettPratica : listaDet) { - FilesImporter.importaFilesFascicolo(dettPratica.getDettPraticaId(), DettPratica.class.getName()); - } - - List listaFine = FineLavoriLocalServiceUtil.findByIntPraticaId(intPraticaId, -1, -1, null); - for (FineLavori fineLavori : listaFine) { - FilesImporter.importaFilesFascicolo(fineLavori.getFineLavoriId(), FineLavori.class.getName()); - } - - List 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, - "

Completato

Refresh"); - } else if ("comuni".equals(id)) { - String provinciaId = ParamUtil.getString(resourceRequest, "provinciaId"); - JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); - if (Validator.isNotNull(provinciaId) && !provinciaId.equals("0")) { - List comuniIds = TerritorioLocalServiceUtil.getActiveComuniByCodiceProvincia(provinciaId); - - //ADT BUG-ID=15 Sezione Ricerca / Ordinamento Filtro - List comumeList = new ArrayList(); - for (long comuneId : comuniIds) { - Comune comune = ComuneLocalServiceUtil.getComune(comuneId); - comumeList.add(comune); - } - - Collections.sort(comumeList, new Comparator() { - @Override - public int compare(Comune o1, Comune o2) { - return o1.getDenominazione().compareTo(o2.getDenominazione()); - } - }); - - for (Comune comune : comumeList) { - JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); - jsonObject.put("comuneId", comune.getComuneId()); - jsonObject.put("descLong", comune.getDenominazione()); - - jsonArray.put(jsonObject); - } - } - writeJSON(resourceRequest, resourceResponse, jsonArray); - - } else if("exportRicerca".equals(id)){ - - ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); - Locale locale = themeDisplay.getLocale(); - - User user = themeDisplay.getUser(); - - - String csv = StringPool.BLANK; - - HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest); - HttpServletResponse response = PortalUtil.getHttpServletResponse(resourceResponse); - - csv = exportSearch(locale, resourceRequest, user); - - ServletResponseUtil.sendFile(request, response, "export_ricerca.csv", csv.getBytes(StringPool.UTF8), - ContentTypes.TEXT_CSV_UTF8); - - }else { - super.serveResource(resourceRequest, resourceResponse); - } - } catch (Exception e) { - _log.error(e, e); - throw new IOException(e); - } - - } - - private String exportSearch(Locale locale, ResourceRequest resourceRequest, User user) { - String method = "exportSearch"; - - HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(resourceRequest); - StringBuilder sb = new StringBuilder(); - - List lista = new ArrayList(); - -// try { - - Hits hits = IntPraticaAdvancedSearch.searchProgettiBO(httpRequest, user, -1, -1); - - for (Document doc : hits.toList()) { - String intPraticaId = doc.get("intPraticaId"); - try { - if (Validator.isNotNull(intPraticaId)) { - IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(GetterUtil.getLong(intPraticaId)); - if (Validator.isNotNull(intPratica)) { - lista.add(intPratica); - } - } - } catch(Throwable e){ - _log.error(method + " IntPraticaLocalServiceUtil.fetchIntPratica IntPraticaId: " + intPraticaId, e); - } - } - - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.sorteggiata"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.pratica"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.titolare"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.committenti"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.istruttore"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.statoPratica"))); - sb.append(StringPool.SEMICOLON); - - //ADT BUG-ID=15 Sezione Ricerca / Export csv - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.provincia"))); - sb.append(StringPool.SEMICOLON); - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.comune"))); - sb.append(StringPool.SEMICOLON); - - sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.descrizioneIntervento"))); - sb.append(StringPool.SEMICOLON); - - sb.append(StringPool.NEW_LINE); - - - SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); - - for (IntPratica intPratica : lista) { - - try{ - DettPratica lastDettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(intPratica.getIntPraticaId()); - - Territorio territorio = TerritorioLocalServiceUtil.fetchTerritorio(intPratica.getTerritorioId()); - Comune comune = ComuneLocalServiceUtil.fetchComune(territorio.getComuneId()); - - Provincia provincia = - ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(), territorio.getCodiceProvincia()); - - boolean sorteggiata = SorteggioLocalServiceUtil.findByIntPratica(intPratica.getIntPraticaId()) != null; - sb.append(CSVUtil.encode((sorteggiata) ? "Si" : "No")); - sb.append(StringPool.SEMICOLON); - - String praticaLabel = intPratica.getTitle(locale, true); - sb.append(CSVUtil.encode(praticaLabel)); - sb.append(StringPool.SEMICOLON); - - User titolareUser = UserLocalServiceUtil.getUserById(intPratica.getUserId()); - List titolari = SoggettoLocalServiceUtil.getValidByIntPratica_CodiceFiscale(lastDettPratica.getIntPraticaId(), lastDettPratica.getCodiceFiscaleDelegatoCommittente()); + private Log _log = LogFactoryUtil.getLog(FascicoloPortlet.class); + + @Override + public void render(RenderRequest request, RenderResponse response) throws PortletException, IOException { + + HttpServletRequest httpReq = PortalUtil.getOriginalServletRequest(PortalUtil + .getHttpServletRequest(request)); + String intPraticaId = httpReq.getParameter("intPraticaId"); + + if (Validator.isNotNull(intPraticaId) && !intPraticaId.equals("")) { + request.setAttribute("intPraticaId", intPraticaId); + } + + super.render(request, response); + } + + public void toggleWorkflow(ActionRequest actionRequest, ActionResponse actionResponse) { + + ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); + User user = themeDisplay.getUser(); + + boolean attivare = ParamUtil.getBoolean(actionRequest, "avviare"); + boolean sospendere = ParamUtil.getBoolean(actionRequest, "sospendere"); + long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0); + String stato_pratica = ParamUtil.getString(actionRequest, "seleziona_stato"); + + try { + + IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId); + Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(intPratica.getTerritorioId()); + DettPratica dettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(intPraticaId); + ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); + + if (attivare && !sospendere) { + WorkflowUtil.attivaWorkflow(intPraticaId, territorio.getGroupId(), + serviceContext.getUserId(), dettPratica.getDettPraticaId(), serviceContext, true); + + addRowHistoryWorkflowAction(intPraticaId, dettPratica.getDettPraticaId(), + themeDisplay.getCompanyId(), intPratica.getGroupId(), user, true); + + SessionMessages.add(actionRequest, "success-workflow-ripreso"); + } else if (!attivare && sospendere) { + WorkflowUtil.attivaWorkflow(intPraticaId, territorio.getGroupId(), + serviceContext.getUserId(), dettPratica.getDettPraticaId(), serviceContext, false); + + addRowHistoryWorkflowAction(intPraticaId, dettPratica.getDettPraticaId(), + themeDisplay.getCompanyId(), intPratica.getGroupId(), user, false); + + SessionMessages.add(actionRequest, "success-workflow-sospeso"); + } else { + SessionErrors.add(actionRequest, "error-workflow-stato-incosistente"); + } + + String redirectURL = ParamUtil.getString(actionRequest, "redirect"); + if (Validator.isNotNull(redirectURL)) { + actionResponse.sendRedirect(redirectURL); + } + + if (!attivare) { + intPratica.setStatoPratica(stato_pratica); + IntPraticaLocalServiceUtil.updateStatoPratica(intPraticaId, 0, stato_pratica); + } else { + intPratica.setStatoPratica(StatoPraticaConstants.SOTTOPOSTA_A_PARERE); + IntPraticaLocalServiceUtil.updateStatoPratica(intPraticaId, 0, + StatoPraticaConstants.SOTTOPOSTA_A_PARERE); + } + + IntPraticaLocalServiceUtil.reIndexFasciolo(intPraticaId, intPratica.getCompanyId()); + + } catch (Exception e) { + _log.error("error-workflow-sospeso", e); + SessionErrors.add(actionRequest, attivare ? "error-workflow-sospeso" : "error-workflow-ripreso"); + } + + } + + private void addRowHistoryWorkflowAction(long intPraticaId, long dettPraticaId, long companyId, + long groupId, User user, boolean attivato) throws SystemException { + + HistoryWorkflowAction historyWorkflowAction = HistoryWorkflowActionLocalServiceUtil + .createHistoryWorkflowAction(CounterLocalServiceUtil.increment(HistoryWorkflowAction.class + .getName())); + + historyWorkflowAction.setAttivato(attivato); + historyWorkflowAction.setCompanyId(companyId); + historyWorkflowAction.setCreateDate(new Date()); + historyWorkflowAction.setModifiedDate(new Date()); + historyWorkflowAction.setUserId(user.getUserId()); + historyWorkflowAction.setUserName(user.getScreenName()); + historyWorkflowAction.setIntPraticaId(intPraticaId); + historyWorkflowAction.setDettPraticaId(dettPraticaId); + historyWorkflowAction.setGroupId(groupId); + + HistoryWorkflowActionLocalServiceUtil.updateHistoryWorkflowAction(historyWorkflowAction); + + } + + public void toggleSospensione(ActionRequest actionRequest, ActionResponse actionResponse) { + + long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0); + boolean sospesa = ParamUtil.getBoolean(actionRequest, "sospesa"); + + try { + + IntPraticaServiceUtil.sospendiPratica(intPraticaId, sospesa); + SessionMessages.add(actionRequest, sospesa ? "success-sospesa" : "success-ripresa"); + + } catch (PortalException | SystemException e) { + _log.error("error-workflow-sospeso", e); + SessionErrors.add(actionRequest, sospesa ? "error-sospesa" : "error-ripresa"); + } + + } + + public void cambiaStato(ActionRequest actionRequest, ActionResponse actionResponse) { + + long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0); + String statoPratica = ParamUtil.getString(actionRequest, "nuovoStatoPratica"); + + _log.info("cambiaSospendiRiprendi: INTPRATICAID" + intPraticaId); + try { + _log.info("cambiaSospendiRiprendi: INTPRATICAID" + intPraticaId + " NUOVO STATO: " + statoPratica); + IntPraticaServiceUtil.updateStatoPratica(intPraticaId, statoPratica); + SessionMessages.add(actionRequest, "success-cambio-stato"); + } catch (PortalException | SystemException e) { + _log.error("error-workflow-sospeso", e); + SessionErrors.add(actionRequest, "error-cambio-stato"); + } + + } + + public void aggiungiRichiestaParere(ActionRequest actionRequest, ActionResponse actionResponse) { + + long geologoId = ParamUtil.getLong(actionRequest, "geologoId"); + long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId"); + long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId"); + + try { + ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); + serviceContext.setCreateDate(new Date()); + serviceContext.setModifiedDate(new Date()); + ParereGeologoServiceUtil.addParereGeologo(geologoId, intPraticaId, dettPraticaId, serviceContext); + } catch (PortalException | SystemException e) { + _log.error("error-workflow-sospeso", e); + SessionErrors.add(actionRequest, "error-aggiunta-richiesta-parere"); + } + } + + public void cambiaTitolare(ActionRequest actionRequest, ActionResponse actionResponse) { + + String nuovoSoggettoCF = ParamUtil.getString(actionRequest, "nuovoSoggettoCF"); + long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0); + long companyId = ParamUtil.getLong(actionRequest, "companyId"); + + try { + ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); + User user = UserLocalServiceUtil.fetchUserByScreenName(companyId, nuovoSoggettoCF); + if (Validator.isNotNull(user)) { + if (!ValidazionePraticaUtil.praticaInProgress(intPraticaId)) { + _log.info("cambiaTitolare: cfNuovoTitolare " + nuovoSoggettoCF + " intpratica" + + intPraticaId); + IntPraticaServiceUtil.cambiaTitolare(intPraticaId, user.getUserId(), serviceContext); + SessionMessages.add(actionRequest, "success-cambio-titolare"); + } else { + SessionErrors.add(actionRequest, "error-cambio-titolare-pratica-in-progress"); + } + } else { + _log.error("[FASCICOLO ACTION - CAMBIO TITOLARE] Nessun utente trovato con company " + + companyId + " e codice fiscale " + nuovoSoggettoCF); + SessionErrors.add(actionRequest, "error-cambio-titolare-no-such-user"); + } + } catch (PortalException | SystemException e) { + _log.error("error-cambio-titolare", e); + SessionErrors.add(actionRequest, "error-cambio-titolare"); + } + + } + + public void searchURL(ActionRequest actionRequest, ActionResponse actionResponse) { + + String numeroProgetto = actionRequest.getParameter("numeroProgetto"); + String protocollo = actionRequest.getParameter("protocollo"); + String tipoPratica = actionRequest.getParameter("tipoPratica"); + String statoPratica = actionRequest.getParameter("statoPratica"); + String committente = actionRequest.getParameter("committente"); + String descInterventoSearch = actionRequest.getParameter("descIntervento"); + String tecnicoIstruttore = actionRequest.getParameter("tecnicoIstruttore"); + String titolareDigitale = actionRequest.getParameter("titolareDigitale"); + String soggettiInterconnessi = actionRequest.getParameter("soggettiInterconnessi"); + String dataRichiestaInizio = actionRequest.getParameter("dataRichiestaInizio"); + String dataRichiestaFine = actionRequest.getParameter("dataRichiestaFine"); + String provincia = actionRequest.getParameter("provincia"); + String praticaAperta = actionRequest.getParameter("praticaAperta"); + String comune = actionRequest.getParameter("comune"); + String tipoIntervento = actionRequest.getParameter("tipoIntervento"); + String indirizzo = actionRequest.getParameter("indirizzo"); + + if (dataRichiestaInizio != null && !dataRichiestaInizio.equals("")) { + String[] dataRichiestaInizioSplitted = dataRichiestaInizio.split("/"); + + int mounth = Integer.valueOf(dataRichiestaInizioSplitted[1]) - 1; + + actionResponse.setRenderParameter("dataRichiestaInizioDay", dataRichiestaInizioSplitted[0]); + actionResponse.setRenderParameter("dataRichiestaInizioMonth", mounth + ""); + actionResponse.setRenderParameter("dataRichiestaInizioYear", dataRichiestaInizioSplitted[2]); + } + + if (dataRichiestaFine != null && !dataRichiestaFine.equals("")) { + String[] dataRichiestaFineSplitted = dataRichiestaFine.split("/"); + + int mounth = Integer.valueOf(dataRichiestaFineSplitted[1]) - 1; + + actionResponse.setRenderParameter("dataRichiestaFineDay", dataRichiestaFineSplitted[0]); + actionResponse.setRenderParameter("dataRichiestaFineMonth", mounth + ""); + actionResponse.setRenderParameter("dataRichiestaFineYear", dataRichiestaFineSplitted[2]); + } + + String ufficio = actionRequest.getParameter("ufficio"); + String ordinaPer = actionRequest.getParameter("ordinaPer"); + String ordinaTipo = actionRequest.getParameter("ordinaTipo"); + + if (tipoIntervento != null && !tipoIntervento.equals("")) { + actionResponse.setRenderParameter("tipoIntervento", tipoIntervento); + } + + actionResponse.setRenderParameter("numeroProgetto", numeroProgetto); + actionResponse.setRenderParameter("praticaAperta", praticaAperta); + actionResponse.setRenderParameter("descIntervento", descInterventoSearch); + actionResponse.setRenderParameter("protocollo", protocollo); + actionResponse.setRenderParameter("tipoPratica", tipoPratica); + actionResponse.setRenderParameter("tipoPratica", tipoPratica); + actionResponse.setRenderParameter("statoPratica", statoPratica); + actionResponse.setRenderParameter("committente", committente); + + if (provincia != null && !provincia.equals("")) { + actionResponse.setRenderParameter("provincia", provincia); + } + + if (comune != null && !comune.equals("")) { + actionResponse.setRenderParameter("comune", comune); + } + + actionResponse.setRenderParameter("indirizzo", indirizzo); + + if (tecnicoIstruttore != null && !tecnicoIstruttore.equals("")) { + actionResponse.setRenderParameter("tecnicoIstruttore", tecnicoIstruttore); + } else { + actionResponse.setRenderParameter("tecnicoIstruttore", StringPool.BLANK); + } + + actionResponse.setRenderParameter("titolareDigitale", titolareDigitale); + actionResponse.setRenderParameter("soggettiInterconnessi", soggettiInterconnessi); + actionResponse.setRenderParameter("dataRichiestaInizio", dataRichiestaInizio); + actionResponse.setRenderParameter("dataRichiestaFine", dataRichiestaFine); + + if (ufficio != null && !ufficio.equals("")) { + actionResponse.setRenderParameter("ufficio", ufficio); + } else { + actionResponse.setRenderParameter("ufficio", -1 + ""); + } + + actionResponse.setRenderParameter("ordinaPer", ordinaPer); + actionResponse.setRenderParameter("ordinaTipo", ordinaTipo); + + } + + public void versiona(ActionRequest actionRequest, ActionResponse actionResponse) { + + long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId", 0); + long companyId = ParamUtil.getLong(actionRequest, "companyId"); + + try { + DettPraticaServiceUtil.sendToVersioning(dettPraticaId, companyId); + } catch (Exception e) { + _log.error("error-versioning", e); + SessionErrors.add(actionRequest, "error-versioning"); + } + + PortalUtil.copyRequestParameters(actionRequest, actionResponse); + + } + + @Override + public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) + throws IOException, PortletException { + + String id = resourceRequest.getResourceID(); + ServiceContext serviceContext; + try { + serviceContext = ServiceContextFactory.getInstance(resourceRequest); + if ("downloadAllDocPratica".equals(id)) { + + long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId"); + long classPk = ParamUtil.getLong(resourceRequest, "classPk"); + String comingFrom = ParamUtil.getString(resourceRequest, "comingFrom"); + List docs = new ArrayList<>(); + if (Validator.isNull(comingFrom)) { + docs = DocPraticaLocalServiceUtil.findByClassPk(classPk); + } else { + List tipologieAllegati = new ArrayList(); + if ("page_geologica".equals(comingFrom)) { + tipologieAllegati = DocumentiPraticaUtil.getDocGeologo(); + } else if ("page_allegati".equals(comingFrom)) { + tipologieAllegati = DocumentiPraticaUtil.getDocDomanda(); + IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(intPraticaId); + if (Validator.isNotNull(intPratica.getOldIntPraticaId())) { + tipologieAllegati.addAll(0, DocumentiPraticaUtil.getDocDomandaPortos1()); + } + } else if ("page_fine_lavori".equals(comingFrom)) { + tipologieAllegati = DocumentiPraticaUtil.getDocFineLavori(); + } else if ("page_collaudo".equals(comingFrom)) { + tipologieAllegati = DocumentiPraticaUtil.getDocCollaudo(); + } + docs = DocPraticaLocalServiceUtil.findByIntPratica_ClassPk_Tipologie(intPraticaId, + classPk, tipologieAllegati); + } + + ZipWriter zipWriter = ZipWriterFactoryUtil.getZipWriter(); + + for (DocPratica doc : docs) { + + InputStream inputStream = null; + try { + if (Validator.isNull(doc.getDlFileEntryId())) { + continue; + } + FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(doc.getDlFileEntryId()); + inputStream = DLFileEntryLocalServiceUtil.getFileAsStream(fileEntry.getFileEntryId(), + fileEntry.getVersion(), false); + + // String name = fileEntry.getTitle() + + // StringPool.PERIOD + fileEntry.getExtension(); + String name = fileEntry.getTitle(); + zipWriter.addEntry(name, inputStream); + } finally { + StreamUtil.cleanUp(inputStream); + } + } + + resourceResponse.reset(); + + File file = zipWriter.getFile(); + byte[] data = Files.readAllBytes(file.toPath()); + + resourceResponse.setContentType(ContentTypes.APPLICATION_ZIP); + resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate"); + resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + + file.getName() + "\""); + resourceResponse.setContentLength(data.length); + + resourceResponse.getPortletOutputStream().write(data); + resourceResponse.getPortletOutputStream().flush(); + resourceResponse.getPortletOutputStream().close(); + + } else if ("importFile".equals(id)) { + + long classPk = ParamUtil.getLong(resourceRequest, "classPk"); + String className = ParamUtil.getString(resourceRequest, "className"); + + FilesImporter.importaFile(classPk, className); + + // if (DocPratica.class.getName().equalsIgnoreCase(className)) { + // DocPratica docPratica = + // DocPraticaLocalServiceUtil.getDocPratica(classPk); + // if (docPratica.getDlFileEntryId() == 0L && + // docPratica.getOldDlFileEntryId() != 0L) { + // FilesImporter.handleFileImportDocPratica(docPratica); + // } + // } else if + // (Avviso.class.getName().equalsIgnoreCase(className)) { + // Avviso avviso = AvvisoLocalServiceUtil.getAvviso(classPk); + // if (avviso.getFileEntryIdBase() == 0L && + // avviso.getOldFileEntryIdBase() != 0L) { + // FilesImporter.handleFileImportAvviso(avviso, true); + // } + // if (avviso.getFileEntryIdInvio() == 0L && + // avviso.getOldFileEntryIdInvio() != 0L) { + // FilesImporter.handleFileImportAvviso(avviso, false); + // } + // } else if + // (Pagamento.class.getName().equalsIgnoreCase(className)) { + // Pagamento pagamento = + // PagamentoLocalServiceUtil.getPagamento(classPk); + // if (pagamento.getFileEntryId() == 0L && + // pagamento.getOldFileEntryId() != 0L) { + // FilesImporter.handleFileImportPagamento(pagamento); + // } + // } else if + // (DocAggiuntiva.class.getName().equalsIgnoreCase(className)) { + // DocAggiuntiva docAggiuntiva = + // DocAggiuntivaLocalServiceUtil.getDocAggiuntiva(classPk); + // if (docAggiuntiva.getFileEntryId() == 0L && + // docAggiuntiva.getOldFileEntryId() != 0L) { + // FilesImporter.handleFileImportDocAggiuntiva(docAggiuntiva); + // } + // } else if + // (AllegatoManuale.class.getName().equalsIgnoreCase(className)) + // { + // AllegatoManuale allegatoManuale = + // AllegatoManualeLocalServiceUtil.getAllegatoManuale(classPk); + // if (allegatoManuale.getFileEntryId() == 0L && + // allegatoManuale.getOldFileEntryId() != 0L) + // { + // FilesImporter.handleFileImportAllegatoManuale(allegatoManuale); + // } + // } + + PortletResponseUtil + .write(resourceResponse, + "

Completato

Refresh"); + + } 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 listaDet = DettPraticaLocalServiceUtil.findByIntPraticaId(intPraticaId); + for (DettPratica dettPratica : listaDet) { + FilesImporter.importaFilesFascicolo(dettPratica.getDettPraticaId(), + DettPratica.class.getName()); + } + + List listaFine = FineLavoriLocalServiceUtil.findByIntPraticaId(intPraticaId, -1, + -1, null); + for (FineLavori fineLavori : listaFine) { + FilesImporter.importaFilesFascicolo(fineLavori.getFineLavoriId(), + FineLavori.class.getName()); + } + + List 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, + "

Completato

Refresh"); + } else if ("comuni".equals(id)) { + String provinciaId = ParamUtil.getString(resourceRequest, "provinciaId"); + JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); + if (Validator.isNotNull(provinciaId) && !provinciaId.equals("0")) { + List comuniIds = TerritorioLocalServiceUtil + .getActiveComuniByCodiceProvincia(provinciaId); + + // ADT BUG-ID=15 Sezione Ricerca / Ordinamento Filtro + List comumeList = new ArrayList(); + for (long comuneId : comuniIds) { + Comune comune = ComuneLocalServiceUtil.getComune(comuneId); + comumeList.add(comune); + } + + Collections.sort(comumeList, new Comparator() { + @Override + public int compare(Comune o1, Comune o2) { + return o1.getDenominazione().compareTo(o2.getDenominazione()); + } + }); + + for (Comune comune : comumeList) { + JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); + jsonObject.put("comuneId", comune.getComuneId()); + jsonObject.put("descLong", comune.getDenominazione()); + + jsonArray.put(jsonObject); + } + } + writeJSON(resourceRequest, resourceResponse, jsonArray); + + } else if ("exportRicerca".equals(id)) { + + ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest + .getAttribute(WebKeys.THEME_DISPLAY); + Locale locale = themeDisplay.getLocale(); + + User user = themeDisplay.getUser(); + + String csv = StringPool.BLANK; + + HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest); + HttpServletResponse response = PortalUtil.getHttpServletResponse(resourceResponse); + + csv = exportSearch(locale, resourceRequest, user); + + ServletResponseUtil.sendFile(request, response, "export_ricerca.csv", + csv.getBytes(StringPool.UTF8), ContentTypes.TEXT_CSV_UTF8); + + } else { + super.serveResource(resourceRequest, resourceResponse); + } + } catch (Exception e) { + _log.error(e, e); + throw new IOException(e); + } + + } + + private String exportSearch(Locale locale, ResourceRequest resourceRequest, User user) { + String method = "exportSearch"; + + HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(resourceRequest); + StringBuilder sb = new StringBuilder(); + + List lista = new ArrayList(); + + // try { + + Hits hits = IntPraticaAdvancedSearch.searchProgettiBO(httpRequest, user, -1, -1); + + for (Document doc : hits.toList()) { + String intPraticaId = doc.get("intPraticaId"); + try { + if (Validator.isNotNull(intPraticaId)) { + IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(GetterUtil + .getLong(intPraticaId)); + if (Validator.isNotNull(intPratica)) { + lista.add(intPratica); + } + } + } catch (Throwable e) { + _log.error(method + " IntPraticaLocalServiceUtil.fetchIntPratica IntPraticaId: " + + intPraticaId, e); + } + } + + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.sorteggiata"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.pratica"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.titolare"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.committenti"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.istruttore"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.statoPratica"))); + sb.append(StringPool.SEMICOLON); + + // ADT BUG-ID=15 Sezione Ricerca / Export csv + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.provincia"))); + sb.append(StringPool.SEMICOLON); + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.comune"))); + sb.append(StringPool.SEMICOLON); + + sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, + "label.scadenzegeniocivile.descrizioneIntervento"))); + sb.append(StringPool.SEMICOLON); + + sb.append(StringPool.NEW_LINE); + + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); + + for (IntPratica intPratica : lista) { + + try { + DettPratica lastDettPratica = DettPraticaLocalServiceUtil + .getLastCompletedByIntPratica(intPratica.getIntPraticaId()); + + Territorio territorio = TerritorioLocalServiceUtil.fetchTerritorio(intPratica + .getTerritorioId()); + Comune comune = ComuneLocalServiceUtil.fetchComune(territorio.getComuneId()); + + Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(), + territorio.getCodiceProvincia()); + + boolean sorteggiata = SorteggioLocalServiceUtil + .findByIntPratica(intPratica.getIntPraticaId()) != null; + sb.append(CSVUtil.encode((sorteggiata) ? "Si" : "No")); + sb.append(StringPool.SEMICOLON); + + String praticaLabel = intPratica.getTitle(locale, true); + sb.append(CSVUtil.encode(praticaLabel)); + sb.append(StringPool.SEMICOLON); + + User titolareUser = UserLocalServiceUtil.getUserById(intPratica.getUserId()); + List titolari = SoggettoLocalServiceUtil.getValidByIntPratica_CodiceFiscale( + lastDettPratica.getIntPraticaId(), + lastDettPratica.getCodiceFiscaleDelegatoCommittente()); Soggetto titolare = null; - if(!titolari.isEmpty()){ - titolare = titolari.get(0); + if (!titolari.isEmpty()) { + titolare = titolari.get(0); } - if(titolare != null){ - sb.append(titolare.getTitle()+ " - " +titolare.getCodiceFiscale()); + if (titolare != null) { + sb.append(titolare.getTitle() + " - " + titolare.getCodiceFiscale()); } else { sb.append(""); } - sb.append(StringPool.SEMICOLON); - - - StringBuilder builder = new StringBuilder(); - - List committenti = SoggettoLocalServiceUtil.findByIntPratica_TipologiaSoggetto(lastDettPratica.getIntPraticaId(), TipoSoggettoUtil.COMMITTENTE); - for(Soggetto committente : committenti){ - builder.append(committente.getTitle()+" - "+committente.getCodiceFiscale()) - .append(StringPool.COMMA_AND_SPACE); + sb.append(StringPool.SEMICOLON); + + StringBuilder builder = new StringBuilder(); + + List committenti = SoggettoLocalServiceUtil.findByIntPratica_TipologiaSoggetto( + lastDettPratica.getIntPraticaId(), TipoSoggettoUtil.COMMITTENTE); + for (Soggetto committente : committenti) { + builder.append(committente.getTitle() + " - " + committente.getCodiceFiscale()).append( + StringPool.COMMA_AND_SPACE); } - if(builder.length()>0) - builder.setLength(builder.length()-12); - + if (builder.length() > 0) + builder.setLength(builder.length() - 12); + sb.append(builder.toString()); - sb.append(StringPool.SEMICOLON); - - User istruttore = UserLocalServiceUtil.fetchUser(intPratica.getStatusByUserId()); - if(istruttore!=null){ + sb.append(StringPool.SEMICOLON); + + User istruttore = UserLocalServiceUtil.fetchUser(intPratica.getStatusByUserId()); + if (istruttore != null) { sb.append(istruttore.getFullName()); } else { - sb.append(""); + sb.append(""); } - sb.append(StringPool.SEMICOLON); - - sb.append(LanguageUtil.get(locale, PraticaUtil.getStatoPraticaLabel(intPratica.getStatoPratica(), intPratica))); - sb.append(StringPool.SEMICOLON); - - //ADT BUG-ID=15 Sezione Ricerca / Export csv - sb.append(provincia != null ? provincia.getProvincia() : ""); - sb.append(StringPool.SEMICOLON); - sb.append(comune != null ? comune.getDenominazione() : ""); - sb.append(StringPool.SEMICOLON); - - // sb.append("Territorio: " ).append(comune.getDenominazione()).append(!lastDettPratica.getLocalita().isEmpty() ? "(Loc. "+lastDettPratica.getLocalita()+" ) " : "").append(" - ").append(provincia.getProvincia()); - //ADT BUG-ID=15 Sezione Ricerca / Export csv - Max 30 chars - int MAX_LENGHT_DESCR_INTERVENTO = 30; - sb.append(lastDettPratica.getDescLongIntervento() == null ? "": lastDettPratica.getDescLongIntervento().length() > MAX_LENGHT_DESCR_INTERVENTO ? lastDettPratica.getDescLongIntervento().substring(0, MAX_LENGHT_DESCR_INTERVENTO) : lastDettPratica.getDescLongIntervento()); - sb.append(StringPool.SEMICOLON); - - // Territorio: <%= comune.getDenominazione() %> <%= !lastDettPratica.getLocalita().isEmpty() ? "(Loc. "+lastDettPratica.getLocalita()+" ) " : "" %>- <%= provincia.getProvincia() %>
- // Localizzazione: <%= lastDettPratica.getVia() %>

- // <%= lastDettPratica.getDescLongIntervento() %> - } catch(Throwable e){ - _log.error(method + " IntPraticaId: " + intPratica != null ? intPratica.getIntPraticaId() : "", e); - } finally{ - sb.append(StringPool.NEW_LINE); - } - } - -// } catch (PortalException e) { -// _log.error(e, e); -// } catch (SystemException e) { -// _log.error(e, e); -// } - - return sb.toString(); - - } + sb.append(StringPool.SEMICOLON); + + sb.append(LanguageUtil.get(locale, + PraticaUtil.getStatoPraticaLabel(intPratica.getStatoPratica(), intPratica))); + sb.append(StringPool.SEMICOLON); + + // ADT BUG-ID=15 Sezione Ricerca / Export csv + sb.append(provincia != null ? provincia.getProvincia() : ""); + sb.append(StringPool.SEMICOLON); + sb.append(comune != null ? comune.getDenominazione() : ""); + sb.append(StringPool.SEMICOLON); + + // sb.append("Territorio: " + // ).append(comune.getDenominazione()).append(!lastDettPratica.getLocalita().isEmpty() + // ? "(Loc. "+lastDettPratica.getLocalita()+" ) " : + // "").append(" - ").append(provincia.getProvincia()); + // ADT BUG-ID=15 Sezione Ricerca / Export csv - Max 30 chars + int MAX_LENGHT_DESCR_INTERVENTO = 30; + sb.append(lastDettPratica.getDescLongIntervento() == null ? "" : lastDettPratica + .getDescLongIntervento().length() > MAX_LENGHT_DESCR_INTERVENTO ? lastDettPratica + .getDescLongIntervento().substring(0, MAX_LENGHT_DESCR_INTERVENTO) : lastDettPratica + .getDescLongIntervento()); + sb.append(StringPool.SEMICOLON); + + // Territorio: <%= comune.getDenominazione() %> <%= + // !lastDettPratica.getLocalita().isEmpty() ? + // "(Loc. "+lastDettPratica.getLocalita()+" ) " : "" %>- <%= + // provincia.getProvincia() %>
+ // Localizzazione: <%= lastDettPratica.getVia() + // %>

+ // <%= lastDettPratica.getDescLongIntervento() %> + } catch (Throwable e) { + _log.error(method + " IntPraticaId: " + intPratica != null ? intPratica.getIntPraticaId() + : "", e); + } finally { + sb.append(StringPool.NEW_LINE); + } + } + + // } catch (PortalException e) { + // _log.error(e, e); + // } catch (SystemException e) { + // _log.error(e, e); + // } + + return sb.toString(); + + } } diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/DettPraticaServiceImpl.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/DettPraticaServiceImpl.java index efb23de0..736c17d7 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/DettPraticaServiceImpl.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/DettPraticaServiceImpl.java @@ -480,8 +480,7 @@ public class DettPraticaServiceImpl extends DettPraticaServiceBaseImpl { } - public void sendToVersioning(long dettPraticaId, long companyId) throws PortalException, SystemException, - NoSuchFieldException, SecurityException, IOException { + public void sendToVersioning(long dettPraticaId, long companyId) throws Exception { Company company = CompanyLocalServiceUtil.getCompany(companyId); String commitURL = (String) company.getExpandoBridge().getAttribute( diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties index e65e63dc..e0143c66 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties @@ -13,8 +13,8 @@ ## build.namespace=portos_bo - build.number=2409 - build.date=1600356327380 + build.number=2413 + build.date=1600421442524 build.auto.upgrade=true ## diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/tld/c.tld b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/tld/c.tld deleted file mode 100644 index 98efa6a6..00000000 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/tld/c.tld +++ /dev/null @@ -1,572 +0,0 @@ - - - - - JSTL 1.2 core library - JSTL core - 1.2 - c - http://java.sun.com/jsp/jstl/core - - - - Provides core validation features for JSTL tags. - - - org.apache.taglibs.standard.tlv.JstlCoreTLV - - - - - - Catches any Throwable that occurs in its body and optionally - exposes it. - - catch - org.apache.taglibs.standard.tag.common.core.CatchTag - JSP - - -Name of the exported scoped variable for the -exception thrown from a nested action. The type of the -scoped variable is the type of the exception thrown. - - var - false - false - - - - - - Simple conditional tag that establishes a context for - mutually exclusive conditional operations, marked by - <when> and <otherwise> - - choose - com.liferay.taglib.core.ChooseTag - JSP - - - - - Simple conditional tag, which evalutes its body if the - supplied condition is true and optionally exposes a Boolean - scripting variable representing the evaluation of this condition - - if - com.liferay.taglib.core.IfTag - JSP - - -The test condition that determines whether or -not the body content should be processed. - - test - true - true - boolean - - - -Name of the exported scoped variable for the -resulting value of the test condition. The type -of the scoped variable is Boolean. - - var - false - false - - - -Scope for var. - - scope - false - false - - - - - - Retrieves an absolute or relative URL and exposes its contents - to either the page, a String in 'var', or a Reader in 'varReader'. - - import - org.apache.taglibs.standard.tag.rt.core.ImportTag - org.apache.taglibs.standard.tei.ImportTEI - JSP - - -The URL of the resource to import. - - url - true - true - - - -Name of the exported scoped variable for the -resource's content. The type of the scoped -variable is String. - - var - false - false - - - -Scope for var. - - scope - false - false - - - -Name of the exported scoped variable for the -resource's content. The type of the scoped -variable is Reader. - - varReader - false - false - - - -Name of the context when accessing a relative -URL resource that belongs to a foreign -context. - - context - false - true - - - -Character encoding of the content at the input -resource. - - charEncoding - false - true - - - - - - The basic iteration tag, accepting many different - collection types and supporting subsetting and other - functionality - - forEach - org.apache.taglibs.standard.tag.rt.core.ForEachTag - org.apache.taglibs.standard.tei.ForEachTEI - JSP - - -Collection of items to iterate over. - - items - false - true - java.lang.Object - - java.lang.Object - - - - -If items specified: -Iteration begins at the item located at the -specified index. First item of the collection has -index 0. -If items not specified: -Iteration begins with index set at the value -specified. - - begin - false - true - int - - - -If items specified: -Iteration ends at the item located at the -specified index (inclusive). -If items not specified: -Iteration ends when index reaches the value -specified. - - end - false - true - int - - - -Iteration will only process every step items of -the collection, starting with the first one. - - step - false - true - int - - - -Name of the exported scoped variable for the -current item of the iteration. This scoped -variable has nested visibility. Its type depends -on the object of the underlying collection. - - var - false - false - - - -Name of the exported scoped variable for the -status of the iteration. Object exported is of type -javax.servlet.jsp.jstl.core.LoopTagStatus. This scoped variable has nested -visibility. - - varStatus - false - false - - - - - - Iterates over tokens, separated by the supplied delimeters - - forTokens - org.apache.taglibs.standard.tag.rt.core.ForTokensTag - JSP - - -String of tokens to iterate over. - - items - true - true - java.lang.String - - java.lang.String - - - - -The set of delimiters (the characters that -separate the tokens in the string). - - delims - true - true - java.lang.String - - - -Iteration begins at the token located at the -specified index. First token has index 0. - - begin - false - true - int - - - -Iteration ends at the token located at the -specified index (inclusive). - - end - false - true - int - - - -Iteration will only process every step tokens -of the string, starting with the first one. - - step - false - true - int - - - -Name of the exported scoped variable for the -current item of the iteration. This scoped -variable has nested visibility. - - var - false - false - - - -Name of the exported scoped variable for the -status of the iteration. Object exported is of -type -javax.servlet.jsp.jstl.core.LoopTag -Status. This scoped variable has nested -visibility. - - varStatus - false - false - - - - - - Like <%= ... >, but for expressions. - - out - org.apache.taglibs.standard.tag.rt.core.OutTag - JSP - - -Expression to be evaluated. - - value - true - true - - - -Default value if the resulting value is null. - - default - false - true - - - -Determines whether characters <,>,&,'," in the -resulting string should be converted to their -corresponding character entity codes. Default value is -true. - - escapeXml - false - true - - - - - - - Subtag of <choose> that follows <when> tags - and runs only if all of the prior conditions evaluated to - 'false' - - otherwise - com.liferay.taglib.core.OtherwiseTag - JSP - - - - - Adds a parameter to a containing 'import' tag's URL. - - param - org.apache.taglibs.standard.tag.rt.core.ParamTag - JSP - - -Name of the query string parameter. - - name - true - true - - - -Value of the parameter. - - value - false - true - - - - - - Redirects to a new URL. - - redirect - org.apache.taglibs.standard.tag.rt.core.RedirectTag - JSP - - -The URL of the resource to redirect to. - - url - false - true - - - -Name of the context when redirecting to a relative URL -resource that belongs to a foreign context. - - context - false - true - - - - - - Removes a scoped variable (from a particular scope, if specified). - - remove - org.apache.taglibs.standard.tag.common.core.RemoveTag - empty - - -Name of the scoped variable to be removed. - - var - true - false - - - -Scope for var. - - scope - false - false - - - - - - Sets the result of an expression evaluation in a 'scope' - - set - org.apache.taglibs.standard.tag.rt.core.SetTag - JSP - - -Name of the exported scoped variable to hold the value -specified in the action. The type of the scoped variable is -whatever type the value expression evaluates to. - - var - false - false - - - -Expression to be evaluated. - - value - false - true - - java.lang.Object - - - - -Target object whose property will be set. Must evaluate to -a JavaBeans object with setter property property, or to a -java.util.Map object. - - target - false - true - - - -Name of the property to be set in the target object. - - property - false - true - - - -Scope for var. - - scope - false - false - - - - - - Creates a URL with optional query parameters. - - url - org.apache.taglibs.standard.tag.rt.core.UrlTag - JSP - - -Name of the exported scoped variable for the -processed url. The type of the scoped variable is -String. - - var - false - false - - - -Scope for var. - - scope - false - false - - - -URL to be processed. - - value - false - true - - - -Name of the context when specifying a relative URL -resource that belongs to a foreign context. - - context - false - true - - - - - - Subtag of <choose> that includes its body if its - condition evalutes to 'true' - - when - com.liferay.taglib.core.WhenTag - JSP - - -The test condition that determines whether or not the -body content should be processed. - - test - true - true - boolean - - - -