Salvatore La Manna 4 anni fa
parent
commit
8ca03fa4df
  1. 2
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/liferay-portlet.xml
  2. 34
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/service/it/mwg/sismica/bo/util/HttpServiceUtil.java
  3. 38
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/PuliziaDatabase.java
  4. 4
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/service.properties
  5. 3
      liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/report/messaging/ProtocolloMessageListener.java
  6. 85
      liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/report/service/impl/ReportTaskManagerServiceImpl.java
  7. 4
      liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/src/service.properties

2
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/liferay-portlet.xml

@ -1,8 +1,6 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 6.2.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_6_2_0.dtd"> <!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 6.2.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_6_2_0.dtd">
<liferay-portlet-app> <liferay-portlet-app>
<portlet> <portlet>
<portlet-name>1</portlet-name> <portlet-name>1</portlet-name>
<icon>/icon.png</icon> <icon>/icon.png</icon>

34
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; 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.service.ConfigurazioneLocalServiceUtil;
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.util.ConfigurazioneConstants; 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.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils; 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.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.util.ContentTypes; 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.HttpUtil;
import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.Http.Options; 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 { public static JSONObject postProtocolloBean(long companyId, Protocollo protocolloBean) throws Exception {
flexjson.JSONSerializer serializer = new flexjson.JSONSerializer(); JSONSerializer serializer = new JSONSerializer();
serializer.exclude("*.class"); serializer.exclude("*.class");
String json = serializer.serialize(protocolloBean); String json = serializer.serialize(protocolloBean);
String url = ConfigurazioneLocalServiceUtil.findByC_ChiaveString(companyId, String url = ConfigurazioneLocalServiceUtil.findByC_ChiaveString(companyId,
ConfigurazioneConstants.PROTOCOLLAZIONE_SERVICE_URL); ConfigurazioneConstants.PROTOCOLLAZIONE_SERVICE_URL);
return postJson(url, json);
}
public static JSONObject postJson(String url, String json) throws Exception {
JSONObject risposta = null; JSONObject risposta = null;
HttpPost request = new HttpPost(url); HttpPost request = new HttpPost(url);
request.setHeader("Content-type", ContentTypes.APPLICATION_JSON); request.addHeader("Content-type", ContentTypes.APPLICATION_JSON);
request.setEntity(new StringEntity(json)); request.setEntity(new StringEntity(json, StringPool.UTF8));
CloseableHttpClient client = HttpClientBuilder.create().build(); CloseableHttpClient client = HttpClientBuilder.create().build();
HttpResponse response = client.execute(request); HttpResponse response = client.execute(request);
@ -55,7 +54,24 @@ public class HttpServiceUtil {
_log.info(url + " || " + json + " || " + risposta); _log.info(url + " || " + json + " || " + risposta);
} else { } else {
_log.info(url + " || " + json + " || " + statusCode + ": " + responseBody); _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; return risposta;
} }

38
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; 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.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.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.FineLavori;
import it.tref.liferay.portos.bo.model.IntPratica; import it.tref.liferay.portos.bo.model.IntPratica;
import it.tref.liferay.portos.bo.model.Soggetto; 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.CollaudoLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DelegaLocalServiceUtil; import it.tref.liferay.portos.bo.service.DelegaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil; 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.MultiVMPoolUtil;
import com.liferay.portal.kernel.cache.SingleVMPoolUtil; import com.liferay.portal.kernel.cache.SingleVMPoolUtil;
import com.liferay.portal.kernel.dao.jdbc.DataAccess; 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.PortalException;
import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log; 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 Log _log = LogFactoryUtil.getLog(PuliziaDatabase.class);
private static final int SLICE = 1000; private static final int SLICE = 1000;
public static List<String> pulisci2(ServiceContext serviceContext) {
List<String> esito = new ArrayList<>();
int numeroPratiche = 0;
try {
List<IntPratica> pratiche = null;
int start = 0;
do {
pratiche = IntPraticaLocalServiceUtil.getIntPraticas(start, start + SLICE);
for (IntPratica pratica : pratiche) {
List<Avviso> 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<String> pulisci(ServiceContext serviceContext) { public static List<String> pulisci(ServiceContext serviceContext) {
List<String> esito = new ArrayList<>(); List<String> esito = new ArrayList<>();
@ -71,6 +108,7 @@ public class PuliziaDatabase {
MultiVMPoolUtil.clear(); MultiVMPoolUtil.clear();
CacheRegistryUtil.clear(); CacheRegistryUtil.clear();
DirectServletRegistryUtil.clearServlets(); DirectServletRegistryUtil.clearServlets();
// WebCachePoolUtil.clear();
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
} }

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=2427 build.number=2444
build.date=1600851464644 build.date=1600956928654
build.auto.upgrade=true build.auto.upgrade=true
## ##

3
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.ServiceContext;
import com.liferay.portal.service.UserLocalServiceUtil; import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portlet.documentlibrary.DuplicateFileException; 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.DLAppLocalServiceUtil;
import com.liferay.portlet.documentlibrary.service.DLAppServiceUtil; 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.bo.shared.util.Constants;
import it.tref.liferay.portos.report.shared.constants.ReportConstants; import it.tref.liferay.portos.report.shared.constants.ReportConstants;
import it.tref.liferay.portos.report.shared.constants.ReportConstants.ReportResult; import it.tref.liferay.portos.report.shared.constants.ReportConstants.ReportResult;

85
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.StreamUtil;
import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.StringUtil; 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.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.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.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.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.html.core.HtmlToPdfEngine;
import it.tref.liferay.portos.report.jasper.core.provider.JasperPdfProvider; import it.tref.liferay.portos.report.jasper.core.provider.JasperPdfProvider;
@ -110,7 +128,6 @@ public class ReportTaskManagerServiceImpl extends ReportTaskManagerServiceBaseIm
fileEntryTemplate.getFileEntryId(), fileEntryTemplate.getVersion(), false); fileEntryTemplate.getFileEntryId(), fileEntryTemplate.getVersion(), false);
// generazione report // generazione report
if (reportType.equals(ReportType.JRXML_TO_PDF)) { if (reportType.equals(ReportType.JRXML_TO_PDF)) {
// Object dataSource = reportDto.getDataSource(); // Object dataSource = reportDto.getDataSource();
@ -168,20 +185,44 @@ public class ReportTaskManagerServiceImpl extends ReportTaskManagerServiceBaseIm
// recupero folder dove inserire report generato // 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 title = reportDto.getFileName();
String sourceFileName = title + StringPool.PERIOD + "pdf"; String fileName = title + StringPool.PERIOD + "pdf";
String mimeType = MimeTypesUtil.getContentType(sourceFileName); String mimeType = MimeTypesUtil.getContentType(fileName);
// se è già presente lo cancello // se è già presente lo cancello
// FileEntry fileEntry = null;
try { // try {
FileEntry fileEntry = dlAppLocalService.getFileEntry(folder.getGroupId(), // fileEntry =
folder.getFolderId(), title); // DLAppLocalServiceUtil.getFileEntry(groupId,
dlAppLocalService.deleteFileEntry(fileEntry.getFileEntryId()); // folderId,
} catch (PortalException e) { // 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 // inserimento con permessi di view per site member
@ -190,19 +231,23 @@ public class ReportTaskManagerServiceImpl extends ReportTaskManagerServiceBaseIm
serviceContext.setUserId(userId); serviceContext.setUserId(userId);
serviceContext.setGroupPermissions(new String[] { ActionKeys.VIEW }); serviceContext.setGroupPermissions(new String[] { ActionKeys.VIEW });
_log.info("addFileEntry userId=" + serviceContext.getUserId() + ", repositoryId=" _log.info("addFileEntry userId=" + userId + ", repositoryId=" + repositoryId + ", folderId="
+ folder.getRepositoryId() + ", folderId=" + folder.getFolderId() + folderId + ", sourceFileName=" + fileName + ", mimeType=" + mimeType + ", title="
+ ", sourceFileName=" + sourceFileName + ", mimeType=" + mimeType + ", title="
+ title); + title);
FileEntry fileEntry = dlAppLocalService.addFileEntry(serviceContext.getUserId(), FileEntry fileEntry = null;
folder.getRepositoryId(), folder.getFolderId(), sourceFileName, mimeType, title, try {
StringPool.BLANK, StringPool.BLANK, bytes, serviceContext); 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()); fileEntryIds = ArrayUtil.append(fileEntryIds, fileEntry.getFileEntryId());
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
throw new SystemException(e);
} }
return fileEntryIds; return fileEntryIds;

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

@ -13,8 +13,8 @@
## ##
build.namespace=portos_rep build.namespace=portos_rep
build.number=18 build.number=22
build.date=1577444175789 build.date=1600955423028
build.auto.upgrade=true build.auto.upgrade=true
## ##

Caricamento…
Annulla
Salva