Sfoglia il codice sorgente

Inizio correzione permessi

master
Salvatore La Manna 4 anni fa
parent
commit
cfb21a5fb7
  1. 8
      liferay-plugins-sdk-6.2/build.m.gosetto.properties
  2. BIN
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpclient.jar
  3. BIN
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/util-java.jar
  4. 127
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/SismicaUtil.java
  5. 2
      liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/fe/portlet/FascicoloFePortlet.java

8
liferay-plugins-sdk-6.2/build.m.gosetto.properties

@ -1,8 +0,0 @@
#Managed by Liferay IDE (remove this comment to prevent future updates)
#Tue May 19 15:47:40 CEST 2020
app.server.tomcat.lib.global.dir=C\:\\Users\\m.gosetto\\Documents\\Sicilia\\liferay-portal-6.2-ce-ga6\\tomcat-7.0.62\\lib\\ext
app.server.tomcat.deploy.dir=C\:\\Users\\m.gosetto\\Documents\\Sicilia\\liferay-portal-6.2-ce-ga6\\tomcat-7.0.62\\webapps
app.server.parent.dir=C\:\\Users\\m.gosetto\\Documents\\Sicilia\\liferay-portal-6.2-ce-ga6
app.server.tomcat.dir=C\:\\Users\\m.gosetto\\Documents\\Sicilia\\liferay-portal-6.2-ce-ga6\\tomcat-7.0.62
app.server.type=tomcat
app.server.tomcat.portal.dir=C\:\\Users\\m.gosetto\\Documents\\Sicilia\\liferay-portal-6.2-ce-ga6\\tomcat-7.0.62\\webapps\\ROOT

BIN
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/httpclient.jar

File binario non mostrato.

BIN
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/lib/util-java.jar

File binario non mostrato.

127
liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/SismicaUtil.java

