diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpclient.jar b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpclient.jar deleted file mode 100644 index 970c9891..00000000 Binary files a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpclient.jar and /dev/null differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/util-java.jar b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/util-java.jar deleted file mode 100644 index 6b5d95f8..00000000 Binary files a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/util-java.jar and /dev/null differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/liferay-portlet.xml b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/liferay-portlet.xml index 2ac06f44..b22e004d 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/liferay-portlet.xml +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/liferay-portlet.xml @@ -1,14 +1,12 @@ - - 1 /icon.png it.tref.liferay.portos.bo.indexer.IntPraticaIndexer it.tref.liferay.portos.bo.indexer.ControlloPraticaIndexer - + Estrazione Firme it.tref.liferay.portos.bo.scheduler.SchedulerEstrazioneFirme @@ -38,7 +36,7 @@ - + Sorteggio Pratiche it.mwg.sismica.bo.scheduler.SchedulerSorteggio @@ -87,7 +85,7 @@ - it.tref.liferay.portos.bo.asset.ControlloPraticaAssetRendererFactory + it.tref.liferay.portos.bo.asset.ControlloPraticaAssetRendererFactory it.tref.liferay.portos.bo.workflow.ControlloPraticaWorkflowHandler /css/main.css 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 561c43a2..32f8861f 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 @@ -1,5 +1,8 @@ package it.mwg.sismica.bo.util; +import java.io.IOException; + +import flexjson.JSONSerializer; 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; @@ -13,12 +16,12 @@ 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.Http.Body; import com.liferay.portal.kernel.util.HttpUtil; import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.Http.Options; @@ -28,21 +31,17 @@ public class HttpServiceUtil { public static JSONObject postProtocolloBean(long companyId, Protocollo protocolloBean) throws Exception { - flexjson.JSONSerializer serializer = new flexjson.JSONSerializer(); + JSONSerializer serializer = new 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)); + request.addHeader("Content-type", ContentTypes.APPLICATION_JSON); + request.setEntity(new StringEntity(json, StringPool.UTF8)); CloseableHttpClient client = HttpClientBuilder.create().build(); HttpResponse response = client.execute(request); @@ -55,7 +54,24 @@ public class HttpServiceUtil { _log.info(url + " || " + json + " || " + risposta); } else { _log.info(url + " || " + json + " || " + statusCode + ": " + responseBody); - throw new PortalException(statusCode + StringPool.SPACE + responseBody); + } + return risposta; + } + + public static JSONObject postJson(String url, String json) throws Exception { + JSONObject risposta = null; + Options options = new Options(); + options.setLocation(url); + options.setPost(true); + options.addHeader("Content-Type", ContentTypes.APPLICATION_JSON); + Body body = new Body(json, 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) { + risposta = JSONFactoryUtil.createJSONObject(responseBody); + } else { + throw new Exception(options.getResponse().getResponseCode() + StringPool.SPACE + responseBody); } return risposta; } diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/PuliziaDatabase.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/PuliziaDatabase.java index 3eda1db2..b0ab1e40 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/PuliziaDatabase.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/PuliziaDatabase.java @@ -5,6 +5,7 @@ */ package it.mwg.sismica.bo.util; +import it.tref.liferay.portos.bo.model.Avviso; import it.tref.liferay.portos.bo.model.Collaudo; import it.tref.liferay.portos.bo.model.ControlloPratica; import it.tref.liferay.portos.bo.model.Delega; @@ -14,6 +15,7 @@ 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.AvvisoLocalServiceUtil; import it.tref.liferay.portos.bo.service.CollaudoLocalServiceUtil; import it.tref.liferay.portos.bo.service.DelegaLocalServiceUtil; import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil; @@ -33,6 +35,7 @@ import com.liferay.portal.kernel.cache.CacheRegistryUtil; import com.liferay.portal.kernel.cache.MultiVMPoolUtil; import com.liferay.portal.kernel.cache.SingleVMPoolUtil; import com.liferay.portal.kernel.dao.jdbc.DataAccess; +import com.liferay.portal.kernel.dao.orm.QueryUtil; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.kernel.log.Log; @@ -59,6 +62,40 @@ public class PuliziaDatabase { private static final Log _log = LogFactoryUtil.getLog(PuliziaDatabase.class); private static final int SLICE = 1000; + public static List pulisci2(ServiceContext serviceContext) { + List esito = new ArrayList<>(); + int numeroPratiche = 0; + try { + List pratiche = null; + int start = 0; + do { + pratiche = IntPraticaLocalServiceUtil.getIntPraticas(start, start + SLICE); + for (IntPratica pratica : pratiche) { + List avvisi = AvvisoLocalServiceUtil.findByIntPratica(pratica.getIntPraticaId(), + QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); + int noFile = 0; + for (Avviso avviso : avvisi) { + if (0 == avviso.getFileEntryIdBase()) { + AvvisoLocalServiceUtil.deleteAvviso(avviso); + noFile++; + } + } + if (noFile > 0) { + esitoLog(esito, + "Pratica " + pratica.getNumeroProgetto() + "(" + pratica.getIntPraticaId() + + ") - " + avvisi.size() + " avvisi, eliminati: " + noFile); + } + } + start += SLICE; + numeroPratiche += pratiche.size(); + } while (pratiche.size() > 0); + esitoLog(esito, numeroPratiche + " pratiche"); + } catch (Exception e) { + esitoLog(esito, "Interrotto per errore: " + e.getMessage()); + } + return esito; + } + public static List pulisci(ServiceContext serviceContext) { List esito = new ArrayList<>(); @@ -71,6 +108,7 @@ public class PuliziaDatabase { MultiVMPoolUtil.clear(); CacheRegistryUtil.clear(); DirectServletRegistryUtil.clearServlets(); + // WebCachePoolUtil.clear(); } catch (IllegalStateException e) { } 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 c0658d2f..8c2330a0 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=2426 - build.date=1600769216546 + build.number=2444 + build.date=1600956928654 build.auto.upgrade=true ## diff --git a/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/report/messaging/ProtocolloMessageListener.java b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/report/messaging/ProtocolloMessageListener.java index 93089f84..c2e704a8 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/report/messaging/ProtocolloMessageListener.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/report/messaging/ProtocolloMessageListener.java @@ -35,11 +35,8 @@ import com.liferay.portal.service.RoleLocalServiceUtil; import com.liferay.portal.service.ServiceContext; import com.liferay.portal.service.UserLocalServiceUtil; import com.liferay.portlet.documentlibrary.DuplicateFileException; -import com.liferay.portlet.documentlibrary.model.DLFileEntry; import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil; import com.liferay.portlet.documentlibrary.service.DLAppServiceUtil; -import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil; - import it.tref.liferay.portos.bo.shared.util.Constants; import it.tref.liferay.portos.report.shared.constants.ReportConstants; import it.tref.liferay.portos.report.shared.constants.ReportConstants.ReportResult; diff --git a/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/report/service/impl/ReportTaskManagerServiceImpl.java b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/report/service/impl/ReportTaskManagerServiceImpl.java index 8db4af78..ad9b6858 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/report/service/impl/ReportTaskManagerServiceImpl.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/report/service/impl/ReportTaskManagerServiceImpl.java @@ -28,10 +28,28 @@ import com.liferay.portal.kernel.util.MimeTypesUtil; import com.liferay.portal.kernel.util.StreamUtil; import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.StringUtil; +import com.liferay.portal.kernel.util.Validator; +import com.liferay.portal.model.Role; +import com.liferay.portal.model.RoleConstants; +import com.liferay.portal.model.User; +import com.liferay.portal.security.auth.PrincipalThreadLocal; import com.liferay.portal.security.permission.ActionKeys; +import com.liferay.portal.security.permission.PermissionChecker; +import com.liferay.portal.security.permission.PermissionCheckerFactoryUtil; +import com.liferay.portal.security.permission.PermissionThreadLocal; +import com.liferay.portal.service.RoleLocalServiceUtil; import com.liferay.portal.service.ServiceContext; +import com.liferay.portal.service.UserLocalServiceUtil; +import com.liferay.portlet.documentlibrary.DuplicateFileException; +import com.liferay.portlet.documentlibrary.NoSuchFileEntryException; +import com.liferay.portlet.documentlibrary.service.DLAppHelperLocalServiceUtil; import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil; +import com.liferay.portlet.documentlibrary.service.DLAppServiceUtil; +import com.liferay.portlet.documentlibrary.service.DLContentLocalServiceUtil; import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil; +import com.liferay.portlet.documentlibrary.util.DLAppHelperThreadLocal; +import com.liferay.portlet.documentlibrary.util.DLProcessorRegistryUtil; +import com.liferay.portlet.trash.service.TrashEntryLocalServiceUtil; import it.tref.liferay.portos.report.html.core.HtmlToPdfEngine; import it.tref.liferay.portos.report.jasper.core.provider.JasperPdfProvider; @@ -110,7 +128,6 @@ public class ReportTaskManagerServiceImpl extends ReportTaskManagerServiceBaseIm fileEntryTemplate.getFileEntryId(), fileEntryTemplate.getVersion(), false); // generazione report - if (reportType.equals(ReportType.JRXML_TO_PDF)) { // Object dataSource = reportDto.getDataSource(); @@ -168,20 +185,44 @@ public class ReportTaskManagerServiceImpl extends ReportTaskManagerServiceBaseIm // recupero folder dove inserire report generato - Folder folder = DLAppLocalServiceUtil.getFolder(reportDto.getFolderId()); + long folderId = reportDto.getFolderId(); + Folder folder = DLAppLocalServiceUtil.getFolder(folderId); + long groupId = folder.getGroupId(); + long repositoryId = folder.getRepositoryId(); String title = reportDto.getFileName(); - String sourceFileName = title + StringPool.PERIOD + "pdf"; - String mimeType = MimeTypesUtil.getContentType(sourceFileName); + String fileName = title + StringPool.PERIOD + "pdf"; + String mimeType = MimeTypesUtil.getContentType(fileName); // se è già presente lo cancello - - try { - FileEntry fileEntry = dlAppLocalService.getFileEntry(folder.getGroupId(), - folder.getFolderId(), title); - dlAppLocalService.deleteFileEntry(fileEntry.getFileEntryId()); - } catch (PortalException e) { - } + // FileEntry fileEntry = null; + // try { + // fileEntry = + // DLAppLocalServiceUtil.getFileEntry(groupId, + // folderId, + // title); + // } catch (PortalException e) { + // } + // if (Validator.isNotNull(fileEntry)) { + // _log.info("Cancello file entry " + + // fileEntry.getFileEntryId()); + // + // Role role = RoleLocalServiceUtil.getRole(companyId, + // RoleConstants.ADMINISTRATOR); + // User user = + // UserLocalServiceUtil.getRoleUsers(role.getRoleId(), 0, + // 1).get(0); + // PermissionChecker permissionChecker = + // PermissionCheckerFactoryUtil.create(user); + // + // PrincipalThreadLocal.setName(user.getUserId()); + // PermissionThreadLocal.setPermissionChecker(permissionChecker); + // + // DLAppServiceUtil.deleteFileEntry(fileEntry.getFileEntryId()); + // DLAppLocalServiceUtil.deleteFileEntry(fileEntry.getFileEntryId()); + // + // DLAppHelperLocalServiceUtil.deleteFileEntry(fileEntry); + // } // inserimento con permessi di view per site member @@ -190,19 +231,23 @@ public class ReportTaskManagerServiceImpl extends ReportTaskManagerServiceBaseIm serviceContext.setUserId(userId); serviceContext.setGroupPermissions(new String[] { ActionKeys.VIEW }); - _log.info("addFileEntry userId=" + serviceContext.getUserId() + ", repositoryId=" - + folder.getRepositoryId() + ", folderId=" + folder.getFolderId() - + ", sourceFileName=" + sourceFileName + ", mimeType=" + mimeType + ", title=" + _log.info("addFileEntry userId=" + userId + ", repositoryId=" + repositoryId + ", folderId=" + + folderId + ", sourceFileName=" + fileName + ", mimeType=" + mimeType + ", title=" + title); - FileEntry fileEntry = dlAppLocalService.addFileEntry(serviceContext.getUserId(), - folder.getRepositoryId(), folder.getFolderId(), sourceFileName, mimeType, title, - StringPool.BLANK, StringPool.BLANK, bytes, serviceContext); - + FileEntry fileEntry = null; + try { + fileEntry = DLAppLocalServiceUtil.getFileEntry(groupId, folderId, title); + fileEntry = DLAppLocalServiceUtil.updateFileEntry(userId, fileEntry.getFileEntryId(), + fileName, mimeType, title, StringPool.BLANK, StringPool.BLANK, false, bytes, + serviceContext); + } catch (PortalException e) { + fileEntry = DLAppLocalServiceUtil.addFileEntry(userId, repositoryId, folderId, fileName, + mimeType, title, StringPool.BLANK, StringPool.BLANK, bytes, serviceContext); + } fileEntryIds = ArrayUtil.append(fileEntryIds, fileEntry.getFileEntryId()); } } catch (Exception e) { - - throw new SystemException(e); + e.printStackTrace(); } return fileEntryIds; diff --git a/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/src/service.properties b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/src/service.properties index 35195345..dadb7231 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/src/service.properties +++ b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/src/service.properties @@ -13,8 +13,8 @@ ## build.namespace=portos_rep - build.number=18 - build.date=1577444175789 + build.number=22 + build.date=1600955423028 build.auto.upgrade=true ##