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

Caricamento…
Annulla
Salva