Sfoglia il codice sorgente

Merge branch 'master' of 149.202.172.180:/home/mattia/sicilia/sources

master
Mattia MWG 4 anni fa
parent
commit
80378beb79
  1. 4
      liferay-plugins-sdk-6.2/build.portos.properties
  2. BIN
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpclient.jar
  3. BIN
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpcore-4.4.6.jar
  4. BIN
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpcore.jar
  5. BIN
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpmime-4.5.3.jar
  6. BIN
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpmime.jar
  7. 11
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/liferay-plugin-package.properties
  8. 81
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/mwg/sismica/bo/util/HttpServiceUtil.java
  9. 5
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaLocalService.java
  10. 25
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaLocalServiceClp.java
  11. 5
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaLocalServiceUtil.java
  12. 5
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaLocalServiceWrapper.java
  13. 5
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaService.java
  14. 25
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaServiceClp.java
  15. 5
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaServiceUtil.java
  16. 5
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/service/DettPraticaServiceWrapper.java
  17. 86
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/ProtocolloUtil.java
  18. 44
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/ValidazionePraticaUtil.java
  19. 166
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/PuliziaDatabase.java
  20. 282
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/FascicoloPortlet.java
  21. 57
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/scheduler/SchedulerEstrazioneFirme.java
  22. 26
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/DettPraticaLocalServiceImpl.java
  23. 3
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/DettPraticaServiceImpl.java
  24. 130
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/util/ProtocollazioneUtil.java
  25. 4
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties
  26. BIN
      liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/lib/httpclient.jar
  27. BIN
      liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/lib/httpcore.jar
  28. BIN
      liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/lib/httpmime.jar

4
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.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.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 app.server.parent.dir = /home/portos/bin/liferay-portal-6.2-ce-ga6

BIN
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpclient.jar

File binario non mostrato.

BIN
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpcore-4.4.6.jar

File binario non mostrato.

BIN
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpcore.jar

File binario non mostrato.

BIN
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpmime-4.5.3.jar

File binario non mostrato.

BIN
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpmime.jar

File binario non mostrato.

11
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 licenses=LGPL
liferay-versions=6.2.0+ liferay-versions=6.2.0+
portal-dependency-jars=\ portal-dependency-jars=\
axis.jar,\
commons-discovery.jar,\
httpclient.jar,\
jaxrpc.jar,\
jstl-api.jar,\ jstl-api.jar,\
jstl-impl.jar,\ jstl-impl.jar,\
jaxrpc.jar,\ util-java.jar,\
commons-discovery.jar,\
wsdl4j.jar,\ wsdl4j.jar,\
axis.jar,\ xml-apis.jar
xml-apis.jar,\
httpclient.jar
portal-dependency-tlds=\ portal-dependency-tlds=\
c.tld c.tld
required-deployment-contexts=\ required-deployment-contexts=\

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

@ -0,0 +1,81 @@
package it.mwg.sismica.bo.util;
import it.tref.liferay.portos.bo.service.ConfigurazioneLocalServiceUtil;
import it.tref.liferay.portos.bo.shared.protocollo.model.Protocollo;
import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants;
import javax.servlet.http.HttpServletResponse;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.json.JSONFactoryUtil;
import com.liferay.portal.kernel.json.JSONObject;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.ContentTypes;
import com.liferay.portal.kernel.util.HttpUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.Http.Options;
public class HttpServiceUtil {
private static final Log _log = LogFactoryUtil.getLog(HttpServiceUtil.class);
public static JSONObject postProtocolloBean(long companyId, Protocollo protocolloBean) throws Exception {
flexjson.JSONSerializer serializer = new flexjson.JSONSerializer();
serializer.exclude("*.class");
String json = serializer.serialize(protocolloBean);
String url = ConfigurazioneLocalServiceUtil.findByC_ChiaveString(companyId,
ConfigurazioneConstants.PROTOCOLLAZIONE_SERVICE_URL);
return postJson(url, json);
}
public static JSONObject postJson(String url, String json) throws Exception {
JSONObject risposta = null;
HttpPost request = new HttpPost(url);
request.setHeader("Content-type", ContentTypes.APPLICATION_JSON);
request.setEntity(new StringEntity(json));
CloseableHttpClient client = HttpClientBuilder.create().build();
HttpResponse response = client.execute(request);
int statusCode = response.getStatusLine().getStatusCode();
String responseBody = EntityUtils.toString(response.getEntity(), StringPool.UTF8);
client.close();
if (statusCode == HttpServletResponse.SC_OK || statusCode == HttpServletResponse.SC_CREATED) {
risposta = JSONFactoryUtil.createJSONObject(responseBody);
_log.info(url + " || " + json + " || " + risposta);
} else {
_log.info(url + " || " + json + " || " + statusCode + ": " + responseBody);
throw new PortalException(statusCode + StringPool.SPACE + responseBody);
}
return risposta;
}
public static String getUrl(String url) throws Exception {
return getUrl(url, StringPool.BLANK);
}
public static String getUrl(String url, String defaultValue) throws Exception {
Options options = new Options();
options.setLocation(url);
options.setPost(false);
String responseBody = HttpUtil.URLtoString(options);
_log.info(url + " || " + responseBody);
if (options.getResponse().getResponseCode() != HttpServletResponse.SC_OK) {
throw new Exception(url + ": " + options.getResponse().getResponseCode());
// responseBody = defaultValue;
}
return responseBody;
}
}

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

@ -849,10 +849,7 @@ public interface DettPraticaLocalService extends BaseLocalService,
com.liferay.portal.kernel.exception.SystemException; com.liferay.portal.kernel.exception.SystemException;
public void sendToVersioning(long dettPraticaId, java.lang.String url) public void sendToVersioning(long dettPraticaId, java.lang.String url)
throws com.liferay.portal.kernel.exception.PortalException, throws java.lang.Exception;
com.liferay.portal.kernel.exception.SystemException,
java.io.IOException, java.lang.NoSuchFieldException,
java.lang.SecurityException;
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public int getNumeroDiVersioni(java.lang.String url) public int getNumeroDiVersioni(java.lang.String url)

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

