Completato
Refresh"); - - } else { - super.serveResource(resourceRequest, resourceResponse); - } - } catch (PortalException | SystemException e) { - _log.error(e, e); - throw new IOException(e); - } - } + private Log _log = LogFactoryUtil.getLog(AllegatiManualiPortlet.class); + + public void uploadAllegatoManuale(ActionRequest actionRequest, ActionResponse actionResponse) + throws PortalException, SystemException { + try { + UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest); + ServiceContext serviceContext = ServiceContextFactory.getInstance(uploadRequest); + long intPraticaId = ParamUtil.getLong(uploadRequest, "intPraticaId"); + long dettPraticaId = ParamUtil.getLong(uploadRequest, "dettPraticaId"); + String descrizione = ParamUtil.getString(uploadRequest, "descrizione"); + String sourceFileName = uploadRequest.getFileName("docFile"); + File file = uploadRequest.getFile("docFile"); + + if (Validator.isNotNull(sourceFileName) && file != null) { + // lunghezza fissata a 200 + if (sourceFileName.length() > 200) { + SessionErrors.add(actionRequest, "error.geniocivilefe.allegato.manuale.length.valid"); + } + } else { + SessionErrors.add(actionRequest, "error.geniocivilefe.allegato.manuale.is.request"); + } + + if (!SessionErrors.isEmpty(actionRequest)) { + PortalUtil.copyRequestParameters(actionRequest, actionResponse); + } else { + if (Validator.isNotNull(intPraticaId) && Validator.isNotNull(dettPraticaId)) { + byte[] content = FileUtil.getBytes(file); + + AllegatoManualeLocalServiceUtil + .addAllegatoManuale(serviceContext.getUserId(), intPraticaId, dettPraticaId, + descrizione, content, sourceFileName, serviceContext); + } + } + + PortalUtil.copyRequestParameters(actionRequest, actionResponse); + } catch (Exception e) { + PortalUtil.copyRequestParameters(actionRequest, actionResponse); + _log.error("Error", e); + throw new SystemException(e); + } + + } + + public void deleteAllegatoManuale(ActionRequest actionRequest, ActionResponse actionResponse) + throws Exception { + long allegatoManualeId = ParamUtil.getLong(actionRequest, "allegatoManualeId"); + AllegatoManualeServiceUtil.deleteAllegatoManuale(allegatoManualeId); + } + + @Override + public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) + throws IOException, PortletException { + + String id = resourceRequest.getResourceID(); + + try { + if ("downloadAll".equals(id)) { + long intPraticaId = ParamUtil.getLong(resourceRequest, "intPraticaId"); + ListCompletato
Refresh"); + + } else { + super.serveResource(resourceRequest, resourceResponse); + } + } catch (PortalException | SystemException e) { + _log.error(e, e); + throw new IOException(e); + } + } } diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/SismicaAdministrationPortlet.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/SismicaAdministrationPortlet.java index 9b6dd8de..0e6186b5 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/SismicaAdministrationPortlet.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/portlet/SismicaAdministrationPortlet.java @@ -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; diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/AllegatoManualeLocalServiceImpl.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/AllegatoManualeLocalServiceImpl.java index 4656ebb4..31fc777b 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/AllegatoManualeLocalServiceImpl.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/AllegatoManualeLocalServiceImpl.java @@ -34,6 +34,7 @@ import com.liferay.portal.kernel.util.MimeTypesUtil; import com.liferay.portal.kernel.util.OrderByComparator; import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.model.User; +import com.liferay.portal.security.permission.ActionKeys; import com.liferay.portal.service.ServiceContext; import com.liferay.portal.service.UserGroupRoleLocalServiceUtil; import com.liferay.portlet.documentlibrary.NoSuchFolderException; @@ -121,6 +122,7 @@ public class AllegatoManualeLocalServiceImpl extends AllegatoManualeLocalService Folder defaultFolder = dlAppLocalService.getFolder(defaultFolderId); String folderName = PraticaUtil.getFolderName(dettPratica.getDettPraticaId()); + serviceContext.setGroupPermissions(new String[] { ActionKeys.VIEW }); Folder folder = null; try { folder = dlAppLocalService.getFolder(defaultFolder.getRepositoryId(), defaultFolder.getFolderId(), folderName); diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/AsseverazioneLocalServiceImpl.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/AsseverazioneLocalServiceImpl.java index 56092796..c29c7ed8 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/AsseverazioneLocalServiceImpl.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/AsseverazioneLocalServiceImpl.java @@ -63,6 +63,7 @@ import com.liferay.portal.kernel.util.OrderByComparator; import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.model.User; +import com.liferay.portal.security.permission.ActionKeys; import com.liferay.portal.service.ServiceContext; import com.liferay.portal.service.UserLocalServiceUtil; import com.liferay.portlet.documentlibrary.NoSuchFileEntryException; @@ -577,6 +578,7 @@ public class AsseverazioneLocalServiceImpl extends AsseverazioneLocalServiceBase String folderName = PraticaUtil.getFolderName(dettPratica.getDettPraticaId()); + serviceContext.setGroupPermissions(new String[] { ActionKeys.VIEW }); Folder folder = null; try { folder = dlAppLocalService.getFolder(defaultFolder.getRepositoryId(), diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/AvvisoLocalServiceImpl.java b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/AvvisoLocalServiceImpl.java index 7f570c65..2a633890 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/AvvisoLocalServiceImpl.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/bo/service/impl/AvvisoLocalServiceImpl.java @@ -62,6 +62,7 @@ import com.liferay.portal.kernel.util.OrderByComparator; import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.model.User; +import com.liferay.portal.security.permission.ActionKeys; import com.liferay.portal.service.ServiceContext; import com.liferay.portlet.documentlibrary.NoSuchFileEntryException; import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil; @@ -982,7 +983,7 @@ public class AvvisoLocalServiceImpl extends AvvisoLocalServiceBaseImpl { dynamicQuery.add(RestrictionsFactoryUtil.eq("fileEntryIdInvio", 0l)); dynamicQuery.add(RestrictionsFactoryUtil.ne("fileEntryIdBase", 0l)); dynamicQuery.add(RestrictionsFactoryUtil.eq("rifiutato", false)); - List avvisi = avvisoPersistence.findWithDynamicQuery(dynamicQuery); + List- * All custom service methods should be put in this class. Whenever methods are added, rerun - * ServiceBuilder to copy their definitions into the + * All custom service methods should be put in this class. Whenever methods are + * added, rerun ServiceBuilder to copy their definitions into the * {@link it.tref.liferay.portos.bo.service.DocPraticaLocalService} interface. * *
- * This is a local service. Methods of this service will not have security checks based on the - * propagated JAAS credentials because this service can only be accessed from within the same VM. + * This is a local service. Methods of this service will not have security + * checks based on the propagated JAAS credentials because this service can only + * be accessed from within the same VM. *
* * @author Davide Barbagallo, 3F Consulting @@ -71,655 +73,667 @@ import com.liferay.portlet.documentlibrary.NoSuchFolderException; * @see it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil */ public class DocPraticaLocalServiceImpl extends DocPraticaLocalServiceBaseImpl { - /* - * NOTE FOR DEVELOPERS: Never reference this interface directly. Always use {@link - * it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil} to access the doc pratica local - * service. - */ - - private Log _log = LogFactoryUtil.getLog(DocPraticaLocalServiceImpl.class); - - @Override - public DocPratica deleteDocPratica(DocPratica docPratica) throws SystemException { + /* + * NOTE FOR DEVELOPERS: Never reference this interface directly. Always use + * {@link it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil} to + * access the doc pratica local service. + */ + + private Log _log = LogFactoryUtil.getLog(DocPraticaLocalServiceImpl.class); + + @Override + public DocPratica deleteDocPratica(DocPratica docPratica) throws SystemException { + + try { + if (Validator.isNotNull(docPratica.getDlFileEntryId())) { + dlAppLocalService.deleteFileEntry(docPratica.getDlFileEntryId()); + } + } catch (NoSuchFileEntryException | NoSuchRepositoryEntryException e) { + + } catch (PortalException e) { + throw new SystemException(e); + } + return super.deleteDocPratica(docPratica); + } - try { - if (Validator.isNotNull(docPratica.getDlFileEntryId())) { - dlAppLocalService.deleteFileEntry(docPratica.getDlFileEntryId()); - } - } catch (NoSuchFileEntryException | NoSuchRepositoryEntryException e) { + @Override + public DocPratica deleteDocPratica(long docPraticaId) throws PortalException, SystemException { - } catch (PortalException e) { - throw new SystemException(e); - } - return super.deleteDocPratica(docPratica); - } + return deleteDocPratica(docPraticaLocalService.getDocPratica(docPraticaId)); + } - @Override - public DocPratica deleteDocPratica(long docPraticaId) throws PortalException, SystemException { + public DocPratica addDocPratica(long userId, String className, long classPk, long intPraticaId, + byte[] dlFileEntry, String fileName, String version, boolean praticaValidata, String descLong, + String tipologia, String sha256, boolean aggiornato, String jsonFirmatari, + long dettPraticaIdRimozione, Date dtDataRimozione, ServiceContext serviceContext) + throws PortalException, SystemException { - return deleteDocPratica(docPraticaLocalService.getDocPratica(docPraticaId)); - } + User user = userPersistence.findByPrimaryKey(userId); + + Date now = new Date(); + + validate(serviceContext.getScopeGroupId(), 0L, className, classPk, intPraticaId, dlFileEntry, + fileName, version, praticaValidata, descLong, tipologia, sha256, aggiornato, jsonFirmatari, + dettPraticaIdRimozione, dtDataRimozione); + + DocPratica docPratica = docPraticaPersistence.create(counterLocalService.increment(DocPratica.class + .getName())); + + FileEntry fileEntry = addAttachment(classPk, intPraticaId, userId, fileName, dlFileEntry, tipologia); + + docPratica.setCompanyId(serviceContext.getCompanyId()); + docPratica.setUserId(user.getUserId()); + docPratica.setUserName(user.getFullName()); + docPratica.setCreateDate(serviceContext.getCreateDate(now)); + docPratica.setModifiedDate(serviceContext.getModifiedDate(now)); + docPratica.setGroupId(serviceContext.getScopeGroupId()); + + docPratica.setClassName(className); + docPratica.setClassPk(classPk); + docPratica.setIntPraticaId(intPraticaId); + docPratica.setDlFileEntryId(fileEntry.getFileEntryId()); + docPratica.setVersion(version); + docPratica.setPraticaValidata(praticaValidata); + docPratica.setDescLong(descLong); + docPratica.setTipologia(tipologia); + docPratica.setSha256(sha256); + docPratica.setAggiornato(aggiornato); + docPratica.setJsonFirmatari(jsonFirmatari); + docPratica.setDettPraticaIdRimozione(dettPraticaIdRimozione); + docPratica.setDtDataRimozione(dtDataRimozione); + + docPratica.setStatus(WorkflowConstants.STATUS_PENDING); + + docPratica = docPraticaPersistence.update(docPratica); + + return docPratica; + } + + public DocPratica addDocPratica(long userId, String className, long classPk, long intPraticaId, + byte[] dlFileEntry, String fileName, String tipologia, String jsonFirmatari, + ServiceContext serviceContext) throws PortalException, SystemException { + + User user = userPersistence.findByPrimaryKey(userId); + + Date now = new Date(); + + DocPratica docPratica = docPraticaPersistence.create(counterLocalService.increment(DocPratica.class + .getName())); + + FileEntry fileEntry = addAttachment(classPk, intPraticaId, userId, fileName, dlFileEntry, tipologia); + + docPratica.setCompanyId(serviceContext.getCompanyId()); + docPratica.setUserId(user.getUserId()); + docPratica.setUserName(user.getFullName()); + docPratica.setCreateDate(serviceContext.getCreateDate(now)); + docPratica.setModifiedDate(serviceContext.getModifiedDate(now)); + docPratica.setGroupId(serviceContext.getScopeGroupId()); + + docPratica.setClassName(className); + docPratica.setClassPk(classPk); + docPratica.setIntPraticaId(intPraticaId); + docPratica.setDlFileEntryId(fileEntry.getFileEntryId()); + docPratica.setVersion("0"); + docPratica.setPraticaValidata(false); + docPratica.setDescLong(fileName); + docPratica.setTipologia(tipologia); + docPratica.setAggiornato(false); + docPratica.setJsonFirmatari(jsonFirmatari); + docPratica.setDettPraticaIdRimozione(0l); + docPratica.setDtDataRimozione(null); + + docPratica.setStatus(WorkflowConstants.STATUS_PENDING); + + docPratica = docPraticaPersistence.update(docPratica); + + return docPratica; + } + + public DocPratica addDocPratica(long userId, String className, long classPk, long intPraticaId, + long fileEntryId, String fileName, String tipologia, String jsonFirmatari, + ServiceContext serviceContext) throws PortalException, SystemException { + + User user = userPersistence.findByPrimaryKey(userId); + + Date now = new Date(); + + DocPratica docPratica = docPraticaPersistence.create(counterLocalService.increment(DocPratica.class + .getName())); + + docPratica.setCompanyId(serviceContext.getCompanyId()); + docPratica.setUserId(user.getUserId()); + docPratica.setUserName(user.getFullName()); + docPratica.setCreateDate(serviceContext.getCreateDate(now)); + docPratica.setModifiedDate(serviceContext.getModifiedDate(now)); + docPratica.setGroupId(serviceContext.getScopeGroupId()); + + docPratica.setClassName(className); + docPratica.setClassPk(classPk); + docPratica.setIntPraticaId(intPraticaId); + docPratica.setDlFileEntryId(fileEntryId); + docPratica.setVersion("0"); + docPratica.setPraticaValidata(false); + docPratica.setDescLong(fileName); + docPratica.setTipologia(tipologia); + docPratica.setAggiornato(false); + docPratica.setJsonFirmatari(jsonFirmatari); + docPratica.setDettPraticaIdRimozione(0l); + docPratica.setDtDataRimozione(null); + + docPratica.setStatus(WorkflowConstants.STATUS_PENDING); + + docPratica = docPraticaPersistence.update(docPratica); + + return docPratica; + } + + public DocPratica addDocPraticaForImport(long userId, String className, long classPk, long intPraticaId, + byte[] dlFileEntry, String fileName, String version, boolean praticaValidata, String descLong, + String tipologia, String sha256, boolean aggiornato, String jsonFirmatari, + long dettPraticaIdRimozione, Date dtDataRimozione, long oldDocPraticaId, + ServiceContext serviceContext) throws PortalException, SystemException { + + Date now = new Date(); + + validate(serviceContext.getScopeGroupId(), 0L, className, classPk, intPraticaId, dlFileEntry, + fileName, version, praticaValidata, descLong, tipologia, sha256, aggiornato, jsonFirmatari, + dettPraticaIdRimozione, dtDataRimozione); + + DocPratica docPratica = docPraticaPersistence.create(counterLocalService.increment(DocPratica.class + .getName())); + + docPratica.setCompanyId(serviceContext.getCompanyId()); + docPratica.setUserId(userId); + if (userId > 0) { + User user = userPersistence.findByPrimaryKey(userId); + docPratica.setUserName(user.getFullName()); + } + docPratica.setCreateDate(serviceContext.getCreateDate(now)); + docPratica.setModifiedDate(serviceContext.getModifiedDate(now)); + docPratica.setGroupId(serviceContext.getScopeGroupId()); + docPratica.setClassName(className); + docPratica.setClassPk(classPk); + docPratica.setIntPraticaId(intPraticaId); + docPratica.setVersion(version); + docPratica.setPraticaValidata(praticaValidata); + docPratica.setDescLong(descLong); + docPratica.setTipologia(tipologia); + docPratica.setSha256(sha256); + docPratica.setAggiornato(aggiornato); + docPratica.setJsonFirmatari(jsonFirmatari); + docPratica.setDettPraticaIdRimozione(dettPraticaIdRimozione); + docPratica.setDtDataRimozione(dtDataRimozione); + docPratica.setOldDocPraticaId(oldDocPraticaId); + + docPratica.setStatus(WorkflowConstants.STATUS_APPROVED); + + return docPraticaPersistence.update(docPratica); + } + + public FileEntry addAttachment(long classPk, long intPraticaId, long delegaUserId, String sourceFileName, + byte[] content, String tipoAllegato) throws SystemException, PortalException { + + FileEntry fileEntry = null; + + // DettPratica dettPratica = + // dettPraticaPersistence.fetchByPrimaryKey(dettPraticaId); + IntPratica intPratica = intPraticaPersistence.fetchByPrimaryKey(intPraticaId); + Territorio territorio = territorioPersistence.fetchByPrimaryKey(intPratica.getTerritorioId()); + + long companyId = territorio.getCompanyId(); + long groupId = territorio.getGroupId(); + + // TODO forse è meglio ragionare con un'altra logica per i permessi + User user = UserLocalServiceUtil.getRoleUsers( + RoleLocalServiceUtil.getRole(intPratica.getCompanyId(), RoleConstants.ADMINISTRATOR) + .getRoleId()).get(0); + try { + PermissionThreadLocal.setPermissionChecker(PermissionCheckerFactoryUtil.create(user)); + } catch (Exception e) { + throw new SystemException(e); + + } + long userId = user.getUserId(); + + ServiceContext serviceContext = new ServiceContext(); + serviceContext.setCompanyId(companyId); + serviceContext.setScopeGroupId(groupId); + serviceContext.setUserId(userId); + serviceContext.setGroupPermissions(new String[] { ActionKeys.VIEW }); + + long defaultFolderId = configurazioneLocalService.findByC_ChiaveLong(companyId, + ConfigurazioneConstants.ATTACHMENT_FOLDER_ID); + + Folder defaultFolder = dlAppLocalService.getFolder(defaultFolderId); + + String folderName = PraticaUtil.getFolderName(classPk); + + Folder folder = null; + try { + folder = dlAppLocalService.getFolder(defaultFolder.getRepositoryId(), + defaultFolder.getFolderId(), folderName); + } catch (NoSuchFolderException e) { + // cartella non presente -> creo cartella + folder = dlAppLocalService.addFolder(userId, defaultFolder.getRepositoryId(), + defaultFolder.getFolderId(), folderName, StringPool.BLANK, serviceContext); + } + Date now = new Date(); + String title = tipoAllegato + StringPool.UNDERLINE + sourceFileName; + String description = sourceFileName; + String mimeType = MimeTypesUtil.getContentType(sourceFileName); + + String changeLog = StringPool.BLANK; + fileEntry = dlAppLocalService.addFileEntry(userId, folder.getRepositoryId(), folder.getFolderId(), + now.getTime() + "_" + sourceFileName, mimeType, title, description, changeLog, content, + serviceContext); + + try { + PermissionThreadLocal.setPermissionChecker(PermissionCheckerFactoryUtil + .create(UserLocalServiceUtil.getUser(delegaUserId))); + } catch (Exception e) { + throw new SystemException(e); + + } + return fileEntry; + } + + public FileEntry getAttachment(long classPk) throws SystemException, PortalException { + + DocPratica fileAllegato = docPraticaPersistence.findByPrimaryKey(classPk); + return dlAppLocalService.getFileEntry(fileAllegato.getDlFileEntryId()); + } + + public void addFirma(long docPraticaId, String codiceFiscale) throws PortalException, SystemException { + + DocPratica docPratica = docPraticaLocalService.getDocPratica(docPraticaId); + docPratica.setJsonFirmatari(FirmeUtil.addFirma(docPratica.getJsonFirmatari(), codiceFiscale)); + docPraticaLocalService.updateDocPratica(docPratica); + } + + public void addFirmeAndApprova(long docPraticaId, ListSTATO | -ALLEGATO | -FIRME | - <%-- <% if(!comingFrom.equals("page_va_allegati") && !comingFrom.equals("page_in_allegati") ) { %> --%> -AGGIUNTO DA | -INVALIDATO DA | - <%-- <% } %> --%> -AZIONI | -
---|
STATO | +ALLEGATO | +FIRME | + <%-- <% if(!comingFrom.equals("page_va_allegati") && !comingFrom.equals("page_in_allegati") ) { %> --%> +AGGIUNTO DA | +INVALIDATO DA | + <%-- <% } %> --%> +AZIONI | +||
---|---|---|---|---|---|---|---|
- - | -- <%= docPratica.getFileName() %> - | -
- <%
- FirmeBean firme = FirmeUtil.deserialize(docPratica.getJsonFirmatari());
- StringBuilder title = new StringBuilder();
- if(firme.numeroFirme()>0){
- if(!firme.getFirmeDigitali().isEmpty()){
- title.append("Firma sul file:
| |||||
+ | +<%=docPratica.getFileName()%> | +
+ <%
+ FirmeBean firme = FirmeUtil.deserialize(docPratica.getJsonFirmatari());
+ StringBuilder title = new StringBuilder();
+ if(firme.numeroFirme()>0){
+ if(!firme.getFirmeDigitali().isEmpty()){
+ title.append("Firma sul file:
|
+ <%-- <% if(!comingFrom.equals("page_va_allegati") && !comingFrom.equals("page_in_allegati") ) { %> --%>
+ + <% + String description = StringPool.BLANK; + + if(DettPratica.class.getName().equalsIgnoreCase(docPratica.getClassName())){ + DettPratica adding = DettPraticaLocalServiceUtil.fetchDettPratica(docPratica.getClassPk()); + if(adding!=null){ + description = adding.getFullDescription() ; + } + }else if(FineLavori.class.getName().equalsIgnoreCase(docPratica.getClassName())){ + FineLavori adding = FineLavoriLocalServiceUtil.fetchFineLavori(docPratica.getClassPk()); + if(adding!=null){ + description = adding.getFullDescription() ; + } + }else if(Collaudo.class.getName().equalsIgnoreCase(docPratica.getClassName())){ + Collaudo adding = CollaudoLocalServiceUtil.fetchCollaudo(docPratica.getClassPk()); + if(adding!=null){ + description = adding.getFullDescription() ; + } + } + + out.print(description); %> - | - <%-- <% if(!comingFrom.equals("page_va_allegati") && !comingFrom.equals("page_in_allegati") ) { %> --%> -- <% - String description = StringPool.BLANK; - - if(DettPratica.class.getName().equalsIgnoreCase(docPratica.getClassName())){ - DettPratica adding = DettPraticaLocalServiceUtil.fetchDettPratica(docPratica.getClassPk()); - if(adding!=null){ - description = adding.getFullDescription() ; - } - }else if(FineLavori.class.getName().equalsIgnoreCase(docPratica.getClassName())){ - FineLavori adding = FineLavoriLocalServiceUtil.fetchFineLavori(docPratica.getClassPk()); - if(adding!=null){ - description = adding.getFullDescription() ; - } - }else if(Collaudo.class.getName().equalsIgnoreCase(docPratica.getClassName())){ - Collaudo adding = CollaudoLocalServiceUtil.fetchCollaudo(docPratica.getClassPk()); - if(adding!=null){ - description = adding.getFullDescription() ; - } - } - - out.print(description); - %> - | -- <% - DettPratica removing = DettPraticaLocalServiceUtil.fetchDettPratica(docPratica.getDettPraticaIdRimozione()); - if(removing != null){ - %> - <%= removing.getFullDescription() %> - <% - } - %> - | - <%-- <% + ++ <% + DettPratica removing = DettPraticaLocalServiceUtil.fetchDettPratica(docPratica.getDettPraticaIdRimozione()); + if(removing != null){ + %> <%=removing.getFullDescription()%> <% + } + %> + | + <%-- <% } %> --%> - - -
- |
-
Delega incompletaRefresh
');"+ - "body.ancestor('.modal-body').next('.modal-footer').remove();return;}"+ - "}, complete: function(event){A.one('#"+renderResponse.getNamespace()+"dgSaveAndCloseDiv_"+randomId+"').show();modal.show();}"+ - "}});"; + String function = "A.io.request('" + + isCompletedDelegaGeologoURL + + "',{data: {" + + renderResponse.getNamespace() + + "classPk: " + + dettPraticaId + + "}," + + "dataType: 'json',on: {success: function(event, id, obj) {console.log(this.get('responseData'));var response = this.get('responseData');" + + "console.log(response.isCompleted);" + + "if(!response.isCompleted){var body = A.one('#" + + renderResponse.getNamespace() + + "dgSaveAndCloseDiv_" + + randomId + + "');" + + "body.html('Delega incompletaRefresh
');" + + "body.ancestor('.modal-body').next('.modal-footer').remove();return;}" + + "}, complete: function(event){A.one('#" + renderResponse.getNamespace() + + "dgSaveAndCloseDiv_" + randomId + "').show();modal.show();}" + "}});"; %> -
-
+