|
|
|
@ -7,6 +7,7 @@ import it.tref.liferay.portos.bo.model.ControlloPratica;
|
|
|
|
|
import it.tref.liferay.portos.bo.model.DettPratica; |
|
|
|
|
import it.tref.liferay.portos.bo.model.DocPratica; |
|
|
|
|
import it.tref.liferay.portos.bo.model.IntPratica; |
|
|
|
|
import it.tref.liferay.portos.bo.model.Pagamento; |
|
|
|
|
import it.tref.liferay.portos.bo.model.Sorteggio; |
|
|
|
|
import it.tref.liferay.portos.bo.model.Territorio; |
|
|
|
|
import it.tref.liferay.portos.bo.service.ConfigurazioneLocalService; |
|
|
|
@ -17,6 +18,7 @@ import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil;
|
|
|
|
|
import it.tref.liferay.portos.bo.service.DocPraticaLocalService; |
|
|
|
|
import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil; |
|
|
|
|
import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil; |
|
|
|
|
import it.tref.liferay.portos.bo.service.PagamentoLocalServiceUtil; |
|
|
|
|
import it.tref.liferay.portos.bo.service.SorteggioLocalServiceUtil; |
|
|
|
|
import it.tref.liferay.portos.bo.service.TerritorioLocalServiceUtil; |
|
|
|
|
import it.tref.liferay.portos.bo.service.persistence.DocPraticaPersistenceImpl; |
|
|
|
@ -96,13 +98,21 @@ public class SismicaAdministrationPortlet extends MVCPortlet {
|
|
|
|
|
public void sostituisciDL(ActionRequest actionRequest, ActionResponse actionResponse) throws SystemException, PortalException, IOException { |
|
|
|
|
SismicaUtil.sostituisciDL(actionRequest, actionResponse); |
|
|
|
|
|
|
|
|
|
Long userId = null; |
|
|
|
|
long userId = 0; |
|
|
|
|
String title = null; |
|
|
|
|
String description = null; |
|
|
|
|
String mimeType = null; |
|
|
|
|
String changeLog = StringPool.BLANK; |
|
|
|
|
FileEntry fileEntry = null; |
|
|
|
|
Date now = new Date(); |
|
|
|
|
long companyId = 0; |
|
|
|
|
long groupId = 0; |
|
|
|
|
long defaultFolderId = 0; |
|
|
|
|
Folder defaultFolder = null; |
|
|
|
|
String folderName = null; |
|
|
|
|
byte[] bytes = null; |
|
|
|
|
long folderId = 0; |
|
|
|
|
long repositoryId = 0; |
|
|
|
|
ServiceContext serviceContext = new ServiceContext(); |
|
|
|
|
|
|
|
|
|
String className = ParamUtil.getString(actionRequest, "className"); |
|
|
|
@ -117,18 +127,18 @@ public class SismicaAdministrationPortlet extends MVCPortlet {
|
|
|
|
|
case "it.tref.liferay.portos.bo.model.DocPratica": |
|
|
|
|
DocPratica pratica = DocPraticaLocalServiceUtil.getDocPratica(idOggetto); |
|
|
|
|
userId = pratica.getUserId(); |
|
|
|
|
long companyId = pratica.getCompanyId(); |
|
|
|
|
long groupId = pratica.getGroupId(); |
|
|
|
|
companyId = pratica.getCompanyId(); |
|
|
|
|
groupId = pratica.getGroupId(); |
|
|
|
|
|
|
|
|
|
serviceContext.setCompanyId(companyId); |
|
|
|
|
serviceContext.setScopeGroupId(groupId); |
|
|
|
|
serviceContext.setUserId(userId); |
|
|
|
|
|
|
|
|
|
long defaultFolderId = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(companyId, ConfigurazioneConstants.ATTACHMENT_FOLDER_ID); |
|
|
|
|
Folder defaultFolder = DLAppLocalServiceUtil.getFolder(defaultFolderId); |
|
|
|
|
String folderName = PraticaUtil.getFolderName(pratica.getClassPk()); |
|
|
|
|
long folderId = defaultFolder.getFolderId(); |
|
|
|
|
long repositoryId = defaultFolder.getRepositoryId(); |
|
|
|
|
defaultFolderId = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(companyId, ConfigurazioneConstants.ATTACHMENT_FOLDER_ID); |
|
|
|
|
defaultFolder = DLAppLocalServiceUtil.getFolder(defaultFolderId); |
|
|
|
|
folderName = PraticaUtil.getFolderName(pratica.getClassPk()); |
|
|
|
|
folderId = defaultFolder.getFolderId(); |
|
|
|
|
repositoryId = defaultFolder.getRepositoryId(); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
folder = DLAppLocalServiceUtil.getFolder(repositoryId, folderId, folderName); |
|
|
|
@ -137,16 +147,16 @@ public class SismicaAdministrationPortlet extends MVCPortlet {
|
|
|
|
|
StringPool.BLANK, serviceContext); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
byte[] bytes = FileUtil.getBytes(file); |
|
|
|
|
bytes = FileUtil.getBytes(file); |
|
|
|
|
title = pratica.getTipologia() + StringPool.UNDERLINE + sourceFileName; |
|
|
|
|
description = sourceFileName; |
|
|
|
|
mimeType = MimeTypesUtil.getContentType(sourceFileName); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
/*try { |
|
|
|
|
DLAppLocalServiceUtil.deleteFileEntry(pratica.getDlFileEntryId()); |
|
|
|
|
} catch(PortalException e){ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
fileEntry = DLAppLocalServiceUtil.getFileEntry(pratica.getDlFileEntryId()); |
|
|
|
@ -157,14 +167,61 @@ public class SismicaAdministrationPortlet extends MVCPortlet {
|
|
|
|
|
fileEntry = DLAppLocalServiceUtil.addFileEntry(userId, folder.getRepositoryId(), folder.getFolderId(), now.getTime() + "_" + sourceFileName, |
|
|
|
|
mimeType, title, description, changeLog, bytes, serviceContext); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*fileEntry = DLAppLocalServiceUtil.addFileEntry(userId, folder.getRepositoryId(), folder.getFolderId(), now.getTime() + "_" |
|
|
|
|
+ sourceFileName, mimeType, title, description, changeLog, bytes, serviceContext);*/ |
|
|
|
|
|
|
|
|
|
pratica.setDlFileEntryId(fileEntry.getFileEntryId()); |
|
|
|
|
pratica.setSha256(DigestUtils.sha256Hex(bytes)); |
|
|
|
|
DocPraticaLocalServiceUtil.updateDocPratica(pratica); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case "it.tref.liferay.portos.bo.model.Pagamento": |
|
|
|
|
Pagamento pagamento = PagamentoLocalServiceUtil.getPagamento(idOggetto); |
|
|
|
|
userId = pagamento.getUserId(); |
|
|
|
|
companyId = pagamento.getCompanyId(); |
|
|
|
|
groupId = pagamento.getGroupId(); |
|
|
|
|
|
|
|
|
|
serviceContext.setCompanyId(companyId); |
|
|
|
|
serviceContext.setScopeGroupId(groupId); |
|
|
|
|
serviceContext.setUserId(userId); |
|
|
|
|
|
|
|
|
|
defaultFolderId = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(companyId, ConfigurazioneConstants.ATTACHMENT_FOLDER_ID); |
|
|
|
|
defaultFolder = DLAppLocalServiceUtil.getFolder(defaultFolderId); |
|
|
|
|
folderName = PraticaUtil.getFolderName(pagamento.getClassPk()); |
|
|
|
|
folderId = defaultFolder.getFolderId(); |
|
|
|
|
repositoryId = defaultFolder.getRepositoryId(); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
folder = DLAppLocalServiceUtil.getFolder(repositoryId, folderId, folderName); |
|
|
|
|
} catch (NoSuchFolderException e) { |
|
|
|
|
folder = DLAppLocalServiceUtil.addFolder(userId, repositoryId, folderId, folderName, |
|
|
|
|
StringPool.BLANK, serviceContext); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bytes = FileUtil.getBytes(file); |
|
|
|
|
title = now.getTime() + StringPool.UNDERLINE + "pagamento_manuale" + StringPool.UNDERLINE |
|
|
|
|
+ pagamento.getPagamentoId() + StringPool.UNDERLINE + sourceFileName; |
|
|
|
|
description = StringPool.BLANK; |
|
|
|
|
mimeType = MimeTypesUtil.getContentType(sourceFileName); |
|
|
|
|
|
|
|
|
|
/*try { |
|
|
|
|
DLAppLocalServiceUtil.deleteFileEntry(pagamento.getFileEntryId()); |
|
|
|
|
} catch(PortalException e){ |
|
|
|
|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
fileEntry = DLAppLocalServiceUtil.getFileEntry(pagamento.getFileEntryId()); |
|
|
|
|
fileEntry = DLAppLocalServiceUtil.updateFileEntry(userId, fileEntry.getFileEntryId(), |
|
|
|
|
now.getTime() + "_" + sourceFileName, mimeType, title, description, changeLog, false, bytes, |
|
|
|
|
serviceContext); |
|
|
|
|
} catch (PortalException e) { |
|
|
|
|
fileEntry = DLAppLocalServiceUtil.addFileEntry(userId, folder.getRepositoryId(), folder.getFolderId(), now.getTime() + "_" + sourceFileName, |
|
|
|
|
mimeType, title, description, changeLog, bytes, serviceContext); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pagamento.setFileEntryId(fileEntry.getFileEntryId()); |
|
|
|
|
PagamentoLocalServiceUtil.updatePagamento(pagamento); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|