@ -4200,10 +4200,7 @@ public class DettPraticaLocalServiceClp implements DettPraticaLocalService {
@Override @Override
public void sendToVersioning(long dettPraticaId, java.lang.String url) public void sendToVersioning(long dettPraticaId, java.lang.String url)
throws com.liferay.portal.kernel.exception.PortalException, throws java.lang.Exception {
com.liferay.portal.kernel.exception.SystemException,
java.io.IOException, java.lang.NoSuchFieldException,
java.lang.SecurityException {
try { try {
_invokableLocalService.invokeMethod(_methodName77, _invokableLocalService.invokeMethod(_methodName77,
_methodParameterTypes77, _methodParameterTypes77,
@ -4212,24 +4209,8 @@ public class DettPraticaLocalServiceClp implements DettPraticaLocalService {
catch (Throwable t) { catch (Throwable t) {
t = ClpSerializer.translateThrowable(t); t = ClpSerializer.translateThrowable(t);
if (t instanceof com.liferay.portal.kernel.exception.PortalException) { if (t instanceof java.lang.Exception) {
throw (com.liferay.portal.kernel.exception.PortalException)t; throw (java.lang.Exception)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 RuntimeException) { if (t instanceof RuntimeException) {

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

@ -1149,10 +1149,7 @@ public class DettPraticaLocalServiceUtil {
} }
public static void sendToVersioning(long dettPraticaId, java.lang.String url) public static void sendToVersioning(long dettPraticaId, java.lang.String url)
throws com.liferay.portal.kernel.exception.PortalException, throws java.lang.Exception {
com.liferay.portal.kernel.exception.SystemException,
java.io.IOException, java.lang.NoSuchFieldException,
java.lang.SecurityException {
getService().sendToVersioning(dettPraticaId, url); getService().sendToVersioning(dettPraticaId, url);
} }

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

@ -1218,10 +1218,7 @@ public class DettPraticaLocalServiceWrapper implements DettPraticaLocalService,
@Override @Override
public void sendToVersioning(long dettPraticaId, java.lang.String url) public void sendToVersioning(long dettPraticaId, java.lang.String url)
throws com.liferay.portal.kernel.exception.PortalException, throws java.lang.Exception {
com.liferay.portal.kernel.exception.SystemException,
java.io.IOException, java.lang.NoSuchFieldException,
java.lang.SecurityException {
_dettPraticaLocalService.sendToVersioning(dettPraticaId, url); _dettPraticaLocalService.sendToVersioning(dettPraticaId, url);
} }

5
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; java.io.IOException;
public void sendToVersioning(long dettPraticaId, long companyId) public void sendToVersioning(long dettPraticaId, long companyId)
throws com.liferay.portal.kernel.exception.PortalException, throws java.lang.Exception;
com.liferay.portal.kernel.exception.SystemException,
java.io.IOException, java.lang.NoSuchFieldException,
java.lang.SecurityException;
} }

25
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 @Override
public void sendToVersioning(long dettPraticaId, long companyId) public void sendToVersioning(long dettPraticaId, long companyId)
throws com.liferay.portal.kernel.exception.PortalException, throws java.lang.Exception {
com.liferay.portal.kernel.exception.SystemException,
java.io.IOException, java.lang.NoSuchFieldException,
java.lang.SecurityException {
try { try {
_invokableService.invokeMethod(_methodName26, _invokableService.invokeMethod(_methodName26,
_methodParameterTypes26, _methodParameterTypes26,
@ -1752,24 +1749,8 @@ public class DettPraticaServiceClp implements DettPraticaService {
catch (Throwable t) { catch (Throwable t) {
t = ClpSerializer.translateThrowable(t); t = ClpSerializer.translateThrowable(t);
if (t instanceof com.liferay.portal.kernel.exception.PortalException) { if (t instanceof java.lang.Exception) {
throw (com.liferay.portal.kernel.exception.PortalException)t; throw (java.lang.Exception)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 RuntimeException) { if (t instanceof RuntimeException) {

5
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) public static void sendToVersioning(long dettPraticaId, long companyId)
throws com.liferay.portal.kernel.exception.PortalException, throws java.lang.Exception {
com.liferay.portal.kernel.exception.SystemException,
java.io.IOException, java.lang.NoSuchFieldException,
java.lang.SecurityException {
getService().sendToVersioning(dettPraticaId, companyId); getService().sendToVersioning(dettPraticaId, companyId);
} }

5
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 @Override
public void sendToVersioning(long dettPraticaId, long companyId) public void sendToVersioning(long dettPraticaId, long companyId)
throws com.liferay.portal.kernel.exception.PortalException, throws java.lang.Exception {
com.liferay.portal.kernel.exception.SystemException,
java.io.IOException, java.lang.NoSuchFieldException,
java.lang.SecurityException {
_dettPraticaService.sendToVersioning(dettPraticaId, companyId); _dettPraticaService.sendToVersioning(dettPraticaId, companyId);
} }

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

@ -1,43 +1,26 @@
package it.tref.liferay.portos.bo.util; 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.model.Avviso;
import it.tref.liferay.portos.bo.service.AvvisoLocalServiceUtil; 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.File;
import it.tref.liferay.portos.bo.shared.protocollo.model.Protocollo; import it.tref.liferay.portos.bo.shared.protocollo.model.Protocollo;
import it.tref.liferay.portos.bo.shared.protocollo.model.Protocollo.TipoProtocollo; import it.tref.liferay.portos.bo.shared.protocollo.model.Protocollo.TipoProtocollo;
import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants;
import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSONFactoryUtil;
import com.liferay.portal.kernel.json.JSONObject; 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; import com.liferay.portal.kernel.util.Validator;
public class ProtocolloUtil { 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;
InputStream inputStream = null;
try {
File allegato = new File(); File allegato = new File();
@ -48,9 +31,9 @@ public class ProtocolloUtil {
allegato.setFileId("0"); allegato.setFileId("0");
allegato.setFileSha256(sha256); allegato.setFileSha256(sha256);
// utilizzato anche come discriminate tra la 1a e la 2a chiamata // utilizzato anche come discriminate tra la 1a e la 2a chiamata 1a
// 1a recupero numero protocollo -> 1 allegato finto // recupero numero protocollo -> 1 allegato finto 2a aggiorno dati del
// 2a aggiorno dati del documento prodotto -> 2 allegati, il 1o giusto e il 2o per recupero // documento prodotto -> 2 allegati, il 1o giusto e il 2o per recupero
// num protocollo // num protocollo
Protocollo protocolloBean = new Protocollo(); Protocollo protocolloBean = new Protocollo();
@ -61,25 +44,12 @@ public class ProtocolloUtil {
protocolloBean.setUfficioId(String.valueOf(groupId)); protocolloBean.setUfficioId(String.valueOf(groupId));
protocolloBean.setPraticaId(String.valueOf(accessoAttiId)); protocolloBean.setPraticaId(String.valueOf(accessoAttiId));
protocolloBean.setFiles(Collections.singletonList(allegato)); protocolloBean.setFiles(Collections.singletonList(allegato));
Options options = createCall(companyId, protocolloBean, true); JSONObject risposta = HttpServiceUtil.postProtocolloBean(companyId, protocolloBean);
return risposta.getString("anno") + String.format("%07d", risposta.getInt("numero"));
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);
}
} finally {
StreamUtil.cleanUp(inputStream);
} }
return protocollo; public static String protocollaArrivoAccessoAtti(long groupId, long companyId, String userName,
} long accessoAttiId, String className) throws Exception {
public static String protocollaArrivoAccessoAtti(long groupId, long companyId, String userName, long accessoAttiId, String className) throws Exception {
String protocollo = null; String protocollo = null;
@ -100,19 +70,9 @@ public class ProtocolloUtil {
protocolloBean.setPraticaId(String.valueOf(accessoAttiId)); protocolloBean.setPraticaId(String.valueOf(accessoAttiId));
protocolloBean.setFiles(allegati); protocolloBean.setFiles(allegati);
Options options = createCall(companyId, protocolloBean, true);
String responseBody = HttpUtil.URLtoString(options); JSONObject risposta = HttpServiceUtil.postProtocolloBean(companyId, protocolloBean);
if (options.getResponse().getResponseCode() == HttpServletResponse.SC_OK return risposta.getString("anno") + String.format("%07d", risposta.getInt("numero"));
|| 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) { public static String generaOggettoProtocollo(String className, long classPk) {
@ -128,26 +88,4 @@ public class ProtocolloUtil {
return "Oggetto: " + className + " " + classPk; 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;
}
} }

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

@ -19,7 +19,6 @@ import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.IntPraticaServiceUtil; import it.tref.liferay.portos.bo.service.IntPraticaServiceUtil;
import it.tref.liferay.portos.bo.service.SoggettoLocalServiceUtil; import it.tref.liferay.portos.bo.service.SoggettoLocalServiceUtil;
import it.tref.liferay.portos.bo.service.TerritorioLocalServiceUtil; import it.tref.liferay.portos.bo.service.TerritorioLocalServiceUtil;
import it.tref.liferay.portos.bo.service.persistence.AsseverazioneUtil;
import it.tref.liferay.portos.bo.shared.bean.FirmeBean; import it.tref.liferay.portos.bo.shared.bean.FirmeBean;
import it.tref.liferay.portos.bo.shared.util.Constants; import it.tref.liferay.portos.bo.shared.util.Constants;
import it.tref.liferay.portos.bo.shared.util.DocumentiPraticaUtil; import it.tref.liferay.portos.bo.shared.util.DocumentiPraticaUtil;
@ -28,7 +27,6 @@ import it.tref.liferay.portos.bo.shared.util.GenericUtils;
import it.tref.liferay.portos.bo.shared.util.StatoPraticaConstants; import it.tref.liferay.portos.bo.shared.util.StatoPraticaConstants;
import it.tref.liferay.portos.bo.shared.util.TipoIntegrazioneUtil; import it.tref.liferay.portos.bo.shared.util.TipoIntegrazioneUtil;
import it.tref.liferay.portos.bo.shared.util.TipoSoggettoUtil; import it.tref.liferay.portos.bo.shared.util.TipoSoggettoUtil;
import it.tref.liferay.portos.bo.shared.util.Constants;
import it.tref.liferay.portos.bo.util.AsseverazioniUtil; import it.tref.liferay.portos.bo.util.AsseverazioniUtil;
import java.io.IOException; import java.io.IOException;
@ -39,6 +37,15 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.ByteArrayBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import com.liferay.portal.kernel.dao.orm.QueryUtil; import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.kernel.exception.SystemException;
@ -47,10 +54,8 @@ import com.liferay.portal.kernel.json.JSONFactoryUtil;
import com.liferay.portal.kernel.language.LanguageUtil; import com.liferay.portal.kernel.language.LanguageUtil;
import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.Http.FilePart;
import com.liferay.portal.kernel.util.Http.Options;
import com.liferay.portal.kernel.util.HttpUtil;
import com.liferay.portal.kernel.util.LocaleUtil; import com.liferay.portal.kernel.util.LocaleUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.UniqueList; import com.liferay.portal.kernel.util.UniqueList;
import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.workflow.WorkflowConstants; import com.liferay.portal.kernel.workflow.WorkflowConstants;
@ -2476,28 +2481,23 @@ public class ValidazionePraticaUtil {
Company company = CompanyLocalServiceUtil.getCompany(companyId); Company company = CompanyLocalServiceUtil.getCompany(companyId);
String urlPdfExtractor = (String) company.getExpandoBridge().getAttribute("url_pdf_extractor", false); String urlPdfExtractor = (String) company.getExpandoBridge().getAttribute("url_pdf_extractor", false);
Options options = new Options(); HttpPost request = new HttpPost(urlPdfExtractor);
options.setLocation(urlPdfExtractor); MultipartEntityBuilder builder = MultipartEntityBuilder.create();
options.setPost(true); builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
List<FilePart> fileParts = new ArrayList<>(); builder.addPart("file", new ByteArrayBody(fileBytes, fileName));
// TODO perché cazzo non funziona il contentType??? request.setEntity(builder.build());
// FilePart filePart = new FilePart("file", fileName, fileBytes, CloseableHttpClient client = HttpClientBuilder.create().build();
// ContentType.P7M.getContentType(), "UTF-8"); HttpResponse httpResponse = client.execute(request);
FilePart filePart = new FilePart("file", fileName, fileBytes, "application/pkcs7-signature", "UTF-8"); int statusCode = httpResponse.getStatusLine().getStatusCode();
fileParts.add(filePart); String responseBody = EntityUtils.toString(httpResponse.getEntity(), StringPool.UTF8);
options.setFileParts(fileParts); client.close();
String responseBody = HttpUtil.URLtoString(options); if (statusCode == HttpServletResponse.SC_OK || statusCode == HttpServletResponse.SC_CREATED) {
if (options.getResponse().getResponseCode() == HttpServletResponse.SC_OK
|| options.getResponse().getResponseCode() == HttpServletResponse.SC_CREATED) {
JSONArray arrayFirme = JSONFactoryUtil.createJSONObject(responseBody).getJSONArray("cf"); JSONArray arrayFirme = JSONFactoryUtil.createJSONObject(responseBody).getJSONArray("cf");
List<String> cf = new UniqueList<String>(); List<String> cf = new UniqueList<String>();
for (int i = 0; i < arrayFirme.length(); i++) { for (int i = 0; i < arrayFirme.length(); i++) {
cf.add(arrayFirme.getString(i)); cf.add(arrayFirme.getString(i));
} }
return cf; return cf;
} else { } else {

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

@ -5,9 +5,24 @@
*/ */
package it.mwg.sismica.bo.util; package it.mwg.sismica.bo.util;
import it.tref.liferay.portos.bo.model.Collaudo;
import it.tref.liferay.portos.bo.model.ControlloPratica; import it.tref.liferay.portos.bo.model.ControlloPratica;
import it.tref.liferay.portos.bo.model.Delega;
import it.tref.liferay.portos.bo.model.DettPratica; import it.tref.liferay.portos.bo.model.DettPratica;
import it.tref.liferay.portos.bo.model.DocAggiuntiva;
import it.tref.liferay.portos.bo.model.DocPratica;
import it.tref.liferay.portos.bo.model.FineLavori;
import it.tref.liferay.portos.bo.model.IntPratica;
import it.tref.liferay.portos.bo.model.Soggetto;
import it.tref.liferay.portos.bo.service.CollaudoLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DelegaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DocAggiuntivaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.FineLavoriLocalServiceUtil;
import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.SoggettoLocalServiceUtil;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
@ -46,6 +61,8 @@ public class PuliziaDatabase {
public static List<String> pulisci(ServiceContext serviceContext) { public static List<String> pulisci(ServiceContext serviceContext) {
List<String> esito = new ArrayList<>(); List<String> esito = new ArrayList<>();
esito.addAll(puliziaPreliminare());
esito.addAll(puliziaDocumentLibrary()); esito.addAll(puliziaDocumentLibrary());
esito.addAll(svuotaDatabase(serviceContext)); esito.addAll(svuotaDatabase(serviceContext));
@ -60,6 +77,137 @@ public class PuliziaDatabase {
return esito; return esito;
} }
private static List<String> puliziaPreliminare() {
List<String> esito = new ArrayList<>();
try {
Connection connection = DataAccess.getUpgradeOptimizedConnection();
Statement s = connection.createStatement();
int rows = s.executeUpdate("DELETE FROM portos_bo_intpratica WHERE intpraticaid IN ("
+ "SELECT intpraticaid FROM portos_bo_intpratica i "
+ "LEFT JOIN group_ g ON i.groupid=g.groupid WHERE g.groupid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da portos_bo_intpratica");
rows = s.executeUpdate("DELETE FROM portos_bo_dettpratica WHERE dettpraticaid IN ("
+ "SELECT dettpraticaid FROM portos_bo_dettpratica d "
+ "LEFT JOIN portos_bo_intpratica i ON d.intpraticaid=i.intpraticaid "
+ "WHERE i.intpraticaid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da portos_bo_dettpratica");
rows = s.executeUpdate("DELETE FROM portos_bo_controllopratica WHERE controllopraticaid IN ("
+ "SELECT controllopraticaid FROM portos_bo_controllopratica c "
+ "LEFT JOIN portos_bo_intpratica i ON c.intpraticaid=i.intpraticaid "
+ "WHERE i.intpraticaid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da portos_bo_controllopratica");
rows = s.executeUpdate("DELETE FROM portos_bo_collaudo WHERE collaudoid IN ("
+ "SELECT collaudoid FROM portos_bo_collaudo c "
+ "LEFT JOIN portos_bo_intpratica i ON c.intpraticaid=i.intpraticaid "
+ "WHERE i.intpraticaid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da portos_bo_collaudo");
rows = s.executeUpdate("DELETE FROM portos_bo_delega WHERE delegaid IN ("
+ "SELECT delegaid FROM portos_bo_delega d "
+ "LEFT JOIN portos_bo_dettpratica dp ON d.dettpraticaid=dp.dettpraticaid "
+ "WHERE dp.dettpraticaid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da portos_bo_delega");
rows = s.executeUpdate("DELETE FROM portos_bo_finelavori WHERE finelavoriid IN ("
+ "SELECT finelavoriid FROM portos_bo_finelavori f "
+ "LEFT JOIN portos_bo_intpratica i ON f.intpraticaid=i.intpraticaid "
+ "WHERE i.intpraticaid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da portos_bo_finelavori");
rows = s.executeUpdate("DELETE FROM portos_bo_soggetto WHERE soggettoid IN ("
+ "SELECT soggettoid FROM portos_bo_soggetto s "
+ "LEFT JOIN portos_bo_dettpratica d ON s.dettpraticaid=d.dettpraticaid "
+ "WHERE d.dettpraticaid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da portos_bo_soggetto");
int cancellati = 0;
int start = 0;
int totali = 0;
List<DocAggiuntiva> docs = null;
do {
docs = DocAggiuntivaLocalServiceUtil.getDocAggiuntivas(start, start + SLICE);
int rimossi = 0;
for (DocAggiuntiva doc : docs) {
IntPratica intPratica = IntPraticaLocalServiceUtil.getIntPratica(doc.getIntPraticaId());
DettPratica dettPratica = DettPraticaLocalServiceUtil.getDettPratica(doc
.getDettPraticaId());
if (Validator.isNull(intPratica) || Validator.isNull(dettPratica)) {
DocAggiuntivaLocalServiceUtil.deleteDocAggiuntiva(doc);
cancellati++;
rimossi++;
}
}
totali += docs.size();
start += SLICE - rimossi;
} while (docs.size() > 0);
esitoLog(esito, "Analizzati " + totali + " DocAggiuntiva, cancellati " + cancellati);
cancellati = 0;
start = 0;
totali = 0;
List<DocPratica> docs2 = null;
do {
docs2 = DocPraticaLocalServiceUtil.getDocPraticas(start, start + SLICE);
int rimossi = 0;
for (DocPratica doc : docs2) {
boolean rimuovi = false;
if (Collaudo.class.getName().equals(doc.getClassName())) {
Collaudo collaudo = null;
try {
collaudo = CollaudoLocalServiceUtil.getCollaudo(doc.getClassPk());
} catch (PortalException e) {
}
rimuovi = Validator.isNull(collaudo);
} else if (Delega.class.getName().equals(doc.getClassName())) {
Delega delega = null;
try {
delega = DelegaLocalServiceUtil.getDelega(doc.getClassPk());
} catch (PortalException e) {
}
rimuovi = Validator.isNull(delega);
} else if (DettPratica.class.getName().equals(doc.getClassName())) {
DettPratica dettPratica = null;
try {
dettPratica = DettPraticaLocalServiceUtil.getDettPratica(doc.getClassPk());
} catch (PortalException e) {
}
rimuovi = Validator.isNull(dettPratica);
} else if (FineLavori.class.getName().equals(doc.getClassName())) {
FineLavori fineLavori = null;
try {
fineLavori = FineLavoriLocalServiceUtil.getFineLavori(doc.getClassPk());
} catch (PortalException e) {
}
rimuovi = Validator.isNull(fineLavori);
} else if (IntPratica.class.getName().equals(doc.getClassName())) {
IntPratica intPratica = null;
try {
intPratica = IntPraticaLocalServiceUtil.getIntPratica(doc.getClassPk());
} catch (PortalException e) {
}
rimuovi = Validator.isNull(intPratica);
} else if (Soggetto.class.getName().equals(doc.getClassName())) {
Soggetto soggetto = null;
try {
soggetto = SoggettoLocalServiceUtil.getSoggetto(doc.getClassPk());
} catch (PortalException e) {
}
rimuovi = Validator.isNull(soggetto);
}
if (rimuovi) {
DocPraticaLocalServiceUtil.deleteDocPratica(doc);
cancellati++;
rimossi++;
}
}
totali += docs2.size();
start += SLICE - rimossi;
_log.info("Analizzati " + totali + " DocPratica, cancellati " + cancellati);
} while (docs2.size() > 0);
esitoLog(esito, "Analizzati " + totali + " DocPratica, cancellati " + cancellati);
} catch (PortalException | SQLException | SystemException e) {
esitoLog(esito, "Interrotto per errore: " + e.getMessage());
}
return esito;
}
private static List<String> svuotaDatabase(ServiceContext serviceContext) { private static List<String> svuotaDatabase(ServiceContext serviceContext) {
List<String> esito = new ArrayList<>(); List<String> esito = new ArrayList<>();
int rows = 0; int rows = 0;
@ -239,6 +387,24 @@ public class PuliziaDatabase {
+ "ON a.classpk=b.fileentryid WHERE a.classnameid=" + dlFileEntryClassNameId + "ON a.classpk=b.fileentryid WHERE a.classnameid=" + dlFileEntryClassNameId
+ " AND b.fileentryid IS NULL)"); + " AND b.fileentryid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da socialactivity"); esitoLog(esito, "Cancellate " + rows + " righe da socialactivity");
rows = s.executeUpdate("DELETE FROM systemevent WHERE systemeventid IN ("
+ "SELECT systemeventid FROM systemevent a LEFT JOIN dlfileentry b "
+ "ON a.classpk=b.fileentryid WHERE a.classnameid=" + dlFileEntryClassNameId
+ " AND b.fileentryid IS NULL)");
rows += s.executeUpdate("DELETE FROM systemevent WHERE systemeventid IN ("
+ "SELECT systemeventid FROM systemevent a LEFT JOIN dlfolder b "
+ "ON a.classpk=b.folderid WHERE a.classnameid=" + dlFolderClassNameId
+ " AND b.folderid IS NULL)");
rows += s.executeUpdate("DELETE FROM systemevent WHERE systemeventid IN ("
+ "SELECT systemeventid FROM systemevent a LEFT JOIN portos_bo_controllopratica b "
+ "ON a.classpk=b.controllopraticaid WHERE a.classnameid=" + controlloPraticaClassNameId
+ " AND b.controllopraticaid IS NULL)");
rows += s.executeUpdate("DELETE FROM systemevent WHERE systemeventid IN ("
+ "SELECT systemeventid FROM systemevent a LEFT JOIN portos_bo_dettpratica b "
+ "ON a.classpk=b.dettpraticaid WHERE a.classnameid=" + dettPraticaClassNameId
+ " AND b.dettpraticaid IS NULL)");
esitoLog(esito, "Cancellate " + rows + " righe da systemevent");
} catch (SQLException | SystemException e) { } catch (SQLException | SystemException e) {
esitoLog(esito, "Interrotto per errore: " + e.getMessage()); esitoLog(esito, "Interrotto per errore: " + e.getMessage());
} }

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

@ -106,7 +106,8 @@ public class FascicoloPortlet extends MVCPortlet {
@Override @Override
public void render(RenderRequest request, RenderResponse response) throws PortletException, IOException { public void render(RenderRequest request, RenderResponse response) throws PortletException, IOException {
HttpServletRequest httpReq = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(request)); HttpServletRequest httpReq = PortalUtil.getOriginalServletRequest(PortalUtil
.getHttpServletRequest(request));
String intPraticaId = httpReq.getParameter("intPraticaId"); String intPraticaId = httpReq.getParameter("intPraticaId");
if (Validator.isNotNull(intPraticaId) && !intPraticaId.equals("")) { if (Validator.isNotNull(intPraticaId) && !intPraticaId.equals("")) {
@ -118,14 +119,13 @@ public class FascicoloPortlet extends MVCPortlet {
public void toggleWorkflow(ActionRequest actionRequest, ActionResponse actionResponse) { public void toggleWorkflow(ActionRequest actionRequest, ActionResponse actionResponse) {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
User user = themeDisplay.getUser(); User user = themeDisplay.getUser();
boolean attivare = ParamUtil.getBoolean(actionRequest, "avviare"); boolean attivare = ParamUtil.getBoolean(actionRequest, "avviare");
boolean sospendere = ParamUtil.getBoolean(actionRequest, "sospendere"); boolean sospendere = ParamUtil.getBoolean(actionRequest, "sospendere");
long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0); long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0);
String stato_pratica= ParamUtil.getString(actionRequest, "seleziona_stato"); String stato_pratica = ParamUtil.getString(actionRequest, "seleziona_stato");
try { try {
@ -135,16 +135,16 @@ public class FascicoloPortlet extends MVCPortlet {
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
if (attivare && !sospendere) { if (attivare && !sospendere) {
WorkflowUtil.attivaWorkflow(intPraticaId, territorio.getGroupId(), serviceContext.getUserId(), WorkflowUtil.attivaWorkflow(intPraticaId, territorio.getGroupId(),
dettPratica.getDettPraticaId(), serviceContext, true); serviceContext.getUserId(), dettPratica.getDettPraticaId(), serviceContext, true);
addRowHistoryWorkflowAction(intPraticaId, dettPratica.getDettPraticaId(), addRowHistoryWorkflowAction(intPraticaId, dettPratica.getDettPraticaId(),
themeDisplay.getCompanyId(), intPratica.getGroupId(), user, true); themeDisplay.getCompanyId(), intPratica.getGroupId(), user, true);
SessionMessages.add(actionRequest, "success-workflow-ripreso"); SessionMessages.add(actionRequest, "success-workflow-ripreso");
} else if (!attivare && sospendere) { } else if (!attivare && sospendere) {
WorkflowUtil.attivaWorkflow(intPraticaId, territorio.getGroupId(), serviceContext.getUserId(), WorkflowUtil.attivaWorkflow(intPraticaId, territorio.getGroupId(),
dettPratica.getDettPraticaId(), serviceContext, false); serviceContext.getUserId(), dettPratica.getDettPraticaId(), serviceContext, false);
addRowHistoryWorkflowAction(intPraticaId, dettPratica.getDettPraticaId(), addRowHistoryWorkflowAction(intPraticaId, dettPratica.getDettPraticaId(),
themeDisplay.getCompanyId(), intPratica.getGroupId(), user, false); themeDisplay.getCompanyId(), intPratica.getGroupId(), user, false);
@ -159,15 +159,15 @@ public class FascicoloPortlet extends MVCPortlet {
actionResponse.sendRedirect(redirectURL); actionResponse.sendRedirect(redirectURL);
} }
if(!attivare){ if (!attivare) {
intPratica.setStatoPratica(stato_pratica); intPratica.setStatoPratica(stato_pratica);
IntPraticaLocalServiceUtil.updateStatoPratica(intPraticaId, 0, stato_pratica); IntPraticaLocalServiceUtil.updateStatoPratica(intPraticaId, 0, stato_pratica);
} else { } else {
intPratica.setStatoPratica(StatoPraticaConstants.SOTTOPOSTA_A_PARERE); intPratica.setStatoPratica(StatoPraticaConstants.SOTTOPOSTA_A_PARERE);
IntPraticaLocalServiceUtil.updateStatoPratica(intPraticaId, 0, StatoPraticaConstants.SOTTOPOSTA_A_PARERE); IntPraticaLocalServiceUtil.updateStatoPratica(intPraticaId, 0,
StatoPraticaConstants.SOTTOPOSTA_A_PARERE);
} }
IntPraticaLocalServiceUtil.reIndexFasciolo(intPraticaId, intPratica.getCompanyId()); IntPraticaLocalServiceUtil.reIndexFasciolo(intPraticaId, intPratica.getCompanyId());
} catch (Exception e) { } catch (Exception e) {
@ -177,10 +177,12 @@ public class FascicoloPortlet extends MVCPortlet {
} }
private void addRowHistoryWorkflowAction(long intPraticaId, long dettPraticaId, long companyId, long groupId, User user, boolean attivato) throws SystemException{ private void addRowHistoryWorkflowAction(long intPraticaId, long dettPraticaId, long companyId,
long groupId, User user, boolean attivato) throws SystemException {
HistoryWorkflowAction historyWorkflowAction = HistoryWorkflowActionLocalServiceUtil.createHistoryWorkflowAction( HistoryWorkflowAction historyWorkflowAction = HistoryWorkflowActionLocalServiceUtil
CounterLocalServiceUtil.increment(HistoryWorkflowAction.class.getName())); .createHistoryWorkflowAction(CounterLocalServiceUtil.increment(HistoryWorkflowAction.class
.getName()));
historyWorkflowAction.setAttivato(attivato); historyWorkflowAction.setAttivato(attivato);
historyWorkflowAction.setCompanyId(companyId); historyWorkflowAction.setCompanyId(companyId);
@ -253,21 +255,21 @@ public class FascicoloPortlet extends MVCPortlet {
long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0); long intPraticaId = ParamUtil.getLong(actionRequest, "intPraticaId", 0);
long companyId = ParamUtil.getLong(actionRequest, "companyId"); long companyId = ParamUtil.getLong(actionRequest, "companyId");
try { try {
ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);
User user = UserLocalServiceUtil.fetchUserByScreenName(companyId, nuovoSoggettoCF); User user = UserLocalServiceUtil.fetchUserByScreenName(companyId, nuovoSoggettoCF);
if (Validator.isNotNull(user)) { if (Validator.isNotNull(user)) {
if (!ValidazionePraticaUtil.praticaInProgress(intPraticaId)) { if (!ValidazionePraticaUtil.praticaInProgress(intPraticaId)) {
_log.info("cambiaTitolare: cfNuovoTitolare " + nuovoSoggettoCF + " intpratica" + intPraticaId); _log.info("cambiaTitolare: cfNuovoTitolare " + nuovoSoggettoCF + " intpratica"
+ intPraticaId);
IntPraticaServiceUtil.cambiaTitolare(intPraticaId, user.getUserId(), serviceContext); IntPraticaServiceUtil.cambiaTitolare(intPraticaId, user.getUserId(), serviceContext);
SessionMessages.add(actionRequest, "success-cambio-titolare"); SessionMessages.add(actionRequest, "success-cambio-titolare");
} else { } else {
SessionErrors.add(actionRequest, "error-cambio-titolare-pratica-in-progress"); SessionErrors.add(actionRequest, "error-cambio-titolare-pratica-in-progress");
} }
} else { } else {
_log.error("[FASCICOLO ACTION - CAMBIO TITOLARE] Nessun utente trovato con company " + companyId _log.error("[FASCICOLO ACTION - CAMBIO TITOLARE] Nessun utente trovato con company "
+ " e codice fiscale " + nuovoSoggettoCF); + companyId + " e codice fiscale " + nuovoSoggettoCF);
SessionErrors.add(actionRequest, "error-cambio-titolare-no-such-user"); SessionErrors.add(actionRequest, "error-cambio-titolare-no-such-user");
} }
} catch (PortalException | SystemException e) { } catch (PortalException | SystemException e) {
@ -299,24 +301,23 @@ public class FascicoloPortlet extends MVCPortlet {
if (dataRichiestaInizio != null && !dataRichiestaInizio.equals("")) { if (dataRichiestaInizio != null && !dataRichiestaInizio.equals("")) {
String[] dataRichiestaInizioSplitted = dataRichiestaInizio.split("/"); String[] dataRichiestaInizioSplitted = dataRichiestaInizio.split("/");
int mounth = Integer.valueOf(dataRichiestaInizioSplitted[1]) -1; int mounth = Integer.valueOf(dataRichiestaInizioSplitted[1]) - 1;
actionResponse.setRenderParameter("dataRichiestaInizioDay", dataRichiestaInizioSplitted[0]); actionResponse.setRenderParameter("dataRichiestaInizioDay", dataRichiestaInizioSplitted[0]);
actionResponse.setRenderParameter("dataRichiestaInizioMonth", mounth+""); actionResponse.setRenderParameter("dataRichiestaInizioMonth", mounth + "");
actionResponse.setRenderParameter("dataRichiestaInizioYear", dataRichiestaInizioSplitted[2]); actionResponse.setRenderParameter("dataRichiestaInizioYear", dataRichiestaInizioSplitted[2]);
} }
if (dataRichiestaFine != null && !dataRichiestaFine.equals("")) { if (dataRichiestaFine != null && !dataRichiestaFine.equals("")) {
String[] dataRichiestaFineSplitted = dataRichiestaFine.split("/"); String[] dataRichiestaFineSplitted = dataRichiestaFine.split("/");
int mounth = Integer.valueOf(dataRichiestaFineSplitted[1]) -1; int mounth = Integer.valueOf(dataRichiestaFineSplitted[1]) - 1;
actionResponse.setRenderParameter("dataRichiestaFineDay", dataRichiestaFineSplitted[0]); actionResponse.setRenderParameter("dataRichiestaFineDay", dataRichiestaFineSplitted[0]);
actionResponse.setRenderParameter("dataRichiestaFineMonth", mounth+""); actionResponse.setRenderParameter("dataRichiestaFineMonth", mounth + "");
actionResponse.setRenderParameter("dataRichiestaFineYear", dataRichiestaFineSplitted[2]); actionResponse.setRenderParameter("dataRichiestaFineYear", dataRichiestaFineSplitted[2]);
} }
String ufficio = actionRequest.getParameter("ufficio"); String ufficio = actionRequest.getParameter("ufficio");
String ordinaPer = actionRequest.getParameter("ordinaPer"); String ordinaPer = actionRequest.getParameter("ordinaPer");
String ordinaTipo = actionRequest.getParameter("ordinaTipo"); String ordinaTipo = actionRequest.getParameter("ordinaTipo");
@ -334,11 +335,11 @@ public class FascicoloPortlet extends MVCPortlet {
actionResponse.setRenderParameter("statoPratica", statoPratica); actionResponse.setRenderParameter("statoPratica", statoPratica);
actionResponse.setRenderParameter("committente", committente); actionResponse.setRenderParameter("committente", committente);
if(provincia != null && !provincia.equals("")){ if (provincia != null && !provincia.equals("")) {
actionResponse.setRenderParameter("provincia", provincia); actionResponse.setRenderParameter("provincia", provincia);
} }
if(comune != null && !comune.equals("")){ if (comune != null && !comune.equals("")) {
actionResponse.setRenderParameter("comune", comune); actionResponse.setRenderParameter("comune", comune);
} }
@ -361,7 +362,6 @@ public class FascicoloPortlet extends MVCPortlet {
actionResponse.setRenderParameter("ufficio", -1 + ""); actionResponse.setRenderParameter("ufficio", -1 + "");
} }
actionResponse.setRenderParameter("ordinaPer", ordinaPer); actionResponse.setRenderParameter("ordinaPer", ordinaPer);
actionResponse.setRenderParameter("ordinaTipo", ordinaTipo); actionResponse.setRenderParameter("ordinaTipo", ordinaTipo);
@ -372,11 +372,9 @@ public class FascicoloPortlet extends MVCPortlet {
long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId", 0); long dettPraticaId = ParamUtil.getLong(actionRequest, "dettPraticaId", 0);
long companyId = ParamUtil.getLong(actionRequest, "companyId"); long companyId = ParamUtil.getLong(actionRequest, "companyId");
try { try {
DettPraticaServiceUtil.sendToVersioning(dettPraticaId, companyId); DettPraticaServiceUtil.sendToVersioning(dettPraticaId, companyId);
} catch (Exception e) {
} catch (PortalException | SystemException | IOException | NoSuchFieldException | SecurityException e) {
_log.error("error-versioning", e); _log.error("error-versioning", e);
SessionErrors.add(actionRequest, "error-versioning"); SessionErrors.add(actionRequest, "error-versioning");
} }
@ -386,8 +384,8 @@ public class FascicoloPortlet extends MVCPortlet {
} }
@Override @Override
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
PortletException { throws IOException, PortletException {
String id = resourceRequest.getResourceID(); String id = resourceRequest.getResourceID();
ServiceContext serviceContext; ServiceContext serviceContext;
@ -416,8 +414,8 @@ public class FascicoloPortlet extends MVCPortlet {
} else if ("page_collaudo".equals(comingFrom)) { } else if ("page_collaudo".equals(comingFrom)) {
tipologieAllegati = DocumentiPraticaUtil.getDocCollaudo(); tipologieAllegati = DocumentiPraticaUtil.getDocCollaudo();
} }
docs = docs = DocPraticaLocalServiceUtil.findByIntPratica_ClassPk_Tipologie(intPraticaId,
DocPraticaLocalServiceUtil.findByIntPratica_ClassPk_Tipologie(intPraticaId, classPk, tipologieAllegati); classPk, tipologieAllegati);
} }
ZipWriter zipWriter = ZipWriterFactoryUtil.getZipWriter(); ZipWriter zipWriter = ZipWriterFactoryUtil.getZipWriter();
@ -430,10 +428,11 @@ public class FascicoloPortlet extends MVCPortlet {
continue; continue;
} }
FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(doc.getDlFileEntryId()); FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(doc.getDlFileEntryId());
inputStream = inputStream = DLFileEntryLocalServiceUtil.getFileAsStream(fileEntry.getFileEntryId(),
DLFileEntryLocalServiceUtil.getFileAsStream(fileEntry.getFileEntryId(), fileEntry.getVersion(), false); fileEntry.getVersion(), false);
// String name = fileEntry.getTitle() + StringPool.PERIOD + fileEntry.getExtension(); // String name = fileEntry.getTitle() +
// StringPool.PERIOD + fileEntry.getExtension();
String name = fileEntry.getTitle(); String name = fileEntry.getTitle();
zipWriter.addEntry(name, inputStream); zipWriter.addEntry(name, inputStream);
} finally { } finally {
@ -448,8 +447,8 @@ public class FascicoloPortlet extends MVCPortlet {
resourceResponse.setContentType(ContentTypes.APPLICATION_ZIP); resourceResponse.setContentType(ContentTypes.APPLICATION_ZIP);
resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate"); resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=3600, must-revalidate");
resourceResponse resourceResponse.addProperty(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\""
.addProperty(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + file.getName() + "\""); + file.getName() + "\"");
resourceResponse.setContentLength(data.length); resourceResponse.setContentLength(data.length);
resourceResponse.getPortletOutputStream().write(data); resourceResponse.getPortletOutputStream().write(data);
@ -464,40 +463,53 @@ public class FascicoloPortlet extends MVCPortlet {
FilesImporter.importaFile(classPk, className); FilesImporter.importaFile(classPk, className);
// if (DocPratica.class.getName().equalsIgnoreCase(className)) { // if (DocPratica.class.getName().equalsIgnoreCase(className)) {
// DocPratica docPratica = DocPraticaLocalServiceUtil.getDocPratica(classPk); // DocPratica docPratica =
// if (docPratica.getDlFileEntryId() == 0L && docPratica.getOldDlFileEntryId() != 0L) { // DocPraticaLocalServiceUtil.getDocPratica(classPk);
// if (docPratica.getDlFileEntryId() == 0L &&
// docPratica.getOldDlFileEntryId() != 0L) {
// FilesImporter.handleFileImportDocPratica(docPratica); // FilesImporter.handleFileImportDocPratica(docPratica);
// } // }
// } else if (Avviso.class.getName().equalsIgnoreCase(className)) { // } else if
// (Avviso.class.getName().equalsIgnoreCase(className)) {
// Avviso avviso = AvvisoLocalServiceUtil.getAvviso(classPk); // Avviso avviso = AvvisoLocalServiceUtil.getAvviso(classPk);
// if (avviso.getFileEntryIdBase() == 0L && avviso.getOldFileEntryIdBase() != 0L) { // if (avviso.getFileEntryIdBase() == 0L &&
// avviso.getOldFileEntryIdBase() != 0L) {
// FilesImporter.handleFileImportAvviso(avviso, true); // FilesImporter.handleFileImportAvviso(avviso, true);
// } // }
// if (avviso.getFileEntryIdInvio() == 0L && avviso.getOldFileEntryIdInvio() != 0L) { // if (avviso.getFileEntryIdInvio() == 0L &&
// avviso.getOldFileEntryIdInvio() != 0L) {
// FilesImporter.handleFileImportAvviso(avviso, false); // FilesImporter.handleFileImportAvviso(avviso, false);
// } // }
// } else if (Pagamento.class.getName().equalsIgnoreCase(className)) { // } else if
// Pagamento pagamento = PagamentoLocalServiceUtil.getPagamento(classPk); // (Pagamento.class.getName().equalsIgnoreCase(className)) {
// if (pagamento.getFileEntryId() == 0L && pagamento.getOldFileEntryId() != 0L) { // Pagamento pagamento =
// PagamentoLocalServiceUtil.getPagamento(classPk);
// if (pagamento.getFileEntryId() == 0L &&
// pagamento.getOldFileEntryId() != 0L) {
// FilesImporter.handleFileImportPagamento(pagamento); // FilesImporter.handleFileImportPagamento(pagamento);
// } // }
// } else if (DocAggiuntiva.class.getName().equalsIgnoreCase(className)) { // } else if
// DocAggiuntiva docAggiuntiva = DocAggiuntivaLocalServiceUtil.getDocAggiuntiva(classPk); // (DocAggiuntiva.class.getName().equalsIgnoreCase(className)) {
// if (docAggiuntiva.getFileEntryId() == 0L && docAggiuntiva.getOldFileEntryId() != 0L) { // DocAggiuntiva docAggiuntiva =
// DocAggiuntivaLocalServiceUtil.getDocAggiuntiva(classPk);
// if (docAggiuntiva.getFileEntryId() == 0L &&
// docAggiuntiva.getOldFileEntryId() != 0L) {
// FilesImporter.handleFileImportDocAggiuntiva(docAggiuntiva); // FilesImporter.handleFileImportDocAggiuntiva(docAggiuntiva);
// } // }
// } else if (AllegatoManuale.class.getName().equalsIgnoreCase(className)) { // } else if
// (AllegatoManuale.class.getName().equalsIgnoreCase(className))
// {
// AllegatoManuale allegatoManuale = // AllegatoManuale allegatoManuale =
// AllegatoManualeLocalServiceUtil.getAllegatoManuale(classPk); // AllegatoManualeLocalServiceUtil.getAllegatoManuale(classPk);
// if (allegatoManuale.getFileEntryId() == 0L && allegatoManuale.getOldFileEntryId() != 0L) // if (allegatoManuale.getFileEntryId() == 0L &&
// allegatoManuale.getOldFileEntryId() != 0L)
// { // {
// FilesImporter.handleFileImportAllegatoManuale(allegatoManuale); // FilesImporter.handleFileImportAllegatoManuale(allegatoManuale);
// } // }
// } // }
PortletResponseUtil PortletResponseUtil
.write( .write(resourceResponse,
resourceResponse,
"<p style='margin-bottom:20px'><strong>Completato</strong></p><a href='#' class='btn btn-success' onclick=\"Liferay.Portlet.refresh('#p_p_id_" "<p style='margin-bottom:20px'><strong>Completato</strong></p><a href='#' class='btn btn-success' onclick=\"Liferay.Portlet.refresh('#p_p_id_"
+ PortletKeys.FASCICOLO + "_')\">Refresh</a>"); + PortletKeys.FASCICOLO + "_')\">Refresh</a>");
@ -510,11 +522,11 @@ public class FascicoloPortlet extends MVCPortlet {
} }
String comingFrom = ParamUtil.getString(resourceRequest, "comingFrom", "bo"); String comingFrom = ParamUtil.getString(resourceRequest, "comingFrom", "bo");
InfoFascicolo infoFascicolo = InfoFascicoloLocalServiceUtil.fetchByIntPratica(intPratica.getIntPraticaId()); InfoFascicolo infoFascicolo = InfoFascicoloLocalServiceUtil.fetchByIntPratica(intPratica
.getIntPraticaId());
if (Validator.isNull(infoFascicolo)) { if (Validator.isNull(infoFascicolo)) {
infoFascicolo = infoFascicolo = InfoFascicoloLocalServiceUtil.addInfoFascicolo(
InfoFascicoloLocalServiceUtil.addInfoFascicolo(intPratica.getIntPraticaId(), intPratica.getIntPraticaId(), intPratica.getNumeroProgetto(), serviceContext);
intPratica.getNumeroProgetto(), serviceContext);
} else { } else {
if (infoFascicolo.getAlreadyImported() && comingFrom.equalsIgnoreCase("fe")) { if (infoFascicolo.getAlreadyImported() && comingFrom.equalsIgnoreCase("fe")) {
_log.error("intpratica.import.file.already-clicked with intpraticaid=" + intPraticaId); _log.error("intpratica.import.file.already-clicked with intpraticaid=" + intPraticaId);
@ -524,19 +536,24 @@ public class FascicoloPortlet extends MVCPortlet {
User user = UserLocalServiceUtil.fetchUser(serviceContext.getUserId()); User user = UserLocalServiceUtil.fetchUser(serviceContext.getUserId());
_log.debug("************** START IMPORT FILES FASCICOLO : " + intPraticaId + " by user" + user.getFullName()); _log.debug("************** START IMPORT FILES FASCICOLO : " + intPraticaId + " by user"
+ user.getFullName());
List<DettPratica> listaDet = DettPraticaLocalServiceUtil.findByIntPraticaId(intPraticaId); List<DettPratica> listaDet = DettPraticaLocalServiceUtil.findByIntPraticaId(intPraticaId);
for (DettPratica dettPratica : listaDet) { for (DettPratica dettPratica : listaDet) {
FilesImporter.importaFilesFascicolo(dettPratica.getDettPraticaId(), DettPratica.class.getName()); FilesImporter.importaFilesFascicolo(dettPratica.getDettPraticaId(),
DettPratica.class.getName());
} }
List<FineLavori> listaFine = FineLavoriLocalServiceUtil.findByIntPraticaId(intPraticaId, -1, -1, null); List<FineLavori> listaFine = FineLavoriLocalServiceUtil.findByIntPraticaId(intPraticaId, -1,
-1, null);
for (FineLavori fineLavori : listaFine) { for (FineLavori fineLavori : listaFine) {
FilesImporter.importaFilesFascicolo(fineLavori.getFineLavoriId(), FineLavori.class.getName()); FilesImporter.importaFilesFascicolo(fineLavori.getFineLavoriId(),
FineLavori.class.getName());
} }
List<Collaudo> listaColl = CollaudoLocalServiceUtil.findByIntPraticaId(intPraticaId, -1, -1, null); List<Collaudo> listaColl = CollaudoLocalServiceUtil.findByIntPraticaId(intPraticaId, -1, -1,
null);
for (Collaudo collaudo : listaColl) { for (Collaudo collaudo : listaColl) {
FilesImporter.importaFilesFascicolo(collaudo.getCollaudoId(), Collaudo.class.getName()); FilesImporter.importaFilesFascicolo(collaudo.getCollaudoId(), Collaudo.class.getName());
} }
@ -547,17 +564,17 @@ public class FascicoloPortlet extends MVCPortlet {
infoFascicolo = InfoFascicoloLocalServiceUtil.updateInfoFascicolo(infoFascicolo); infoFascicolo = InfoFascicoloLocalServiceUtil.updateInfoFascicolo(infoFascicolo);
PortletResponseUtil PortletResponseUtil
.write( .write(resourceResponse,
resourceResponse,
"<p style='margin-bottom:20px'><strong>Completato</strong></p><a href='#' class='btn btn-success' onclick=\"Liferay.Portlet.refresh('#p_p_id_" "<p style='margin-bottom:20px'><strong>Completato</strong></p><a href='#' class='btn btn-success' onclick=\"Liferay.Portlet.refresh('#p_p_id_"
+ PortletKeys.FASCICOLO + "_')\">Refresh</a>"); + PortletKeys.FASCICOLO + "_')\">Refresh</a>");
} else if ("comuni".equals(id)) { } else if ("comuni".equals(id)) {
String provinciaId = ParamUtil.getString(resourceRequest, "provinciaId"); String provinciaId = ParamUtil.getString(resourceRequest, "provinciaId");
JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
if (Validator.isNotNull(provinciaId) && !provinciaId.equals("0")) { if (Validator.isNotNull(provinciaId) && !provinciaId.equals("0")) {
List<Long> comuniIds = TerritorioLocalServiceUtil.getActiveComuniByCodiceProvincia(provinciaId); List<Long> comuniIds = TerritorioLocalServiceUtil
.getActiveComuniByCodiceProvincia(provinciaId);
//ADT BUG-ID=15 Sezione Ricerca / Ordinamento Filtro // ADT BUG-ID=15 Sezione Ricerca / Ordinamento Filtro
List<Comune> comumeList = new ArrayList<Comune>(); List<Comune> comumeList = new ArrayList<Comune>();
for (long comuneId : comuniIds) { for (long comuneId : comuniIds) {
Comune comune = ComuneLocalServiceUtil.getComune(comuneId); Comune comune = ComuneLocalServiceUtil.getComune(comuneId);
@ -581,14 +598,14 @@ public class FascicoloPortlet extends MVCPortlet {
} }
writeJSON(resourceRequest, resourceResponse, jsonArray); writeJSON(resourceRequest, resourceResponse, jsonArray);
} else if("exportRicerca".equals(id)){ } else if ("exportRicerca".equals(id)) {
ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest
.getAttribute(WebKeys.THEME_DISPLAY);
Locale locale = themeDisplay.getLocale(); Locale locale = themeDisplay.getLocale();
User user = themeDisplay.getUser(); User user = themeDisplay.getUser();
String csv = StringPool.BLANK; String csv = StringPool.BLANK;
HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest); HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest);
@ -596,10 +613,10 @@ public class FascicoloPortlet extends MVCPortlet {
csv = exportSearch(locale, resourceRequest, user); csv = exportSearch(locale, resourceRequest, user);
ServletResponseUtil.sendFile(request, response, "export_ricerca.csv", csv.getBytes(StringPool.UTF8), ServletResponseUtil.sendFile(request, response, "export_ricerca.csv",
ContentTypes.TEXT_CSV_UTF8); csv.getBytes(StringPool.UTF8), ContentTypes.TEXT_CSV_UTF8);
}else { } else {
super.serveResource(resourceRequest, resourceResponse); super.serveResource(resourceRequest, resourceResponse);
} }
} catch (Exception e) { } catch (Exception e) {
@ -617,7 +634,7 @@ public class FascicoloPortlet extends MVCPortlet {
List<IntPratica> lista = new ArrayList<IntPratica>(); List<IntPratica> lista = new ArrayList<IntPratica>();
// try { // try {
Hits hits = IntPraticaAdvancedSearch.searchProgettiBO(httpRequest, user, -1, -1); Hits hits = IntPraticaAdvancedSearch.searchProgettiBO(httpRequest, user, -1, -1);
@ -625,55 +642,68 @@ public class FascicoloPortlet extends MVCPortlet {
String intPraticaId = doc.get("intPraticaId"); String intPraticaId = doc.get("intPraticaId");
try { try {
if (Validator.isNotNull(intPraticaId)) { if (Validator.isNotNull(intPraticaId)) {
IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(GetterUtil.getLong(intPraticaId)); IntPratica intPratica = IntPraticaLocalServiceUtil.fetchIntPratica(GetterUtil
.getLong(intPraticaId));
if (Validator.isNotNull(intPratica)) { if (Validator.isNotNull(intPratica)) {
lista.add(intPratica); lista.add(intPratica);
} }
} }
} catch(Throwable e){ } catch (Throwable e) {
_log.error(method + " IntPraticaLocalServiceUtil.fetchIntPratica IntPraticaId: " + intPraticaId, e); _log.error(method + " IntPraticaLocalServiceUtil.fetchIntPratica IntPraticaId: "
+ intPraticaId, e);
} }
} }
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.sorteggiata"))); sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale,
"label.scadenzegeniocivile.sorteggiata")));
sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON);
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.pratica"))); sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale,
"label.scadenzegeniocivile.pratica")));
sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON);
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.titolare"))); sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale,
"label.scadenzegeniocivile.titolare")));
sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON);
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.committenti"))); sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale,
"label.scadenzegeniocivile.committenti")));
sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON);
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.istruttore"))); sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale,
"label.scadenzegeniocivile.istruttore")));
sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON);
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.statoPratica"))); sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale,
"label.scadenzegeniocivile.statoPratica")));
sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON);
//ADT BUG-ID=15 Sezione Ricerca / Export csv // ADT BUG-ID=15 Sezione Ricerca / Export csv
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.provincia"))); sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale,
"label.scadenzegeniocivile.provincia")));
sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON);
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.comune"))); sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale,
"label.scadenzegeniocivile.comune")));
sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON);
sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale, "label.scadenzegeniocivile.descrizioneIntervento"))); sb.append(CSVUtil.encode(LanguageUtil.get(getPortletConfig(), locale,
"label.scadenzegeniocivile.descrizioneIntervento")));
sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON);
sb.append(StringPool.NEW_LINE); sb.append(StringPool.NEW_LINE);
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
for (IntPratica intPratica : lista) { for (IntPratica intPratica : lista) {
try{ try {
DettPratica lastDettPratica = DettPraticaLocalServiceUtil.getLastCompletedByIntPratica(intPratica.getIntPraticaId()); DettPratica lastDettPratica = DettPraticaLocalServiceUtil
.getLastCompletedByIntPratica(intPratica.getIntPraticaId());
Territorio territorio = TerritorioLocalServiceUtil.fetchTerritorio(intPratica.getTerritorioId()); Territorio territorio = TerritorioLocalServiceUtil.fetchTerritorio(intPratica
.getTerritorioId());
Comune comune = ComuneLocalServiceUtil.fetchComune(territorio.getComuneId()); Comune comune = ComuneLocalServiceUtil.fetchComune(territorio.getComuneId());
Provincia provincia = Provincia provincia = ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(),
ProvinciaLocalServiceUtil.fetchByC_C(territorio.getCompanyId(), territorio.getCodiceProvincia()); territorio.getCodiceProvincia());
boolean sorteggiata = SorteggioLocalServiceUtil.findByIntPratica(intPratica.getIntPraticaId()) != null; boolean sorteggiata = SorteggioLocalServiceUtil
.findByIntPratica(intPratica.getIntPraticaId()) != null;
sb.append(CSVUtil.encode((sorteggiata) ? "Si" : "No")); sb.append(CSVUtil.encode((sorteggiata) ? "Si" : "No"));
sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON);
@ -682,70 +712,84 @@ public class FascicoloPortlet extends MVCPortlet {
sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON);
User titolareUser = UserLocalServiceUtil.getUserById(intPratica.getUserId()); User titolareUser = UserLocalServiceUtil.getUserById(intPratica.getUserId());
List<Soggetto> titolari = SoggettoLocalServiceUtil.getValidByIntPratica_CodiceFiscale(lastDettPratica.getIntPraticaId(), lastDettPratica.getCodiceFiscaleDelegatoCommittente()); List<Soggetto> titolari = SoggettoLocalServiceUtil.getValidByIntPratica_CodiceFiscale(
lastDettPratica.getIntPraticaId(),
lastDettPratica.getCodiceFiscaleDelegatoCommittente());
Soggetto titolare = null; Soggetto titolare = null;
if(!titolari.isEmpty()){ if (!titolari.isEmpty()) {
titolare = titolari.get(0); titolare = titolari.get(0);
} }
if(titolare != null){ if (titolare != null) {
sb.append(titolare.getTitle()+ " - " +titolare.getCodiceFiscale()); sb.append(titolare.getTitle() + " - " + titolare.getCodiceFiscale());
} else { } else {
sb.append(""); sb.append("");
} }
sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON);
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
List<Soggetto> committenti = SoggettoLocalServiceUtil.findByIntPratica_TipologiaSoggetto(lastDettPratica.getIntPraticaId(), TipoSoggettoUtil.COMMITTENTE); List<Soggetto> committenti = SoggettoLocalServiceUtil.findByIntPratica_TipologiaSoggetto(
for(Soggetto committente : committenti){ lastDettPratica.getIntPraticaId(), TipoSoggettoUtil.COMMITTENTE);
builder.append(committente.getTitle()+" - "+committente.getCodiceFiscale()) for (Soggetto committente : committenti) {
.append(StringPool.COMMA_AND_SPACE); builder.append(committente.getTitle() + " - " + committente.getCodiceFiscale()).append(
StringPool.COMMA_AND_SPACE);
} }
if(builder.length()>0) if (builder.length() > 0)
builder.setLength(builder.length()-12); builder.setLength(builder.length() - 12);
sb.append(builder.toString()); sb.append(builder.toString());
sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON);
User istruttore = UserLocalServiceUtil.fetchUser(intPratica.getStatusByUserId()); User istruttore = UserLocalServiceUtil.fetchUser(intPratica.getStatusByUserId());
if(istruttore!=null){ if (istruttore != null) {
sb.append(istruttore.getFullName()); sb.append(istruttore.getFullName());
} else { } else {
sb.append(""); sb.append("");
} }
sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON);
sb.append(LanguageUtil.get(locale, PraticaUtil.getStatoPraticaLabel(intPratica.getStatoPratica(), intPratica))); sb.append(LanguageUtil.get(locale,
PraticaUtil.getStatoPraticaLabel(intPratica.getStatoPratica(), intPratica)));
sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON);
//ADT BUG-ID=15 Sezione Ricerca / Export csv // ADT BUG-ID=15 Sezione Ricerca / Export csv
sb.append(provincia != null ? provincia.getProvincia() : ""); sb.append(provincia != null ? provincia.getProvincia() : "");
sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON);
sb.append(comune != null ? comune.getDenominazione() : ""); sb.append(comune != null ? comune.getDenominazione() : "");
sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON);
// sb.append("Territorio: " ).append(comune.getDenominazione()).append(!lastDettPratica.getLocalita().isEmpty() ? "(Loc. "+lastDettPratica.getLocalita()+" ) " : "").append(" - ").append(provincia.getProvincia()); // sb.append("Territorio: "
//ADT BUG-ID=15 Sezione Ricerca / Export csv - Max 30 chars // ).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; 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(lastDettPratica.getDescLongIntervento() == null ? "" : lastDettPratica
.getDescLongIntervento().length() > MAX_LENGHT_DESCR_INTERVENTO ? lastDettPratica
.getDescLongIntervento().substring(0, MAX_LENGHT_DESCR_INTERVENTO) : lastDettPratica
.getDescLongIntervento());
sb.append(StringPool.SEMICOLON); sb.append(StringPool.SEMICOLON);
// Territorio: <strong><%= comune.getDenominazione() %> <%= !lastDettPratica.getLocalita().isEmpty() ? "(Loc. "+lastDettPratica.getLocalita()+" ) " : "" %>- <%= provincia.getProvincia() %></strong><br> // Territorio: <strong><%= comune.getDenominazione() %> <%=
// Localizzazione: <strong><%= lastDettPratica.getVia() %></strong><br><br> // !lastDettPratica.getLocalita().isEmpty() ?
// "(Loc. "+lastDettPratica.getLocalita()+" ) " : "" %>- <%=
// provincia.getProvincia() %></strong><br>
// Localizzazione: <strong><%= lastDettPratica.getVia()
// %></strong><br><br>
// <%= lastDettPratica.getDescLongIntervento() %> // <%= lastDettPratica.getDescLongIntervento() %>
} catch(Throwable e){ } catch (Throwable e) {
_log.error(method + " IntPraticaId: " + intPratica != null ? intPratica.getIntPraticaId() : "", e); _log.error(method + " IntPraticaId: " + intPratica != null ? intPratica.getIntPraticaId()
} finally{ : "", e);
} finally {
sb.append(StringPool.NEW_LINE); sb.append(StringPool.NEW_LINE);
} }
} }
// } catch (PortalException e) { // } catch (PortalException e) {
// _log.error(e, e); // _log.error(e, e);
// } catch (SystemException e) { // } catch (SystemException e) {
// _log.error(e, e); // _log.error(e, e);
// } // }
return sb.toString(); return sb.toString();

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

