diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/portal-service.jar b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/portal-service.jar deleted file mode 100644 index 8c1d9a7d..00000000 Binary files a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/portal-service.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..843b9433 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 @@ -38,7 +38,8 @@ - + + Verifica Pagamenti it.tref.liferay.portos.bo.scheduler.VerificaPagamentiScheduler diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/IntPraticaLocalServiceImpl.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/IntPraticaLocalServiceImpl.java index 455b4f0f..46cf8afc 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/IntPraticaLocalServiceImpl.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/IntPraticaLocalServiceImpl.java @@ -70,7 +70,6 @@ import it.tref.liferay.portos.report.shared.util.ReportUtil; import java.io.IOException; import java.io.Serializable; import java.sql.Connection; -import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.Calendar; @@ -117,10 +116,16 @@ import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.workflow.WorkflowException; import com.liferay.portal.kernel.workflow.WorkflowHandlerRegistryUtil; +import com.liferay.portal.kernel.workflow.WorkflowInstance; import com.liferay.portal.kernel.workflow.WorkflowTask; +import com.liferay.portal.model.Company; +import com.liferay.portal.model.Organization; +import com.liferay.portal.model.Role; import com.liferay.portal.model.User; import com.liferay.portal.model.WorkflowInstanceLink; import com.liferay.portal.security.permission.PermissionThreadLocal; +import com.liferay.portal.service.ClassNameLocalServiceUtil; +import com.liferay.portal.service.CompanyLocalServiceUtil; import com.liferay.portal.service.ServiceContext; import com.liferay.portal.service.UserLocalServiceUtil; import com.liferay.portal.service.WorkflowInstanceLinkLocalServiceUtil; @@ -133,9 +138,13 @@ import com.liferay.portal.workflow.kaleo.model.KaleoTaskInstanceToken; import com.liferay.portlet.documentlibrary.NoSuchFolderException; import com.liferay.portlet.documentlibrary.model.DLFileEntry; import com.liferay.portlet.documentlibrary.model.DLFolder; +import com.liferay.portlet.documentlibrary.model.DLSyncConstants; import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil; import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil; import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil; +import com.liferay.portlet.dynamicdatamapping.model.DDMContent; +import com.liferay.portlet.dynamicdatamapping.model.DDMStorageLink; +import com.liferay.portlet.messageboards.model.MBDiscussion; import com.liferay.portlet.social.model.SocialActivity; /** @@ -382,7 +391,7 @@ public class IntPraticaLocalServiceImpl extends IntPraticaLocalServiceBaseImpl { for (Entry> entry : svuotare.entrySet()) { String table = entry.getKey(); String className = entry.getValue().getName(); - + statement.execute("TRUNCATE TABLE " + table); esitoLog(esito, "Tabella " + table + " svuotata"); counterLocalService.increment(className); @@ -391,12 +400,6 @@ public class IntPraticaLocalServiceImpl extends IntPraticaLocalServiceBaseImpl { } configurazioneLocalService.storeConfig(Constants.NUMERO_PROGETTO_KEY_DB, "1", serviceContext); - // Reset di tutte le cache - SingleVMPoolUtil.clear(); - MultiVMPoolUtil.clear(); - CacheRegistryUtil.clear(); - DirectServletRegistryUtil.clearServlets(); - // Pulizia Document Library int start = 0; int totali = 0; @@ -463,6 +466,157 @@ public class IntPraticaLocalServiceImpl extends IntPraticaLocalServiceBaseImpl { _log.info("Analizzate " + totali + " cartelle, cancellate " + cancellati); } while (folders.size() > 0); esitoLog(esito, "Analizzate " + totali + " cartelle, cancellate " + cancellati); + + // Utenti + start = 0; + List nonCancellare = new ArrayList<>(); + List users; + do { + users = UserLocalServiceUtil.getUsers(start, start + SLICE); + totali += users.size(); + for (User user : users) { + long companyId = user.getCompanyId(); + Company company = CompanyLocalServiceUtil.getCompany(companyId); + long defaultUserId = company.getDefaultUser().getUserId(); + boolean isAdmin = false; + for (Role role : user.getRoles()) { + if (role.getName().equals("Administrator")) { + isAdmin = true; + break; + } + } + if (isAdmin || (defaultUserId == user.getUserId())) { + nonCancellare.add(user.getUserId()); + esitoLog(esito, + "Non cancello l'utente " + user.getScreenName() + ", " + user.getFirstName() + + " " + user.getLastName()); + } + } + start += users.size(); + } while (users.size() > 0); + long userClassNameId = ClassNameLocalServiceUtil.getClassName(User.class.getName()) + .getClassNameId(); + long controlloPraticaClassNameId = ClassNameLocalServiceUtil.getClassName( + ControlloPratica.class.getName()).getClassNameId(); + long dettPraticaClassNameId = ClassNameLocalServiceUtil.getClassName(DettPratica.class.getName()) + .getClassNameId(); + long workflowInstanceClassNameId = ClassNameLocalServiceUtil.getClassName( + WorkflowInstance.class.getName()).getClassNameId(); + long dlFileEntryClassNameId = ClassNameLocalServiceUtil.getClassName(DLFileEntry.class.getName()) + .getClassNameId(); + long dlFolderClassNameId = ClassNameLocalServiceUtil.getClassName(DLFolder.class.getName()) + .getClassNameId(); + long mbDiscussionClassNameId = ClassNameLocalServiceUtil.getClassName( + MBDiscussion.class.getName()).getClassNameId(); + long ddmContentClassNameId = ClassNameLocalServiceUtil.getClassName(DDMContent.class.getName()) + .getClassNameId(); + + // Utenti, gruppi, organizzazioni + String ids = StringUtils.join(nonCancellare, ","); + statement.execute("DELETE FROM user_ WHERE userid NOT IN (" + ids + ")"); + statement.execute("DELETE FROM group_ WHERE classnameid=" + userClassNameId + + " AND classpk NOT IN (" + ids + ")"); + statement.execute("DELETE FROM contact_ WHERE classnameid=" + userClassNameId + + " AND classpk NOT IN (" + ids + ")"); + statement.execute("DELETE FROM usergroup WHERE userid NOT IN (" + ids + ")"); + statement.execute("DELETE FROM usergrouprole WHERE userid NOT IN (" + ids + ")"); + statement.execute("DELETE FROM users_groups WHERE userid NOT IN (" + ids + ")"); + statement.execute("DELETE FROM users_orgs WHERE userid NOT IN (" + ids + ")"); + statement.execute("DELETE FROM users_roles WHERE userid NOT IN (" + ids + ")"); + + // DDMContent + statement.execute("DELETE FROM dlfileentrymetadata WHERE fileentrymetadataid IN (" + + "SELECT fileentrymetadataid FROM dlfileentrymetadata LEFT JOIN dlfileentry " + + "ON dlfileentrymetadata.fileentryid=dlfileentry.fileentryid " + + "WHERE dlfileentry.fileentryid IS NULL)"); + statement.execute("DELETE FROM ddmcontent WHERE contentid IN (" + + "SELECT contentid FROM ddmcontent LEFT JOIN dlfileentrymetadata " + + "ON ddmcontent.contentid=dlfileentrymetadata.ddmstorageid WHERE name='" + + DDMStorageLink.class.getName() + + "' AND dlfileentrymetadata.fileentrymetadataid IS NULL)"); + statement.execute("DELETE FROM ddmstoragelink WHERE storagelinkid IN (" + + "SELECT storagelinkid FROM ddmstoragelink LEFT JOIN ddmcontent " + + "ON ddmstoragelink.classpk=ddmcontent.contentid " + "WHERE ddmstoragelink.classnameid=" + + ddmContentClassNameId + " AND ddmcontent.contentid IS NULL" + ")"); + + // Message board + statement.execute("DELETE FROM mbdiscussion WHERE classnameid IN (" + workflowInstanceClassNameId + + ")"); + statement.execute("DELETE FROM mbdiscussion WHERE discussionid IN (" + + "SELECT discussionid FROM mbdiscussion LEFT JOIN dlfileentry " + + "ON mbdiscussion.classpk=dlfileentry.fileentryid WHERE mbdiscussion.classnameid=" + + dlFileEntryClassNameId + " AND dlfileentry.fileentryid IS NULL)"); + statement.execute("DELETE FROM mbmessage WHERE classnameid IN (" + workflowInstanceClassNameId + + ")"); + statement.execute("DELETE FROM mbmessage WHERE messageid IN (" + + "SELECT messageid FROM mbdiscussion LEFT JOIN dlfileentry " + + "ON mbmessage.classpk=dlfileentry.fileentryid WHERE mbmessage.classnameid=" + + dlFileEntryClassNameId + " AND dlfileentry.fileentryid IS NULL)"); + statement.execute("DELETE FROM mbthread WHERE threadid IN (" + + "SELECT DISTINCT mbthread.threadid FROM mbthread LEFT JOIN mbmessage " + + "ON mbthread.threadid=mbmessage.threadid WHERE mbmessage.messageid IS NULL)"); + + // Ratings stats + statement.execute("DELETE FROM ratingsstats WHERE classnameid=" + controlloPraticaClassNameId); + statement.execute("DELETE FROM ratingsstats WHERE statsid IN (" + + "SELECT statsid FROM ratingsstats LEFT JOIN dlfileentry " + + "ON ratingsstats.classpk=dlfileentry.fileentryid WHERE ratingsstats.classnameid=" + + dlFileEntryClassNameId + " AND dlfileentry.fileentryid IS NULL)"); + statement.execute("DELETE FROM ratingsstats WHERE statsid IN (" + + "SELECT statsid FROM ratingsstats LEFT JOIN dlfolder " + + "ON ratingsstats.classpk=dlfolder.folderid WHERE ratingsstats.classnameid=" + + dlFolderClassNameId + " AND dlfolder.folderid IS NULL)"); + + // Resource permission + statement.execute("DELETE FROM resourcepermission WHERE name='" + + ControlloPratica.class.getName() + "'"); + statement + .execute("DELETE FROM resourcepermission WHERE resourcepermissionid IN (" + + "SELECT resourcepermissionid FROM resourcepermission LEFT JOIN dlfileentry " + + "ON resourcepermission.primkey=dlfileentry.fileentryid::TEXT WHERE resourcepermission.name='" + + DLFileEntry.class.getName() + "' AND dlfileentry.fileentryid IS NULL)"); + statement.execute("DELETE FROM resourcepermission WHERE resourcepermissionid IN (" + + "SELECT resourcepermissionid FROM resourcepermission LEFT JOIN dlfolder " + + "ON resourcepermission.primkey=dlfolder.folderid::TEXT WHERE resourcepermission.name='" + + DLFolder.class.getName() + "' AND dlfolder.folderid IS NULL)"); + + statement.execute("DELETE FROM systemevent WHERE classnameid=" + userClassNameId + + " AND classpk NOT IN (" + ids + ")"); + + // Asset entry + statement.execute("DELETE FROM assetentry WHERE classnameid=" + userClassNameId + + " AND classpk NOT IN (" + ids + ")"); + statement.execute("DELETE FROM assetentry WHERE classnameid IN (" + controlloPraticaClassNameId + + "," + dettPraticaClassNameId + ")"); + statement.execute("DELETE FROM assetentry WHERE entryid IN (" + + "SELECT entryid FROM assetentry LEFT JOIN dlfileentry " + + "ON assetentry.classpk=dlfileentry.fileentryid WHERE assetentry.classnameid=" + + dlFileEntryClassNameId + " AND dlfileentry.fileentryid IS NULL)"); + statement.execute("DELETE FROM assetentry WHERE entryid IN (" + + "SELECT entryid FROM assetentry LEFT JOIN dlfolder " + + "ON assetentry.classpk=dlfolder.folderid WHERE assetentry.classnameid=" + + dlFolderClassNameId + " AND dlfolder.folderid IS NULL)"); + statement.execute("DELETE FROM assetentry WHERE entryid IN (" + + "SELECT entryid FROM assetentry LEFT JOIN mbdiscussion " + + "ON assetentry.classpk=mbdiscussion.discussionid WHERE assetentry.classnameid=" + + mbDiscussionClassNameId + " AND mbdiscussion.discussionid IS NULL)"); + + // DLSyncObject + statement.execute("DELETE FROM syncdlobject WHERE syncdlobjectid IN (" + + "SELECT syncdlobjectid FROM syncdlobject LEFT JOIN dlfileentry " + + "ON syncdlobject.typepk=dlfileentry.fileentryid WHERE type_='" + + DLSyncConstants.TYPE_FILE + "' AND dlfileentry.fileentryid IS NULL)"); + statement.execute("DELETE FROM syncdlobject WHERE syncdlobjectid IN (" + + "SELECT syncdlobjectid FROM syncdlobject LEFT JOIN dlfolder " + + "ON syncdlobject.typepk=dlfolder.folderid WHERE type_='" + + DLSyncConstants.TYPE_FOLDER + "' AND dlfolder.folderid IS NULL)"); + + // Reset di tutte le cache + SingleVMPoolUtil.clear(); + MultiVMPoolUtil.clear(); + CacheRegistryUtil.clear(); + DirectServletRegistryUtil.clearServlets(); + } catch (Exception e) { esitoLog(esito, "Errore: " + e.getMessage()); } diff --git a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/lib/portal-service.jar b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/lib/portal-service.jar deleted file mode 100644 index 8c1d9a7d..00000000 Binary files a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/lib/portal-service.jar and /dev/null differ diff --git a/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/portal-service.jar b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/portal-service.jar deleted file mode 100644 index 8c1d9a7d..00000000 Binary files a/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/docroot/WEB-INF/lib/portal-service.jar and /dev/null differ diff --git a/liferay-plugins-sdk-6.2/shared/portos-report-shared/lib/portal-service.jar b/liferay-plugins-sdk-6.2/shared/portos-report-shared/lib/portal-service.jar deleted file mode 100644 index 8c1d9a7d..00000000 Binary files a/liferay-plugins-sdk-6.2/shared/portos-report-shared/lib/portal-service.jar and /dev/null differ