|
|
@ -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,27 +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)); |
|
|
|
// Complimenti all'ignoto autore di questo magnifico TODO
|
|
|
|
request.setEntity(builder.build()); |
|
|
|
// TODO perché cazzo non funziona il contentType???
|
|
|
|
CloseableHttpClient client = HttpClientBuilder.create().build(); |
|
|
|
FilePart filePart = new FilePart("file", fileName, fileBytes, "application/pkcs7-signature", "UTF-8"); |
|
|
|
HttpResponse httpResponse = client.execute(request); |
|
|
|
fileParts.add(filePart); |
|
|
|
int statusCode = httpResponse.getStatusLine().getStatusCode(); |
|
|
|
options.setFileParts(fileParts); |
|
|
|
String responseBody = EntityUtils.toString(httpResponse.getEntity(), StringPool.UTF8); |
|
|
|
|
|
|
|
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 { |
|
|
|