|
|
@ -41,6 +41,8 @@ import it.tref.liferay.portos.bo.service.SorteggioLocalServiceUtil; |
|
|
|
import it.tref.liferay.portos.bo.service.StoricoSoggettoPraticaLocalServiceUtil; |
|
|
|
import it.tref.liferay.portos.bo.service.StoricoSoggettoPraticaLocalServiceUtil; |
|
|
|
import it.tref.liferay.portos.bo.service.TempisticaLocalServiceUtil; |
|
|
|
import it.tref.liferay.portos.bo.service.TempisticaLocalServiceUtil; |
|
|
|
import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants; |
|
|
|
import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants; |
|
|
|
|
|
|
|
import it.tref.liferay.portos.bo.shared.util.StatoPraticaConstants; |
|
|
|
|
|
|
|
import it.tref.liferay.portos.bo.util.AvvisoUtil; |
|
|
|
import it.tref.liferay.portos.bo.util.Constants; |
|
|
|
import it.tref.liferay.portos.bo.util.Constants; |
|
|
|
import it.tref.liferay.portos.mailmanager.model.Email; |
|
|
|
import it.tref.liferay.portos.mailmanager.model.Email; |
|
|
|
import it.tref.liferay.portos.mailmanager.model.EmailAttachment; |
|
|
|
import it.tref.liferay.portos.mailmanager.model.EmailAttachment; |
|
|
@ -50,6 +52,9 @@ import it.tref.liferay.portos.mailmanager.service.EmailAttachmentLocalServiceUti |
|
|
|
import it.tref.liferay.portos.mailmanager.service.EmailLocalServiceUtil; |
|
|
|
import it.tref.liferay.portos.mailmanager.service.EmailLocalServiceUtil; |
|
|
|
import it.tref.liferay.portos.mailmanager.service.EmailTemplateLocalServiceUtil; |
|
|
|
import it.tref.liferay.portos.mailmanager.service.EmailTemplateLocalServiceUtil; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.sql.Connection; |
|
|
|
|
|
|
|
import java.sql.SQLException; |
|
|
|
|
|
|
|
import java.sql.Statement; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
@ -58,11 +63,14 @@ import java.util.Set; |
|
|
|
import com.liferay.portal.kernel.cache.CacheRegistryUtil; |
|
|
|
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.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; |
|
|
|
import com.liferay.portal.kernel.log.LogFactoryUtil; |
|
|
|
import com.liferay.portal.kernel.log.LogFactoryUtil; |
|
|
|
|
|
|
|
import com.liferay.portal.kernel.repository.model.FileEntry; |
|
|
|
import com.liferay.portal.kernel.servlet.DirectServletRegistryUtil; |
|
|
|
import com.liferay.portal.kernel.servlet.DirectServletRegistryUtil; |
|
|
|
|
|
|
|
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.kernel.util.Validator; |
|
|
|
import com.liferay.portal.kernel.workflow.WorkflowInstance; |
|
|
|
import com.liferay.portal.kernel.workflow.WorkflowInstance; |
|
|
@ -108,6 +116,7 @@ import com.liferay.portlet.documentlibrary.model.DLFileEntryType; |
|
|
|
import com.liferay.portlet.documentlibrary.model.DLFolder; |
|
|
|
import com.liferay.portlet.documentlibrary.model.DLFolder; |
|
|
|
import com.liferay.portlet.documentlibrary.model.DLSyncConstants; |
|
|
|
import com.liferay.portlet.documentlibrary.model.DLSyncConstants; |
|
|
|
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.DLFileEntryTypeLocalServiceUtil; |
|
|
|
import com.liferay.portlet.documentlibrary.service.DLFileEntryTypeLocalServiceUtil; |
|
|
|
import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil; |
|
|
|
import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil; |
|
|
|
import com.liferay.portlet.dynamicdatamapping.model.DDMStructure; |
|
|
|
import com.liferay.portlet.dynamicdatamapping.model.DDMStructure; |
|
|
@ -158,11 +167,19 @@ public class ManutenzioneDatabase { |
|
|
|
public static List<String> pulisci(ServiceContext serviceContext, String mode) throws SystemException, |
|
|
|
public static List<String> pulisci(ServiceContext serviceContext, String mode) throws SystemException, |
|
|
|
PortalException { |
|
|
|
PortalException { |
|
|
|
List<String> esito = new ArrayList<>(); |
|
|
|
List<String> esito = new ArrayList<>(); |
|
|
|
|
|
|
|
long companyId = serviceContext.getCompanyId(); |
|
|
|
if (mode.contains("!Pulisci!")) { |
|
|
|
if (mode.contains("!Pulisci!")) { |
|
|
|
long companyId = serviceContext.getCompanyId(); |
|
|
|
|
|
|
|
esito.addAll(puliziaDocumentLibrary(companyId)); |
|
|
|
esito.addAll(puliziaDocumentLibrary(companyId)); |
|
|
|
|
|
|
|
esitoLog( |
|
|
|
|
|
|
|
esito, |
|
|
|
|
|
|
|
puliziaAllegati(companyId, ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(companyId, |
|
|
|
|
|
|
|
ConfigurazioneConstants.ATTACHMENT_FOLDER_ID))); |
|
|
|
|
|
|
|
esitoLog( |
|
|
|
|
|
|
|
esito, |
|
|
|
|
|
|
|
puliziaAllegati(companyId, ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(companyId, |
|
|
|
|
|
|
|
AvvisoUtil.getAllTipoDocumentoFolderProps().get(StatoPraticaConstants.CONFORME)))); |
|
|
|
if (mode.contains("!IntPratica!")) { |
|
|
|
if (mode.contains("!IntPratica!")) { |
|
|
|
esitoLog(esito, svuotaIntPratica()); |
|
|
|
esitoLog(esito, svuotaIntPraticaDettPratica()); |
|
|
|
} |
|
|
|
} |
|
|
|
if (mode.contains("!User!")) { |
|
|
|
if (mode.contains("!User!")) { |
|
|
|
esitoLog(esito, svuotaUser(companyId)); |
|
|
|
esitoLog(esito, svuotaUser(companyId)); |
|
|
@ -172,13 +189,7 @@ public class ManutenzioneDatabase { |
|
|
|
ConfigurazioneLocalServiceUtil.storeConfig(Constants.NUMERO_PROGETTO_KEY_DB, "1", |
|
|
|
ConfigurazioneLocalServiceUtil.storeConfig(Constants.NUMERO_PROGETTO_KEY_DB, "1", |
|
|
|
serviceContext); |
|
|
|
serviceContext); |
|
|
|
} |
|
|
|
} |
|
|
|
try { |
|
|
|
clearCache(); |
|
|
|
SingleVMPoolUtil.clear(); |
|
|
|
|
|
|
|
MultiVMPoolUtil.clear(); |
|
|
|
|
|
|
|
CacheRegistryUtil.clear(); |
|
|
|
|
|
|
|
DirectServletRegistryUtil.clearServlets(); |
|
|
|
|
|
|
|
} catch (IllegalStateException e) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
_log.info("Elaborazione completata correttamente."); |
|
|
|
_log.info("Elaborazione completata correttamente."); |
|
|
|
} else if (mode.contains("!Integrazioni!")) { |
|
|
|
} else if (mode.contains("!Integrazioni!")) { |
|
|
|
SismicaUtil.integrazioniScadute(); |
|
|
|
SismicaUtil.integrazioniScadute(); |
|
|
@ -188,6 +199,16 @@ public class ManutenzioneDatabase { |
|
|
|
return esito; |
|
|
|
return esito; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void clearCache() { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
SingleVMPoolUtil.clear(); |
|
|
|
|
|
|
|
MultiVMPoolUtil.clear(); |
|
|
|
|
|
|
|
CacheRegistryUtil.clear(); |
|
|
|
|
|
|
|
DirectServletRegistryUtil.clearServlets(); |
|
|
|
|
|
|
|
} catch (IllegalStateException e) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static List<String> svuotaDatabase(long companyId) throws SystemException, PortalException { |
|
|
|
private static List<String> svuotaDatabase(long companyId) throws SystemException, PortalException { |
|
|
|
List<String> esito = new ArrayList<>(); |
|
|
|
List<String> esito = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
@ -298,6 +319,78 @@ public class ManutenzioneDatabase { |
|
|
|
return esito; |
|
|
|
return esito; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static List<Long> avvisiFileEntries() throws SystemException { |
|
|
|
|
|
|
|
List<Long> result = new ArrayList<>(); |
|
|
|
|
|
|
|
int start = 0; |
|
|
|
|
|
|
|
List<Avviso> avvisi = null; |
|
|
|
|
|
|
|
do { |
|
|
|
|
|
|
|
avvisi = AvvisoLocalServiceUtil.getAvvisos(start, start + SLICE); |
|
|
|
|
|
|
|
for (Avviso avviso : avvisi) { |
|
|
|
|
|
|
|
result.add(avviso.getFileEntryIdBase()); |
|
|
|
|
|
|
|
result.add(avviso.getFileEntryIdProtocollo()); |
|
|
|
|
|
|
|
result.add(avviso.getFileEntryIdInvio()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
start += SLICE; |
|
|
|
|
|
|
|
} while (avvisi.size() > 0); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static String puliziaAllegati(long companyId, long folderId) throws SystemException, |
|
|
|
|
|
|
|
PortalException { |
|
|
|
|
|
|
|
List<Long> avvisiFileEntries = avvisiFileEntries(); |
|
|
|
|
|
|
|
long repositoryId = DLAppLocalServiceUtil.getFolder(folderId).getRepositoryId(); |
|
|
|
|
|
|
|
int start = 0; |
|
|
|
|
|
|
|
int cancellati = 0; |
|
|
|
|
|
|
|
List<FileEntry> fileEntries = null; |
|
|
|
|
|
|
|
do { |
|
|
|
|
|
|
|
int rimossi = 0; |
|
|
|
|
|
|
|
fileEntries = DLAppServiceUtil.getFileEntries(repositoryId, folderId, start, start + SLICE); |
|
|
|
|
|
|
|
for (FileEntry fileEntry : fileEntries) { |
|
|
|
|
|
|
|
String[] parti = StringUtil.split(fileEntry.getTitle(), StringPool.UNDERLINE); |
|
|
|
|
|
|
|
String strId1 = parti[0]; |
|
|
|
|
|
|
|
String tipo = StringPool.BLANK; |
|
|
|
|
|
|
|
String strId2 = StringPool.BLANK; |
|
|
|
|
|
|
|
switch (parti.length) { |
|
|
|
|
|
|
|
case 3: |
|
|
|
|
|
|
|
tipo = parti[1]; |
|
|
|
|
|
|
|
strId2 = parti[2]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 4: |
|
|
|
|
|
|
|
tipo = parti[1] + StringPool.UNDERLINE + parti[2]; |
|
|
|
|
|
|
|
strId2 = parti[3]; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if ((strId1.length() == 10) && (strId2.length() > 0) && SismicaUtil.isLong(strId1) |
|
|
|
|
|
|
|
&& SismicaUtil.isLong(strId2)) { |
|
|
|
|
|
|
|
long id1 = Long.parseLong(strId1); |
|
|
|
|
|
|
|
switch (tipo) { |
|
|
|
|
|
|
|
case "AS": |
|
|
|
|
|
|
|
if (!esiste(DETTPRATICA_CLASS_NAME, id1)) { |
|
|
|
|
|
|
|
DLAppLocalServiceUtil.deleteFileEntry(fileEntry.getFileEntryId()); |
|
|
|
|
|
|
|
cancellati++; |
|
|
|
|
|
|
|
rimossi++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case "CO_B": |
|
|
|
|
|
|
|
if (!avvisiFileEntries.contains(fileEntry.getFileEntryId())) { |
|
|
|
|
|
|
|
DLAppLocalServiceUtil.deleteFileEntry(fileEntry.getFileEntryId()); |
|
|
|
|
|
|
|
cancellati++; |
|
|
|
|
|
|
|
rimossi++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
_log.info("Tipo sconosciuto " + tipo + " (" + fileEntry.getTitle() + ")"); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
_log.info("Nome sconosciuto " + fileEntry.getTitle()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
start += SLICE - rimossi; |
|
|
|
|
|
|
|
} while (fileEntries.size() > 0); |
|
|
|
|
|
|
|
return "Cancellati " + cancellati + " File orfani"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static String svuotaAllegatoManuale() throws SystemException { |
|
|
|
private static String svuotaAllegatoManuale() throws SystemException { |
|
|
|
int start = 0; |
|
|
|
int start = 0; |
|
|
|
int cancellati = 0; |
|
|
|
int cancellati = 0; |
|
|
@ -583,21 +676,19 @@ public class ManutenzioneDatabase { |
|
|
|
return "Cancellati " + cancellati + " FineLavori"; |
|
|
|
return "Cancellati " + cancellati + " FineLavori"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static String svuotaIntPratica() throws SystemException, PortalException { |
|
|
|
// Troncare le tabelle è l'unico modo possibile
|
|
|
|
int start = 0; |
|
|
|
private static String svuotaIntPraticaDettPratica() { |
|
|
|
int cancellati = 0; |
|
|
|
int i = 0; |
|
|
|
List<IntPratica> intPratiche = null; |
|
|
|
int d = 0; |
|
|
|
do { |
|
|
|
try { |
|
|
|
int rimossi = 0; |
|
|
|
Connection connection = DataAccess.getUpgradeOptimizedConnection(); |
|
|
|
intPratiche = IntPraticaLocalServiceUtil.getIntPraticas(start, start + SLICE); |
|
|
|
Statement s = connection.createStatement(); |
|
|
|
for (IntPratica intPratica : intPratiche) { |
|
|
|
i = s.executeUpdate("DELETE FROM portos_bo_intpratica"); |
|
|
|
IntPraticaLocalServiceUtil.deleteIntPratica(intPratica, true); |
|
|
|
d = s.executeUpdate("DELETE FROM portos_bo_dettpratica"); |
|
|
|
cancellati++; |
|
|
|
} catch (SQLException e) { |
|
|
|
rimossi++; |
|
|
|
} |
|
|
|
} |
|
|
|
clearCache(); |
|
|
|
start += SLICE - rimossi; |
|
|
|
return "Cancellati " + i + " IntPratica, " + d + " DettPratica"; |
|
|
|
} while (intPratiche.size() > 0); |
|
|
|
|
|
|
|
return "Cancellati " + cancellati + " IntPratica"; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static String svuotaGroup(long companyId) throws SystemException, PortalException { |
|
|
|
private static String svuotaGroup(long companyId) throws SystemException, PortalException { |
|
|
|