@ -5,15 +5,20 @@
*/
package it.mwg.sismica.bo.util;
import it.tref.liferay.portos.bo.model.Asseverazione;
import it.tref.liferay.portos.bo.model.Avviso;
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.Territorio;
import it.tref.liferay.portos.bo.model.impl.AvvisoImpl;
import it.tref.liferay.portos.bo.service.AsseverazioneLocalServiceUtil;
import it.tref.liferay.portos.bo.service.AvvisoLocalServiceUtil;
import it.tref.liferay.portos.bo.service.ConfigurazioneLocalServiceUtil;
import it.tref.liferay.portos.bo.service.ControlloPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DettPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.DocPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil;
import it.tref.liferay.portos.bo.service.TerritorioLocalServiceUtil;
import it.tref.liferay.portos.bo.shared.util.ConfigurazioneConstants;
@ -22,7 +27,11 @@ import it.tref.liferay.portos.bo.util.AvvisoUtil;
import it.tref.liferay.portos.bo.util.Constants;
import it.tref.liferay.portos.bo.util.WorkflowConstants;
import java.io.IOException;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@ -36,6 +45,11 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
import org.apache.commons.io.IOUtils;
import com.itextpdf.text.pdf.codec.Base64.InputStream;
import com.liferay.portal.NoSuchRepositoryEntryException;
import com.liferay.portal.kernel.dao.jdbc.DataAccess;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
@ -43,6 +57,7 @@ import com.liferay.portal.kernel.language.LanguageUtil;
import com.liferay.portal.kernel.log.Log;
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.util.GetterUtil;
import com.liferay.portal.kernel.util.LocaleUtil;
import com.liferay.portal.kernel.util.OrderByComparatorFactoryUtil;
@ -54,7 +69,25 @@ import com.liferay.portal.kernel.workflow.WorkflowInstance;
import com.liferay.portal.kernel.workflow.WorkflowInstanceManagerUtil;
import com.liferay.portal.kernel.workflow.WorkflowTask;
import com.liferay.portal.kernel.workflow.WorkflowTaskManagerUtil;
import com.liferay.portal.model.Group;
import com.liferay.portal.model.Organization;
import com.liferay.portal.model.ResourceAction;
import com.liferay.portal.model.ResourceConstants;
import com.liferay.portal.model.ResourcePermission;
import com.liferay.portal.model.Role;
import com.liferay.portal.model.RoleConstants;
import com.liferay.portal.model.User;
import com.liferay.portal.security.auth.PrincipalException;
import com.liferay.portal.security.auth.PrincipalThreadLocal;
import com.liferay.portal.security.permission.ActionKeys;
import com.liferay.portal.security.permission.PermissionChecker;
import com.liferay.portal.security.permission.PermissionCheckerFactoryUtil;
import com.liferay.portal.security.permission.PermissionThreadLocal;
import com.liferay.portal.service.GroupLocalServiceUtil;
import com.liferay.portal.service.OrganizationLocalServiceUtil;
import com.liferay.portal.service.ResourceActionLocalServiceUtil;
import com.liferay.portal.service.ResourcePermissionLocalServiceUtil;
import com.liferay.portal.service.RoleLocalServiceUtil;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portal.workflow.kaleo.model.KaleoInstance;
@ -67,16 +100,20 @@ import com.liferay.portal.workflow.kaleo.service.KaleoInstanceTokenLocalServiceU
import com.liferay.portal.workflow.kaleo.service.KaleoTaskAssignmentInstanceLocalServiceUtil;
import com.liferay.portal.workflow.kaleo.service.KaleoTaskInstanceTokenLocalServiceUtil;
import com.liferay.portal.workflow.kaleo.service.persistence.KaleoInstanceTokenUtil;
import com.liferay.portlet.documentlibrary.NoSuchFileEntryException;
import com.liferay.portlet.documentlibrary.model.DLFileEntry;
import com.liferay.portlet.documentlibrary.model.DLFolder;
import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil;
import com.liferay.portlet.documentlibrary.service.DLAppServiceUtil;
import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil;
import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil;
public class SismicaUtil {
private final static Log _log = LogFactoryUtil.getLog(SismicaUtil.class);
private static final SimpleDateFormat dfmt = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
private static final SimpleDateFormat sdfGiornoDB = new SimpleDateFormat("yyyy-MM-dd");
private final static int SLICE = 200;
private final static int SLICE = 1000;
public static Date[] getWeekInterval(int dow) {
return getWeekInterval(dow, Calendar.getInstance().getTime());
@ -980,7 +1017,93 @@ public class SismicaUtil {
return new ArrayList<>(sorted.values());
}
public static List<String> generaDocumenti(long companyId) throws SystemException, PortalException {
public static List<String> generaDocumenti(long companyId) throws PortalException, SystemException {
List<String> esito = new ArrayList<>();
Map<Long, PermissionChecker> orgPc = new HashMap<>();
for (Organization org : OrganizationLocalServiceUtil.getOrganizations(QueryUtil.ALL_POS,
QueryUtil.ALL_POS)) {
if (0 == org.getSuborganizationsSize()) {
List<User> users = UserLocalServiceUtil.getOrganizationUsers(org.getOrganizationId());
User user = users.get(users.size() * 2 / 3);
PermissionChecker pc = null;
try {
pc = PermissionCheckerFactoryUtil.create(user);
} catch (Exception e) {
_log.info("PC non funziona: " + e.getMessage());
}
orgPc.put(org.getGroupId(), pc);
}
}
long userRoleId = RoleLocalServiceUtil.getRole(companyId, RoleConstants.USER).getRoleId();
ResourceAction resourceAction = ResourceActionLocalServiceUtil.getResourceAction(
DLFileEntry.class.getName(), ActionKeys.VIEW);
List<Long> mancanti = new ArrayList<>();
int inizio = 0;
int totali = 0;
List<Asseverazione> asseverazioni = null;
do {
asseverazioni = AsseverazioneLocalServiceUtil.getAsseveraziones(inizio, inizio + SLICE);
for (Asseverazione asseverazione : asseverazioni) {
IntPratica pratica = null;
try {
pratica = IntPraticaLocalServiceUtil.getIntPratica(asseverazione.getIntPraticaId());
} catch (PortalException e) {
}
if (Validator.isNotNull(pratica)) {
Territorio territorio = TerritorioLocalServiceUtil.getTerritorio(pratica
.getTerritorioId());
PermissionChecker pc = orgPc.get(territorio.getGroupId());
FileEntry fileEntry = null;
try {
fileEntry = DLAppServiceUtil.getFileEntry(asseverazione.getFileEntryId());
} catch (Exception e) {
_log.info(e.getClass() + ": " + e.getMessage());
}
if (Validator.isNotNull(fileEntry)) {
if (!fileEntry.containsPermission(pc, ActionKeys.VIEW)) {
_log.info("Pratica " + pratica.getNumeroProgetto() + " ("
+ pratica.getIntPraticaId() + "), asseverazione "
+ asseverazione.getAsseverazioneId() + " non ha i permessi");
ResourcePermission resourcePermission = null;
try {
resourcePermission = ResourcePermissionLocalServiceUtil
.getResourcePermission(companyId, DLFileEntry.class.getName(),
ResourceConstants.SCOPE_INDIVIDUAL,
String.valueOf(fileEntry.getPrimaryKey()), userRoleId);
} catch (Exception e) {
_log.info(e.getClass() + ": " + e.getMessage());
}
resourcePermission.setActionIds(resourceAction.getBitwiseValue());
ResourcePermissionLocalServiceUtil.updateResourcePermission(resourcePermission);
Folder folder = fileEntry.getFolder();
while (Validator.isNotNull(folder)) {
if (!folder.containsPermission(pc, ActionKeys.VIEW)) {
_log.info("folder " + folder.getName() + " non ha i permessi");
resourcePermission = ResourcePermissionLocalServiceUtil
.getResourcePermission(companyId, DLFolder.class.getName(),
ResourceConstants.SCOPE_INDIVIDUAL,
String.valueOf(folder.getPrimaryKey()), userRoleId);
}
folder = folder.getParentFolder();
}
}
}
}
}
inizio += SLICE;
if (asseverazioni.size() > 0) {
totali += asseverazioni.size();
_log.info(totali + " DocPratica");
}
} while (asseverazioni.size() > 0);
_log.info("Mancanti " + mancanti.size());
return esito;
}
public static List<String> generaDocumenti2(long companyId) throws SystemException, PortalException {
List<String> esito = new ArrayList<>();
long templateConforme = ConfigurazioneLocalServiceUtil.findByC_ChiaveLong(companyId, AvvisoUtil

2
liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/tref/liferay/portos/fe/portlet/FascicoloFePortlet.java

@ -935,7 +935,7 @@ public class FascicoloFePortlet extends MVCPortlet {
saveDatiDettPratica(dettPraticaId, actionRequest, actionResponse);
} else {
throw new SystemException("operazione non gestita");
throw new SystemException("operazione non gestita (" + cmd + ")");
}
}

Caricamento…
Annulla
Salva