@ -4,13 +4,8 @@ import it.tref.liferay.portos.bo.model.DocPratica;
import it.tref.liferay.portos.bo.service.ConfigurazioneLocalServiceUtil; import it.tref.liferay.portos.bo.service.ConfigurazioneLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil; import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants; import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants;
import it.tref.liferay.portos.bo.util.ContentType;
import java.io.BufferedWriter;
import java.io.File; import java.io.File;
import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
@ -18,6 +13,14 @@ import java.util.concurrent.locks.ReentrantLock;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.ByteArrayBody;
import org.apache.http.entity.mime.content.ContentBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import com.liferay.portal.kernel.dao.orm.QueryUtil; import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.json.JSONArray; import com.liferay.portal.kernel.json.JSONArray;
@ -28,10 +31,8 @@ import com.liferay.portal.kernel.messaging.Message;
import com.liferay.portal.kernel.messaging.MessageListener; import com.liferay.portal.kernel.messaging.MessageListener;
import com.liferay.portal.kernel.messaging.MessageListenerException; import com.liferay.portal.kernel.messaging.MessageListenerException;
import com.liferay.portal.kernel.util.FileUtil; import com.liferay.portal.kernel.util.FileUtil;
import com.liferay.portal.kernel.util.Http.FilePart;
import com.liferay.portal.kernel.util.Http.Options;
import com.liferay.portal.kernel.util.HttpUtil;
import com.liferay.portal.kernel.util.PropsUtil; import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.UniqueList; import com.liferay.portal.kernel.util.UniqueList;
import com.liferay.portal.kernel.workflow.WorkflowConstants; import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.portal.model.Company; import com.liferay.portal.model.Company;
@ -68,9 +69,10 @@ public class SchedulerEstrazioneFirme implements MessageListener {
List<DocPratica> docPratiche = DocPraticaLocalServiceUtil.findByStaus( List<DocPratica> docPratiche = DocPraticaLocalServiceUtil.findByStaus(
WorkflowConstants.STATUS_PENDING, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); WorkflowConstants.STATUS_PENDING, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
for (DocPratica docPratica : docPratiche) {
String urlPdfExtractor = (String) company.getExpandoBridge().getAttribute( String urlPdfExtractor = (String) company.getExpandoBridge().getAttribute(
"url_pdf_extractor", false); "url_pdf_extractor", false);
for (DocPratica docPratica : docPratiche) {
DLFileEntry fileEntry = DLFileEntryLocalServiceUtil.getFileEntry(docPratica DLFileEntry fileEntry = DLFileEntryLocalServiceUtil.getFileEntry(docPratica
.getDlFileEntryId()); .getDlFileEntryId());
User user = UserLocalServiceUtil.getRoleUsers( User user = UserLocalServiceUtil.getRoleUsers(
@ -80,23 +82,18 @@ public class SchedulerEstrazioneFirme implements MessageListener {
.create(user)); .create(user));
byte[] fileBytes = FileUtil.getBytes(fileEntry.getContentStream()); byte[] fileBytes = FileUtil.getBytes(fileEntry.getContentStream());
Options options = new Options(); MultipartEntityBuilder builder = MultipartEntityBuilder.create();
options.setLocation(urlPdfExtractor); ContentBody body = new ByteArrayBody(fileBytes, fileEntry.getTitle());
options.setPost(true); builder.addPart("file", body);
List<FilePart> fileParts = new ArrayList<>(); HttpPost request = new HttpPost(urlPdfExtractor);
fileParts.add(new FilePart("file", fileEntry.getTitle(), fileBytes, request.setEntity(builder.build());
ContentType.P7M.getContentType(), "UTF-8")); CloseableHttpClient client = HttpClientBuilder.create().build();
options.setFileParts(fileParts); HttpResponse response = client.execute(request);
String responseBody; int statusCode = response.getStatusLine().getStatusCode();
try { String responseBody = EntityUtils.toString(response.getEntity(), StringPool.UTF8);
responseBody = HttpUtil.URLtoString(options); if (statusCode == HttpServletResponse.SC_OK
} catch (Exception e) { || statusCode == HttpServletResponse.SC_CREATED) {
responseBody = "";
}
if (options.getResponse().getResponseCode() == HttpServletResponse.SC_OK
|| options.getResponse().getResponseCode() == HttpServletResponse.SC_CREATED) {
JSONArray arrayFirme = JSONFactoryUtil.createJSONObject(responseBody) JSONArray arrayFirme = JSONFactoryUtil.createJSONObject(responseBody)
.getJSONArray("cf"); .getJSONArray("cf");
List<String> cf = new UniqueList<String>(); List<String> cf = new UniqueList<String>();
@ -116,14 +113,16 @@ public class SchedulerEstrazioneFirme implements MessageListener {
errorCode); errorCode);
_log.warn("P7M REST extractor error. Response: " + new String(responseBody) _log.warn("P7M REST extractor error. Response: " + new String(responseBody)
+ " id=" + fileEntry.getFileEntryId()); + " id=" + fileEntry.getFileEntryId());
// salvaCampione(fileEntry, fileBytes, salvaCampione(fileEntry, fileBytes, "0-firme");
// "0-firme");
} }
} }
} }
} }
} catch (Exception e) { } catch (Exception e) {
_log.info("Errore", e); if (_log.isDebugEnabled())
_log.debug("Errore", e);
else
_log.error("Errore " + e.getMessage());
} finally { } finally {
lock.unlock(); lock.unlock();
} }

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

