Sfoglia il codice sorgente

fix: wrap resetFirme in try/catch to handle NPE

fix/NullPointer-Exceptions
Gabriele Zigurella 2 anni fa
parent
commit
f0e4997b3d
  1. 93
      liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/docroot/WEB-INF/src/it/mwg/sismica/bo/util/SismicaUtil.java

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

@ -1268,53 +1268,56 @@ public class SismicaUtil {
public static List<String> resetFirme(long companyId, String numeroProgetto) throws SystemException, public static List<String> resetFirme(long companyId, String numeroProgetto) throws SystemException,
PortalException { PortalException {
try{
List<String> esito = new ArrayList<>(); List<String> esito = new ArrayList<>();
if (Validator.isNull(numeroProgetto)) { if (Validator.isNull(numeroProgetto)) {
esito.addAll(firmeBloccate(companyId)); esito.addAll(firmeBloccate(companyId));
} else { } else {
IntPratica pratica = IntPraticaLocalServiceUtil.findByNumeroProgetto(numeroProgetto); IntPratica pratica = IntPraticaLocalServiceUtil.findByNumeroProgetto(numeroProgetto);
ControlloPratica controllo = getLastControlloPratica(pratica.getIntPraticaId()); ControlloPratica controllo = getLastControlloPratica(pratica.getIntPraticaId());
KaleoInstanceToken instanceToken = findInstanceToken(controllo.getControlloPraticaId()); KaleoInstanceToken instanceToken = findInstanceToken(controllo.getControlloPraticaId());
if (Validator.isNotNull(instanceToken)) { if (Validator.isNotNull(instanceToken)) {
esitoLog(esito, "Trovato KaleoInstanceToken " + instanceToken.getKaleoInstanceTokenId() esitoLog(esito, "Trovato KaleoInstanceToken " + instanceToken.getKaleoInstanceTokenId()
+ ", currentKaleoNodeName = \"" + instanceToken.getCurrentKaleoNodeName() + StringPool.QUOTE); + ", currentKaleoNodeName = \"" + instanceToken.getCurrentKaleoNodeName() + StringPool.QUOTE);
if (instanceToken.getCurrentKaleoNodeName().equalsIgnoreCase("signal_ff")) { if (instanceToken.getCurrentKaleoNodeName().equalsIgnoreCase("signal_ff")) {
List<KaleoTaskInstanceToken> taskInstanceTokens = findTaskInstanceTokens(instanceToken List<KaleoTaskInstanceToken> taskInstanceTokens = findTaskInstanceTokens(instanceToken
.getKaleoInstanceTokenId()); .getKaleoInstanceTokenId());
esitoLog(esito, "Trovati " + taskInstanceTokens.size() + " KaleoTaskInstanceToken"); esitoLog(esito, "Trovati " + taskInstanceTokens.size() + " KaleoTaskInstanceToken");
List<KaleoTaskAssignmentInstance> taskAssignmentInstances = findTaskAssignmentInstances(instanceToken List<KaleoTaskAssignmentInstance> taskAssignmentInstances = findTaskAssignmentInstances(instanceToken
.getKaleoInstanceId()); .getKaleoInstanceId());
esitoLog(esito, "Trovati " + taskAssignmentInstances.size() + " KaleoTaskAssignmentInstance"); esitoLog(esito, "Trovati " + taskAssignmentInstances.size() + " KaleoTaskAssignmentInstance");
KaleoTaskInstanceToken taskInstanceToken = taskInstanceTokens.get(taskInstanceTokens.size() - 1); KaleoTaskInstanceToken taskInstanceToken = taskInstanceTokens.get(taskInstanceTokens.size() - 1);
KaleoTaskAssignmentInstance taskAssignmentInstance = taskAssignmentInstances KaleoTaskAssignmentInstance taskAssignmentInstance = taskAssignmentInstances
.get(taskAssignmentInstances.size() - 1); .get(taskAssignmentInstances.size() - 1);
esitoLog(esito, esitoLog(esito,
"Cancello KaleoTaskInstanceToken " + taskInstanceToken.getKaleoTaskInstanceTokenId()); "Cancello KaleoTaskInstanceToken " + taskInstanceToken.getKaleoTaskInstanceTokenId());
KaleoTaskInstanceTokenLocalServiceUtil.deleteKaleoTaskInstanceToken(taskInstanceToken); KaleoTaskInstanceTokenLocalServiceUtil.deleteKaleoTaskInstanceToken(taskInstanceToken);
esitoLog( esitoLog(
esito, esito,
"Cancello KaleoTaskAssignmentInstance " "Cancello KaleoTaskAssignmentInstance "
+ taskAssignmentInstance.getKaleoTaskAssignmentInstanceId()); + taskAssignmentInstance.getKaleoTaskAssignmentInstanceId());
KaleoTaskAssignmentInstanceLocalServiceUtil KaleoTaskAssignmentInstanceLocalServiceUtil
.deleteKaleoTaskAssignmentInstance(taskAssignmentInstance); .deleteKaleoTaskAssignmentInstance(taskAssignmentInstance);
taskInstanceToken = taskInstanceTokens.get(taskInstanceTokens.size() - 2); taskInstanceToken = taskInstanceTokens.get(taskInstanceTokens.size() - 2);
esitoLog(esito, esitoLog(esito,
"Aggiorno KaleoTaskInstanceToken " + taskInstanceToken.getKaleoTaskInstanceTokenId()); "Aggiorno KaleoTaskInstanceToken " + taskInstanceToken.getKaleoTaskInstanceTokenId());
taskInstanceToken.setCompleted(false); taskInstanceToken.setCompleted(false);
taskInstanceToken.setCompletionUserId(0); taskInstanceToken.setCompletionUserId(0);
taskInstanceToken.setCompletionDate(null); taskInstanceToken.setCompletionDate(null);
KaleoTaskInstanceTokenLocalServiceUtil.updateKaleoTaskInstanceToken(taskInstanceToken); KaleoTaskInstanceTokenLocalServiceUtil.updateKaleoTaskInstanceToken(taskInstanceToken);
esitoLog(esito, "Aggiorno KaleoInstanceToken " + instanceToken.getKaleoInstanceTokenId()); esitoLog(esito, "Aggiorno KaleoInstanceToken " + instanceToken.getKaleoInstanceTokenId());
instanceToken.setCurrentKaleoNodeId(21639); instanceToken.setCurrentKaleoNodeId(21639);
instanceToken.setCurrentKaleoNodeName("Esito"); instanceToken.setCurrentKaleoNodeName("Esito");
KaleoInstanceTokenLocalServiceUtil.updateKaleoInstanceToken(instanceToken); KaleoInstanceTokenLocalServiceUtil.updateKaleoInstanceToken(instanceToken);
}
} }
} }
}catch(Exception e){
_log.error(e, e);
} }
return esito; return esito;
} }

Caricamento…
Annulla
Salva