|
|
@ -5,16 +5,26 @@ import it.mwg.sismica.bo.util.SismicaUtil; |
|
|
|
import it.mwg.sismica.bo.util.SorteggioPraticaUtil; |
|
|
|
import it.mwg.sismica.bo.util.SorteggioPraticaUtil; |
|
|
|
import it.tref.liferay.portos.bo.model.ControlloPratica; |
|
|
|
import it.tref.liferay.portos.bo.model.ControlloPratica; |
|
|
|
import it.tref.liferay.portos.bo.model.DettPratica; |
|
|
|
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.IntPratica; |
|
|
|
import it.tref.liferay.portos.bo.model.Sorteggio; |
|
|
|
import it.tref.liferay.portos.bo.model.Sorteggio; |
|
|
|
import it.tref.liferay.portos.bo.model.Territorio; |
|
|
|
import it.tref.liferay.portos.bo.model.Territorio; |
|
|
|
|
|
|
|
import it.tref.liferay.portos.bo.service.ConfigurazioneLocalService; |
|
|
|
|
|
|
|
import it.tref.liferay.portos.bo.service.ConfigurazioneLocalServiceUtil; |
|
|
|
import it.tref.liferay.portos.bo.service.ConfigurazioneServiceUtil; |
|
|
|
import it.tref.liferay.portos.bo.service.ConfigurazioneServiceUtil; |
|
|
|
import it.tref.liferay.portos.bo.service.ControlloPraticaLocalServiceUtil; |
|
|
|
import it.tref.liferay.portos.bo.service.ControlloPraticaLocalServiceUtil; |
|
|
|
import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil; |
|
|
|
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.IntPraticaLocalServiceUtil; |
|
|
|
import it.tref.liferay.portos.bo.service.SorteggioLocalServiceUtil; |
|
|
|
import it.tref.liferay.portos.bo.service.SorteggioLocalServiceUtil; |
|
|
|
import it.tref.liferay.portos.bo.service.TerritorioLocalServiceUtil; |
|
|
|
import it.tref.liferay.portos.bo.service.TerritorioLocalServiceUtil; |
|
|
|
|
|
|
|
import it.tref.liferay.portos.bo.service.persistence.DocPraticaPersistenceImpl; |
|
|
|
|
|
|
|
import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants; |
|
|
|
|
|
|
|
import it.tref.liferay.portos.bo.util.PraticaUtil; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.sql.SQLException; |
|
|
|
import java.sql.SQLException; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
@ -25,16 +35,28 @@ import java.util.Map; |
|
|
|
import javax.portlet.ActionRequest; |
|
|
|
import javax.portlet.ActionRequest; |
|
|
|
import javax.portlet.ActionResponse; |
|
|
|
import javax.portlet.ActionResponse; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.codec.digest.DigestUtils; |
|
|
|
|
|
|
|
|
|
|
|
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.repository.model.Folder; |
|
|
|
|
|
|
|
import com.liferay.portal.kernel.upload.UploadPortletRequest; |
|
|
|
|
|
|
|
import com.liferay.portal.kernel.util.DigesterUtil; |
|
|
|
|
|
|
|
import com.liferay.portal.kernel.util.MimeTypesUtil; |
|
|
|
import com.liferay.portal.kernel.util.ParamUtil; |
|
|
|
import com.liferay.portal.kernel.util.ParamUtil; |
|
|
|
|
|
|
|
import com.liferay.portal.kernel.util.FileUtil; |
|
|
|
|
|
|
|
import com.liferay.portal.kernel.util.StringPool; |
|
|
|
import com.liferay.portal.kernel.util.Validator; |
|
|
|
import com.liferay.portal.kernel.util.Validator; |
|
|
|
import com.liferay.portal.kernel.util.WebKeys; |
|
|
|
import com.liferay.portal.kernel.util.WebKeys; |
|
|
|
import com.liferay.portal.service.ServiceContext; |
|
|
|
import com.liferay.portal.service.ServiceContext; |
|
|
|
import com.liferay.portal.service.ServiceContextFactory; |
|
|
|
import com.liferay.portal.service.ServiceContextFactory; |
|
|
|
import com.liferay.portal.theme.ThemeDisplay; |
|
|
|
import com.liferay.portal.theme.ThemeDisplay; |
|
|
|
|
|
|
|
import com.liferay.portal.util.PortalUtil; |
|
|
|
|
|
|
|
import com.liferay.portlet.documentlibrary.NoSuchFolderException; |
|
|
|
|
|
|
|
import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil; |
|
|
|
import com.liferay.util.bridges.mvc.MVCPortlet; |
|
|
|
import com.liferay.util.bridges.mvc.MVCPortlet; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -71,8 +93,84 @@ public class SismicaAdministrationPortlet extends MVCPortlet { |
|
|
|
actionResponse.setRenderParameter("esito", esito.toArray(new String[esito.size()])); |
|
|
|
actionResponse.setRenderParameter("esito", esito.toArray(new String[esito.size()])); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void sostituisciDL(ActionRequest actionRequest, ActionResponse actionResponse) { |
|
|
|
public void sostituisciDL(ActionRequest actionRequest, ActionResponse actionResponse) throws SystemException, PortalException, IOException { |
|
|
|
SismicaUtil.sostituisciDL(actionRequest, actionResponse); |
|
|
|
SismicaUtil.sostituisciDL(actionRequest, actionResponse); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Long userId = null; |
|
|
|
|
|
|
|
String title = null; |
|
|
|
|
|
|
|
String description = null; |
|
|
|
|
|
|
|
String mimeType = null; |
|
|
|
|
|
|
|
String changeLog = StringPool.BLANK; |
|
|
|
|
|
|
|
FileEntry fileEntry = null; |
|
|
|
|
|
|
|
Date now = new Date(); |
|
|
|
|
|
|
|
ServiceContext serviceContext = new ServiceContext(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String className = ParamUtil.getString(actionRequest, "className"); |
|
|
|
|
|
|
|
Long idOggetto = ParamUtil.getLong(actionRequest, "classPK"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest); |
|
|
|
|
|
|
|
String sourceFileName = uploadRequest.getFileName("file"); |
|
|
|
|
|
|
|
File file = uploadRequest.getFile("file"); |
|
|
|
|
|
|
|
Folder folder = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch(className){ |
|
|
|
|
|
|
|
case "it.tref.liferay.portos.bo.model.DocPratica": |
|
|
|
|
|
|
|
DocPratica pratica = DocPraticaLocalServiceUtil.getDocPratica(idOggetto); |
|
|
|
|
|
|
|
userId = pratica.getUserId(); |
|
|
|
|
|
|
|
long companyId = pratica.getCompanyId(); |
|
|
|
|
|
|
|
long 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(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
folder = DLAppLocalServiceUtil.getFolder(repositoryId, folderId, folderName); |
|
|
|
|
|
|
|
} catch (NoSuchFolderException e) { |
|
|
|
|
|
|
|
folder = DLAppLocalServiceUtil.addFolder(userId, repositoryId, folderId, folderName, |
|
|
|
|
|
|
|
StringPool.BLANK, serviceContext); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
byte[] bytes = FileUtil.getBytes(file); |
|
|
|
|
|
|
|
title = pratica.getTipologia() + StringPool.UNDERLINE + sourceFileName; |
|
|
|
|
|
|
|
description = sourceFileName; |
|
|
|
|
|
|
|
mimeType = MimeTypesUtil.getContentType(sourceFileName); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
DLAppLocalServiceUtil.deleteFileEntry(pratica.getDlFileEntryId()); |
|
|
|
|
|
|
|
} catch(PortalException e){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
fileEntry = DLAppLocalServiceUtil.getFileEntry(pratica.getDlFileEntryId()); |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*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; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void resetFirme(ActionRequest actionRequest, ActionResponse actionResponse) { |
|
|
|
public void resetFirme(ActionRequest actionRequest, ActionResponse actionResponse) { |
|
|
|