protected void logProcessInstanceNotFound(final SProcessInstanceModificationException e) {
   if (logger.isLoggable(this.getClass(), TechnicalLogSeverity.DEBUG)) {
     logger.log(
         this.getClass(),
         TechnicalLogSeverity.DEBUG,
         e.getMessage() + ". It has probably completed.");
   }
 }
 void disconnectSilently(final SConnector sConnector) {
   try {
     sConnector.disconnect();
   } catch (final Exception t) {
     if (loggerService.isLoggable(getClass(), TechnicalLogSeverity.WARNING)) {
       loggerService.log(
           getClass(),
           TechnicalLogSeverity.WARNING,
           "An error occured while disconnecting the connector: " + sConnector,
           t);
     }
   }
 }
 @Override
 public void rejectedExecution(final Runnable task, final ThreadPoolExecutor executor) {
   if (logger.isLoggable(getClass(), TechnicalLogSeverity.WARNING)) {
     logger.log(
         this.getClass(),
         TechnicalLogSeverity.WARNING,
         "The work was rejected. Requeue work : " + task.toString());
   }
   try {
     executor.getQueue().put(task);
   } catch (final InterruptedException e) {
     throw new RejectedExecutionException("Queuing " + task + " got interrupted.", e);
   }
 }
 private void deleteFlowNodeInstanceElements(
     final SFlowNodeInstance flowNodeInstance, final SProcessDefinition processDefinition)
     throws SBonitaException {
   if (flowNodeInstance.getType().equals(SFlowNodeType.INTERMEDIATE_CATCH_EVENT)) {
     bpmEventInstanceService.deleteWaitingEvents(flowNodeInstance);
   }
   if (flowNodeInstance instanceof SEventInstance) {
     bpmEventInstanceService.deleteEventTriggerInstances(flowNodeInstance.getId());
   } else if (flowNodeInstance instanceof SActivityInstance) {
     deleteDataInstancesIfNecessary(flowNodeInstance, processDefinition);
     deleteConnectorInstancesIfNecessary(flowNodeInstance, processDefinition);
     if (SFlowNodeType.USER_TASK.equals(flowNodeInstance.getType())
         || SFlowNodeType.MANUAL_TASK.equals(flowNodeInstance.getType())) {
       activityService.deleteHiddenTasksForActivity(flowNodeInstance.getId());
       try {
         activityService.deletePendingMappings(flowNodeInstance.getId());
       } catch (final SActivityModificationException e) {
         throw new SFlowNodeReadException(e);
       }
     } else if (SFlowNodeType.CALL_ACTIVITY.equals(flowNodeInstance.getType())
         || SFlowNodeType.SUB_PROCESS.equals(flowNodeInstance.getType())) {
       // in the case of a call activity or subprocess activity delete the child process instance
       try {
         deleteProcessInstance(getChildOfActivity(flowNodeInstance.getId()));
       } catch (final SProcessInstanceNotFoundException e) {
         final StringBuilder stb = new StringBuilder();
         stb.append("Can't find the process instance called by the activity [id: ");
         stb.append(flowNodeInstance.getId());
         stb.append(", name: ");
         stb.append(flowNodeInstance.getName());
         stb.append("]. This process may be already finished");
         // if the child process is not found, it's because it has already finished and archived or
         // it was not created
         if (logger.isLoggable(getClass(), TechnicalLogSeverity.DEBUG)) {
           logger.log(getClass(), TechnicalLogSeverity.DEBUG, stb.toString());
           logger.log(getClass(), TechnicalLogSeverity.DEBUG, e);
         }
       }
     }
   }
 }
 @Override
 public void stop() {
   if (executorService != null) {
     executorService.shutdown();
     try {
       if (!executorService.awaitTermination(5000, TimeUnit.MILLISECONDS)) {
         loggerService.log(
             getClass(),
             TechnicalLogSeverity.WARNING,
             "Timeout (5s) trying to stop the connector executor thread pool.");
       }
     } catch (final InterruptedException e) {
       loggerService.log(
           getClass(),
           TechnicalLogSeverity.WARNING,
           "Error while stopping the connector executor thread pool.",
           e);
     }
     executorService = null;
   }
 }
 private void archiveProcessInstance(final SProcessInstance processInstance)
     throws SProcessInstanceModificationException {
   final SAProcessInstance saProcessInstance =
       BuilderFactory.get(SAProcessInstanceBuilderFactory.class)
           .createNewInstance(processInstance)
           .done();
   final ArchiveInsertRecord insertRecord = new ArchiveInsertRecord(saProcessInstance);
   try {
     archiveService.recordInsert(System.currentTimeMillis(), insertRecord);
   } catch (final SRecorderException e) {
     throw new SProcessInstanceModificationException(e);
   } catch (final SDefinitiveArchiveNotFound e) {
     if (logger.isLoggable(this.getClass(), TechnicalLogSeverity.ERROR)) {
       logger.log(
           this.getClass(),
           TechnicalLogSeverity.ERROR,
           "The process instance was not archived. Id:" + processInstance.getId(),
           e);
     }
   }
 }
 @Override
 public void setState(final SProcessInstance processInstance, final ProcessInstanceState state)
     throws SProcessInstanceModificationException {
   // Let's archive the process instance before changing the state (to keep a track of state
   // change):
   archiveProcessInstance(processInstance);
   int previousStateId = processInstance.getStateId();
   setProcessState(processInstance, state);
   if (logger.isLoggable(getClass(), TechnicalLogSeverity.DEBUG)) {
     logger.log(
         getClass(),
         TechnicalLogSeverity.DEBUG,
         MessageFormat.format(
             "[{0} with id {1}]{2}->{3}(new={4})",
             processInstance.getClass().getSimpleName(),
             processInstance.getId(),
             previousStateId,
             state.getId(),
             state.name()));
   }
 }
 protected void logArchivedProcessInstanceNotFound(final SBonitaException e) {
   if (logger.isLoggable(this.getClass(), TechnicalLogSeverity.WARNING)) {
     logger.log(this.getClass(), TechnicalLogSeverity.WARNING, e.getMessage());
   }
 }