@ -12,6 +12,7 @@
package it.tref.liferay.portos.bo.service.impl; package it.tref.liferay.portos.bo.service.impl;
import it.mwg.sismica.bo.util.HttpServiceUtil;
import it.tref.liferay.portos.bo.NoSuchDettPraticaException; import it.tref.liferay.portos.bo.NoSuchDettPraticaException;
import it.tref.liferay.portos.bo.model.Asseverazione; import it.tref.liferay.portos.bo.model.Asseverazione;
import it.tref.liferay.portos.bo.model.ControlloPratica; import it.tref.liferay.portos.bo.model.ControlloPratica;
@ -1815,8 +1816,6 @@ public class DettPraticaLocalServiceImpl extends DettPraticaLocalServiceBaseImpl
private void updateAsset(DettPratica dettPratica, ServiceContext serviceContext) throws PortalException, private void updateAsset(DettPratica dettPratica, ServiceContext serviceContext) throws PortalException,
SystemException { SystemException {
Locale locale = serviceContext.getLocale();
AssetEntry assetEntry = assetEntryLocalService.updateEntry(dettPratica.getUserId(), AssetEntry assetEntry = assetEntryLocalService.updateEntry(dettPratica.getUserId(),
dettPratica.getGroupId(), dettPratica.getCreateDate(), dettPratica.getModifiedDate(), dettPratica.getGroupId(), dettPratica.getCreateDate(), dettPratica.getModifiedDate(),
DettPratica.class.getName(), dettPratica.getPrimaryKey(), dettPratica.getUuid(), 0L, DettPratica.class.getName(), dettPratica.getPrimaryKey(), dettPratica.getUuid(), 0L,
@ -2179,32 +2178,16 @@ public class DettPraticaLocalServiceImpl extends DettPraticaLocalServiceBaseImpl
return dettPratica; return dettPratica;
} }
public void sendToVersioning(long dettPraticaId, String url) throws PortalException, SystemException, public void sendToVersioning(long dettPraticaId, String url) throws Exception {
NoSuchFieldException, SecurityException, IOException {
DettPratica dettPratica = dettPraticaLocalService.getDettPratica(dettPraticaId); DettPratica dettPratica = dettPraticaLocalService.getDettPratica(dettPraticaId);
String jsonToVersioning = dettPratica.serializeToVersioning(); String jsonToVersioning = dettPratica.serializeToVersioning();
Options options = new Options(); JSONObject response = HttpServiceUtil.postJson(url, jsonToVersioning);
options.setLocation(url);
options.setPost(true);
Body body = new Body(jsonToVersioning, ContentTypes.APPLICATION_JSON, "UTF-8");
options.setBody(body);
String responseBody = HttpUtil.URLtoString(options);
if (options.getResponse().getResponseCode() == HttpServletResponse.SC_OK
|| options.getResponse().getResponseCode() == HttpServletResponse.SC_CREATED) {
JSONObject response = JSONFactoryUtil.createJSONObject(responseBody);
int version = response.getInt("version"); int version = response.getInt("version");
dettPratica.setVersion(version); dettPratica.setVersion(version);
dettPratica.setVersionata(true); dettPratica.setVersionata(true);
dettPraticaLocalService.updateDettPratica(dettPratica); dettPraticaLocalService.updateDettPratica(dettPratica);
} else {
throw new PortalException(options.getResponse().getResponseCode() + StringPool.SPACE
+ responseBody);
}
} }
public int getNumeroDiVersioni(String url) throws IOException, PortalException, SystemException { public int getNumeroDiVersioni(String url) throws IOException, PortalException, SystemException {
@ -2233,7 +2216,7 @@ public class DettPraticaLocalServiceImpl extends DettPraticaLocalServiceBaseImpl
JSONObject snapshot = jsonObjectResponse.getJSONObject("Snapshot"); JSONObject snapshot = jsonObjectResponse.getJSONObject("Snapshot");
int responseVersion = snapshot.getInt("version"); int responseVersion = snapshot.getInt("version");
if (responseVersion != version) { if (responseVersion != version) {
_log.error("Le versioni non corrispondono"); _log.error("Le versioni non corrispondono " + responseVersion + "/" + version);
} }
JSONObject jsonFields = snapshot.getJSONObject("fields"); JSONObject jsonFields = snapshot.getJSONObject("fields");
for (String hiddenField : PraticaUtil.getDettPraticaHiddenFields()) { for (String hiddenField : PraticaUtil.getDettPraticaHiddenFields()) {
@ -2256,6 +2239,7 @@ public class DettPraticaLocalServiceImpl extends DettPraticaLocalServiceBaseImpl
} else { } else {
_log.error(options.getLocation() + ": " + options.getResponse().getResponseCode()); _log.error(options.getLocation() + ": " + options.getResponse().getResponseCode());
} }
// return "{\"values\":[],\"Snapshot\":{\"version\":0,\"fields\":{}}}";
return StringPool.BLANK; return StringPool.BLANK;
} }

3
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, public void sendToVersioning(long dettPraticaId, long companyId) throws Exception {
NoSuchFieldException, SecurityException, IOException {
Company company = CompanyLocalServiceUtil.getCompany(companyId); Company company = CompanyLocalServiceUtil.getCompany(companyId);
String commitURL = (String) company.getExpandoBridge().getAttribute( String commitURL = (String) company.getExpandoBridge().getAttribute(

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

@ -1,5 +1,6 @@
package it.tref.liferay.portos.bo.util; 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.model.Avviso;
import it.tref.liferay.portos.bo.model.Collaudo; import it.tref.liferay.portos.bo.model.Collaudo;
import it.tref.liferay.portos.bo.model.DettPratica; import it.tref.liferay.portos.bo.model.DettPratica;
@ -28,8 +29,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVRecord; import org.apache.commons.csv.CSVRecord;
@ -37,16 +36,11 @@ import org.apache.commons.io.IOUtils;
import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSONFactoryUtil;
import com.liferay.portal.kernel.json.JSONObject; import com.liferay.portal.kernel.json.JSONObject;
import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.repository.model.FileEntry; import com.liferay.portal.kernel.repository.model.FileEntry;
import com.liferay.portal.kernel.util.ContentTypes;
import com.liferay.portal.kernel.util.GetterUtil; import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.Http.Body;
import com.liferay.portal.kernel.util.Http.Options;
import com.liferay.portal.kernel.util.HttpUtil;
import com.liferay.portal.kernel.util.ParamUtil; import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.StreamUtil; import com.liferay.portal.kernel.util.StreamUtil;
import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.StringPool;
@ -61,13 +55,6 @@ public class ProtocollazioneUtil {
private static final Log _log = LogFactoryUtil.getLog(ProtocollazioneUtil.class); private static final Log _log = LogFactoryUtil.getLog(ProtocollazioneUtil.class);
// public static String protocollaPartenza(DettPratica dettPratica, Avviso
// avviso) throws
// Exception {
//
// return protocollaPartenza(dettPratica, avviso, null);
// }
public static String protocollaPartenza(Avviso avviso, Long fileEntryId) throws Exception { public static String protocollaPartenza(Avviso avviso, Long fileEntryId) throws Exception {
String protocollo = null; String protocollo = null;
@ -100,11 +87,10 @@ public class ProtocollazioneUtil {
allegato.setFileSha256(sha256); allegato.setFileSha256(sha256);
} }
// utilizzato anche come discriminate tra la 1a e la 2a chiamata // utilizzato anche come discriminate tra la 1a e la 2a chiamata 1a
// 1a recupero numero protocollo -> 1 allegato finto // recupero numero protocollo -> 1 allegato finto 2a aggiorno dati
// 2a aggiorno dati del documento prodotto -> 2 allegati, il 1o // del documento prodotto -> 2 allegati, il 1o giusto e il 2o per
// giusto e il 2o per recupero // recupero num protocollo
// num protocollo
Protocollo protocolloBean = new Protocollo(); Protocollo protocolloBean = new Protocollo();
protocolloBean.setOggetto(generaOggettoProtocollo(avviso.getClassName(), avviso.getAvvisoId())); protocolloBean.setOggetto(generaOggettoProtocollo(avviso.getClassName(), avviso.getAvvisoId()));
@ -114,17 +100,8 @@ public class ProtocollazioneUtil {
protocolloBean.setUfficioId(String.valueOf(groupId)); protocolloBean.setUfficioId(String.valueOf(groupId));
protocolloBean.setPraticaId(String.valueOf(avviso.getClassPk())); protocolloBean.setPraticaId(String.valueOf(avviso.getClassPk()));
protocolloBean.setFiles(Collections.singletonList(allegato)); protocolloBean.setFiles(Collections.singletonList(allegato));
Options options = createCall(avviso.getCompanyId(), protocolloBean, true); JSONObject risposta = HttpServiceUtil.postProtocolloBean(avviso.getCompanyId(), protocolloBean);
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")); protocollo = risposta.getString("anno") + String.format("%07d", risposta.getInt("numero"));
} else {
throw new Exception(options.getResponse().getResponseCode() + StringPool.SPACE + responseBody);
}
} finally { } finally {
StreamUtil.cleanUp(inputStream); StreamUtil.cleanUp(inputStream);
} }
@ -134,8 +111,6 @@ public class ProtocollazioneUtil {
public static String protocollaArrivo(Object praticaInstance, String title) throws Exception { public static String protocollaArrivo(Object praticaInstance, String title) throws Exception {
String protocollo = null;
long groupId = 0l; long groupId = 0l;
long praticaId = 0l; long praticaId = 0l;
long companyId = 0l; long companyId = 0l;
@ -202,25 +177,13 @@ public class ProtocollazioneUtil {
protocolloBean.setPraticaId(String.valueOf(praticaId)); protocolloBean.setPraticaId(String.valueOf(praticaId));
protocolloBean.setFiles(allegati); protocolloBean.setFiles(allegati);
Options options = createCall(companyId, protocolloBean, true); JSONObject risposta = HttpServiceUtil.postProtocolloBean(companyId, protocolloBean);
return risposta.getString("anno") + String.format("%07d", risposta.getInt("numero"));
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 protocollaArrivoAccessoAtti(long groupId, long companyId, String userName, public static String protocollaArrivoAccessoAtti(long groupId, long companyId, String userName,
long accessoAttiId, String className) throws Exception { long accessoAttiId, String className) throws Exception {
String protocollo = null;
List<File> allegati = new ArrayList<File>(); List<File> allegati = new ArrayList<File>();
File allegato = new File(); File allegato = new File();
String doc = String.valueOf(accessoAttiId); String doc = String.valueOf(accessoAttiId);
@ -238,18 +201,8 @@ public class ProtocollazioneUtil {
protocolloBean.setPraticaId(String.valueOf(accessoAttiId)); protocolloBean.setPraticaId(String.valueOf(accessoAttiId));
protocolloBean.setFiles(allegati); protocolloBean.setFiles(allegati);
Options options = createCall(companyId, protocolloBean, true); JSONObject risposta = HttpServiceUtil.postProtocolloBean(companyId, protocolloBean);
return risposta.getString("anno") + String.format("%07d", risposta.getInt("numero"));
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) { public static String generaOggettoProtocollo(String className, long classPk) {
@ -266,69 +219,6 @@ public class ProtocollazioneUtil {
return "Oggetto: " + className + " " + classPk; return "Oggetto: " + className + " " + classPk;
} }
public static void test() {
String url = "http://172.16.20.148:8080/portos-protocollazione-service/v1/api-rest/genera-protocollo";
// String url =
// "http://10.159.51.84:8080/portos-protocollazione-service/v1/api-rest/genera-protocollo";
Options options = new Options();
options.setLocation(url);
options.setPost(true);
flexjson.JSONSerializer serialize = new flexjson.JSONSerializer();
// JSONSerializer jsonSerializer =
// JSONFactoryUtil.createJSONSerializer();
serialize.exclude("*.class");
Protocollo protocolloBean = new Protocollo();
protocolloBean.setOggetto("oggetto");
protocolloBean.setChiuso(false);
protocolloBean.setTipo(TipoProtocollo.INGRESSO);
protocolloBean.setUtenteId("SSSS");
protocolloBean.setUfficioId("genio");
String protocollo = serialize.serialize(protocolloBean);
Body body = new Body(protocollo, ContentTypes.APPLICATION_JSON, "UTF-8");
options.setBody(body);
try {
String responseBody = HttpUtil.URLtoString(options);
if (options.getResponse().getResponseCode() == HttpServletResponse.SC_OK
|| options.getResponse().getResponseCode() == HttpServletResponse.SC_CREATED) {
System.out.println("ok " + responseBody);
} else {
System.out.println("error " + responseBody);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
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;
}
public static List<OggettoProtocollo> csvToOggettoProtocollo(java.io.File file) public static List<OggettoProtocollo> csvToOggettoProtocollo(java.io.File file)
throws FileNotFoundException, IOException, ParseException { throws FileNotFoundException, IOException, ParseException {

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

@ -13,8 +13,8 @@
## ##
build.namespace=portos_bo build.namespace=portos_bo
build.number=2405 build.number=2426
build.date=1600340894413 build.date=1600769216546
build.auto.upgrade=true build.auto.upgrade=true
## ##

BIN
liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/lib/httpclient.jar

File binario non mostrato.

BIN
liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/lib/httpcore.jar

File binario non mostrato.

BIN
liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/lib/httpmime.jar

File binario non mostrato.
Caricamento…
Annulla
Salva