diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpclient.jar b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpclient.jar new file mode 100644 index 00000000..970c9891 Binary files /dev/null and b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpclient.jar differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpcore.jar b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpcore.jar new file mode 100644 index 00000000..99715b6a Binary files /dev/null and b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpcore.jar differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpmime.jar b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpmime.jar new file mode 100644 index 00000000..b631ceb4 Binary files /dev/null and b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpmime.jar differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/util-java.jar b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/util-java.jar new file mode 100644 index 00000000..6b5d95f8 Binary files /dev/null and b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/util-java.jar differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/mwg/sismica/bo/util/HttpServiceUtil.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/mwg/sismica/bo/util/HttpServiceUtil.java index 5b698001..561c43a2 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/mwg/sismica/bo/util/HttpServiceUtil.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/mwg/sismica/bo/util/HttpServiceUtil.java @@ -37,7 +37,7 @@ public class HttpServiceUtil { return postJson(url, json); } - + public static JSONObject postJson(String url, String json) throws Exception { JSONObject risposta = null; HttpPost request = new HttpPost(url); diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/ValidazionePraticaUtil.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/ValidazionePraticaUtil.java index 2edc86b4..be04fcc3 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/tref/liferay/portos/bo/util/ValidazionePraticaUtil.java +++ b/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.SoggettoLocalServiceUtil; 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.util.Constants; 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.TipoIntegrazioneUtil; 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 java.io.IOException; @@ -39,6 +37,15 @@ import java.util.List; 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.exception.PortalException; 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.log.Log; 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.StringPool; import com.liferay.portal.kernel.util.UniqueList; import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.workflow.WorkflowConstants; @@ -2476,27 +2481,23 @@ public class ValidazionePraticaUtil { Company company = CompanyLocalServiceUtil.getCompany(companyId); String urlPdfExtractor = (String) company.getExpandoBridge().getAttribute("url_pdf_extractor", false); - Options options = new Options(); - options.setLocation(urlPdfExtractor); - options.setPost(true); - List fileParts = new ArrayList<>(); - // Complimenti all'ignoto autore di questo magnifico TODO - // TODO perché cazzo non funziona il contentType??? - FilePart filePart = new FilePart("file", fileName, fileBytes, "application/pkcs7-signature", "UTF-8"); - fileParts.add(filePart); - options.setFileParts(fileParts); - - String responseBody = HttpUtil.URLtoString(options); - - if (options.getResponse().getResponseCode() == HttpServletResponse.SC_OK - || options.getResponse().getResponseCode() == HttpServletResponse.SC_CREATED) { - + HttpPost request = new HttpPost(urlPdfExtractor); + MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + builder.addPart("file", new ByteArrayBody(fileBytes, fileName)); + request.setEntity(builder.build()); + CloseableHttpClient client = HttpClientBuilder.create().build(); + HttpResponse httpResponse = client.execute(request); + int statusCode = httpResponse.getStatusLine().getStatusCode(); + String responseBody = EntityUtils.toString(httpResponse.getEntity(), StringPool.UTF8); + client.close(); + + if (statusCode == HttpServletResponse.SC_OK || statusCode == HttpServletResponse.SC_CREATED) { JSONArray arrayFirme = JSONFactoryUtil.createJSONObject(responseBody).getJSONArray("cf"); List cf = new UniqueList(); for (int i = 0; i < arrayFirme.length(); i++) { cf.add(arrayFirme.getString(i)); } - return cf; } else { diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties index 4dd86d5d..c0658d2f 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties @@ -13,8 +13,8 @@ ## build.namespace=portos_bo - build.number=2415 - build.date=1600698455241 + build.number=2426 + build.date=1600769216546 build.auto.upgrade=true ## diff --git a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/lib/httpcore.jar b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/lib/httpcore.jar new file mode 100644 index 00000000..99715b6a Binary files /dev/null and b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/lib/httpcore.jar differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/lib/httpmime.jar b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/lib/httpmime.jar new file mode 100644 index 00000000..b631ceb4 Binary files /dev/null and b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/lib/httpmime.jar differ