@Override public SProcessDefinition getProcessDefinitionIfIsEnabled(final long processDefinitionId) throws SBonitaReadException, SProcessDefinitionException { final SProcessDefinitionDeployInfo deployInfo = getProcessDeploymentInfo(processDefinitionId); if (ActivationState.DISABLED.name().equals(deployInfo.getActivationState())) { throw new SProcessDefinitionException("The process definition is not enabled !!", deployInfo.getProcessId(), deployInfo.getName(), deployInfo.getVersion()); } return getProcessDefinition(processDefinitionId); }
@Override public SProcessDefinition getProcessDefinitionIfIsEnabled(final long processDefinitionId) throws SBonitaReadException, SProcessDefinitionException { final SProcessDefinitionDeployInfo deployInfo = getProcessDeploymentInfo(processDefinitionId); if (ActivationState.DISABLED.name().equals(deployInfo.getActivationState())) { throw new SProcessDefinitionException("The process definition is not enabled !!", deployInfo.getProcessId(), deployInfo.getName(), deployInfo.getVersion()); } return getProcessDefinition(processDefinitionId); }
public static ProcessDeploymentInfo toProcessDeploymentInfo(final SProcessDefinitionDeployInfo processDefinitionDI) { return new ProcessDeploymentInfoImpl(processDefinitionDI.getId(), processDefinitionDI.getProcessId(), processDefinitionDI.getName(), processDefinitionDI.getVersion(), processDefinitionDI.getDescription(), new Date(processDefinitionDI.getDeploymentDate()), processDefinitionDI.getDeployedBy(), ActivationState.valueOf(processDefinitionDI.getActivationState()), ConfigurationState.valueOf(processDefinitionDI.getConfigurationState()), processDefinitionDI.getDisplayName(), new Date( processDefinitionDI.getLastUpdateDate()), processDefinitionDI.getIconPath(), processDefinitionDI.getDisplayDescription()); }
public static ProcessDeploymentInfo toProcessDeploymentInfo(final SProcessDefinitionDeployInfo processDefinitionDI) { return new ProcessDeploymentInfoImpl(processDefinitionDI.getId(), processDefinitionDI.getProcessId(), processDefinitionDI.getName(), processDefinitionDI.getVersion(), processDefinitionDI.getDescription(), new Date(processDefinitionDI.getDeploymentDate()), processDefinitionDI.getDeployedBy(), ActivationState.valueOf(processDefinitionDI.getActivationState()), ConfigurationState.valueOf(processDefinitionDI.getConfigurationState()), processDefinitionDI.getDisplayName(), new Date( processDefinitionDI.getLastUpdateDate()), processDefinitionDI.getIconPath(), processDefinitionDI.getDisplayDescription()); }
private void ensureProcessIsEnabled(final SProcessDefinition sProcessDefinition) throws SProcessDefinitionNotFoundException, SBonitaReadException, SProcessDefinitionException { final SProcessDefinitionDeployInfo deployInfo = processDefinitionService.getProcessDeploymentInfo(sProcessDefinition.getId()); if (ActivationState.DISABLED.name().equals(deployInfo.getActivationState())) { throw new SProcessDefinitionException("The process " + deployInfo.getName() + " " + deployInfo.getVersion() + " is not enabled.", deployInfo.getProcessId(), deployInfo.getName(), deployInfo.getVersion()); } }
private void ensureProcessIsEnabled(final SProcessDefinition sProcessDefinition) throws SProcessDefinitionNotFoundException, SBonitaReadException, SProcessDefinitionException { final SProcessDefinitionDeployInfo deployInfo = processDefinitionService.getProcessDeploymentInfo(sProcessDefinition.getId()); if (ActivationState.DISABLED.name().equals(deployInfo.getActivationState())) { throw new SProcessDefinitionException("The process " + deployInfo.getName() + " " + deployInfo.getVersion() + " is not enabled.", deployInfo.getProcessId(), deployInfo.getName(), deployInfo.getVersion()); } }
@Override public void delete(final long processId) throws SProcessDefinitionNotFoundException, SProcessDeletionException, SDeletingEnabledProcessException { final SProcessDefinitionLogBuilder logBuilder = getQueriableLog(ActionType.DELETED, "Deleting a Process definition"); final SProcessDefinitionDeployInfo processDefinitionDeployInfo; try { processDefinitionDeployInfo = getProcessDeploymentInfo(processId); if (ActivationState.ENABLED.name().equals(processDefinitionDeployInfo.getActivationState())) { throw new SDeletingEnabledProcessException("Process is enabled.", processDefinitionDeployInfo); } } catch (final SBonitaReadException e) { log(processId, SQueriableLog.STATUS_FAIL, logBuilder, "delete"); throw new SProcessDeletionException(e, processId); } try { recorder.recordDelete(new DeleteRecord(processDefinitionDeployInfo), PROCESSDEFINITION); log(processId, SQueriableLog.STATUS_OK, logBuilder, "delete"); } catch (final SRecorderException e) { log(processId, SQueriableLog.STATUS_FAIL, logBuilder, "delete"); throw new SProcessDeletionException(e, processDefinitionDeployInfo); } }
@Override public void delete(final long processId) throws SProcessDefinitionNotFoundException, SProcessDeletionException, SDeletingEnabledProcessException { final SProcessDefinitionLogBuilder logBuilder = getQueriableLog(ActionType.DELETED, "Deleting a Process definition"); final SProcessDefinitionDeployInfo processDefinitionDeployInfo; try { processDefinitionDeployInfo = getProcessDeploymentInfo(processId); if (ActivationState.ENABLED.name().equals(processDefinitionDeployInfo.getActivationState())) { throw new SDeletingEnabledProcessException("Process is enabled.", processDefinitionDeployInfo); } } catch (final SBonitaReadException e) { log(processId, SQueriableLog.STATUS_FAIL, logBuilder, "delete"); throw new SProcessDeletionException(e, processId); } try { recorder.recordDelete(new DeleteRecord(processDefinitionDeployInfo), PROCESSDEFINITION); log(processId, SQueriableLog.STATUS_OK, logBuilder, "delete"); } catch (final SRecorderException e) { log(processId, SQueriableLog.STATUS_FAIL, logBuilder, "delete"); throw new SProcessDeletionException(e, processDefinitionDeployInfo); } }
public void purgeClassLoader(final long processDefinitionId) throws ProcessDefinitionNotFoundException, UpdateException { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final ProcessDefinitionService processDefinitionService = tenantAccessor.getProcessDefinitionService(); try { final SProcessDefinitionDeployInfo processDeploymentInfo = processDefinitionService.getProcessDeploymentInfo(processDefinitionId); if (!ActivationState.DISABLED.name().equals(processDeploymentInfo.getActivationState())) { throw new UpdateException("Purge can only be done on a disabled process"); } final ProcessInstanceService processInstanceService = tenantAccessor.getProcessInstanceService(); final long numberOfProcessInstances = processInstanceService.getNumberOfProcessInstances(processDefinitionId); if (numberOfProcessInstances != 0) { throw new UpdateException("Purge can only be done on a disabled process with no running instances"); } tenantAccessor.getClassLoaderService().removeLocalClassLoader(ScopeType.PROCESS.name(), processDefinitionId); } catch (final SProcessDefinitionNotFoundException e) { throw new ProcessDefinitionNotFoundException(e); } catch (final SBonitaReadException e) { throw new RetrieveException(e); } catch (SClassLoaderException e) { throw new UpdateException(e); } }
public void purgeClassLoader(final long processDefinitionId) throws ProcessDefinitionNotFoundException, UpdateException { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final ProcessDefinitionService processDefinitionService = tenantAccessor.getProcessDefinitionService(); try { final SProcessDefinitionDeployInfo processDeploymentInfo = processDefinitionService.getProcessDeploymentInfo(processDefinitionId); if (!ActivationState.DISABLED.name().equals(processDeploymentInfo.getActivationState())) { throw new UpdateException("Purge can only be done on a disabled process"); } final ProcessInstanceService processInstanceService = tenantAccessor.getProcessInstanceService(); final long numberOfProcessInstances = processInstanceService.getNumberOfProcessInstances(processDefinitionId); if (numberOfProcessInstances != 0) { throw new UpdateException("Purge can only be done on a disabled process with no running instances"); } tenantAccessor.getClassLoaderService().removeLocalClassLoader(ScopeType.PROCESS.name(), processDefinitionId); } catch (final SProcessDefinitionNotFoundException e) { throw new ProcessDefinitionNotFoundException(e); } catch (final SBonitaReadException e) { throw new RetrieveException(e); } catch (SClassLoaderException e) { throw new UpdateException(e); } }
@Override public void enableProcess(final long processId, boolean failIfAlreadyEnabled) throws SProcessDefinitionNotFoundException, SProcessEnablementException { SProcessDefinitionDeployInfo processDefinitionDeployInfo; try { processDefinitionDeployInfo = getProcessDeploymentInfo(processId); } catch (final SBonitaReadException e) { throw new SProcessEnablementException(e); } if (failIfAlreadyEnabled && ActivationState.ENABLED.name().equals(processDefinitionDeployInfo.getActivationState())) { throw new SProcessEnablementException("Process " + processDefinitionDeployInfo.getName() + " with version " + processDefinitionDeployInfo.getVersion() + " is already enabled"); } if (ConfigurationState.UNRESOLVED.name().equals(processDefinitionDeployInfo.getConfigurationState())) { throw new SProcessEnablementException("Process " + processDefinitionDeployInfo.getName() + " with version " + processDefinitionDeployInfo.getVersion() + " can't be enabled since all dependencies are not resolved yet"); } final EntityUpdateDescriptor descriptor = new EntityUpdateDescriptor(); descriptor.addField(BuilderFactory.get(SProcessDefinitionDeployInfoBuilderFactory.class).getActivationStateKey(), ActivationState.ENABLED.name()); final SPersistenceLogBuilder logBuilder = getQueriableLog(ActionType.UPDATED, "Enabling the process"); try { update(processId, processDefinitionDeployInfo, getUpdateRecord(descriptor, processDefinitionDeployInfo), PROCESSDEFINITION_IS_ENABLED); log(processId, SQueriableLog.STATUS_OK, logBuilder, "enableProcess"); } catch (final SRecorderException | SCacheException e) { log(processId, SQueriableLog.STATUS_FAIL, logBuilder, "enableProcess"); throw new SProcessEnablementException(e); } }
@Override public void enableProcess(final long processId, boolean failIfAlreadyEnabled) throws SProcessDefinitionNotFoundException, SProcessEnablementException { SProcessDefinitionDeployInfo processDefinitionDeployInfo; try { processDefinitionDeployInfo = getProcessDeploymentInfo(processId); } catch (final SBonitaReadException e) { throw new SProcessEnablementException(e); } if (failIfAlreadyEnabled && ActivationState.ENABLED.name().equals(processDefinitionDeployInfo.getActivationState())) { throw new SProcessEnablementException("Process " + processDefinitionDeployInfo.getName() + " with version " + processDefinitionDeployInfo.getVersion() + " is already enabled"); } if (ConfigurationState.UNRESOLVED.name().equals(processDefinitionDeployInfo.getConfigurationState())) { throw new SProcessEnablementException("Process " + processDefinitionDeployInfo.getName() + " with version " + processDefinitionDeployInfo.getVersion() + " can't be enabled since all dependencies are not resolved yet"); } final EntityUpdateDescriptor descriptor = new EntityUpdateDescriptor(); descriptor.addField(BuilderFactory.get(SProcessDefinitionDeployInfoBuilderFactory.class).getActivationStateKey(), ActivationState.ENABLED.name()); final SPersistenceLogBuilder logBuilder = getQueriableLog(ActionType.UPDATED, "Enabling the process"); try { update(processId, processDefinitionDeployInfo, getUpdateRecord(descriptor, processDefinitionDeployInfo), PROCESSDEFINITION_IS_ENABLED); log(processId, SQueriableLog.STATUS_OK, logBuilder, "enableProcess"); } catch (final SRecorderException | SCacheException e) { log(processId, SQueriableLog.STATUS_FAIL, logBuilder, "enableProcess"); throw new SProcessEnablementException(e); } }
@Override public void disableProcess(long processId, boolean failIfAlreadyDisabled) throws SProcessDefinitionNotFoundException, SProcessDisablementException{ SProcessDefinitionDeployInfo processDefinitionDeployInfo; try { processDefinitionDeployInfo = getProcessDeploymentInfo(processId); } catch (final SBonitaReadException e) { throw new SProcessDisablementException(e); } if (failIfAlreadyDisabled && ActivationState.DISABLED.name().equals(processDefinitionDeployInfo.getActivationState())) { throw new SProcessDisablementException("Process " + processDefinitionDeployInfo.getName() + " with version " + processDefinitionDeployInfo.getVersion() + " is already disabled"); } final EntityUpdateDescriptor descriptor = new EntityUpdateDescriptor(); descriptor.addField(BuilderFactory.get(SProcessDefinitionDeployInfoBuilderFactory.class).getActivationStateKey(), ActivationState.DISABLED.name()); final SPersistenceLogBuilder logBuilder = getQueriableLog(ActionType.UPDATED, "Disabling the process"); try { update(processId, processDefinitionDeployInfo, getUpdateRecord(descriptor, processDefinitionDeployInfo), PROCESSDEFINITION_IS_DISABLED); log(processDefinitionDeployInfo.getId(), SQueriableLog.STATUS_OK, logBuilder, "disableProcess"); } catch (final SRecorderException | SCacheException e) { log(processDefinitionDeployInfo.getId(), SQueriableLog.STATUS_FAIL, logBuilder, "disableProcess"); throw new SProcessDisablementException(e); } }
@Override public void disableProcess(long processId, boolean failIfAlreadyDisabled) throws SProcessDefinitionNotFoundException, SProcessDisablementException{ SProcessDefinitionDeployInfo processDefinitionDeployInfo; try { processDefinitionDeployInfo = getProcessDeploymentInfo(processId); } catch (final SBonitaReadException e) { throw new SProcessDisablementException(e); } if (failIfAlreadyDisabled && ActivationState.DISABLED.name().equals(processDefinitionDeployInfo.getActivationState())) { throw new SProcessDisablementException("Process " + processDefinitionDeployInfo.getName() + " with version " + processDefinitionDeployInfo.getVersion() + " is already disabled"); } final EntityUpdateDescriptor descriptor = new EntityUpdateDescriptor(); descriptor.addField(BuilderFactory.get(SProcessDefinitionDeployInfoBuilderFactory.class).getActivationStateKey(), ActivationState.DISABLED.name()); final SPersistenceLogBuilder logBuilder = getQueriableLog(ActionType.UPDATED, "Disabling the process"); try { update(processId, processDefinitionDeployInfo, getUpdateRecord(descriptor, processDefinitionDeployInfo), PROCESSDEFINITION_IS_DISABLED); log(processDefinitionDeployInfo.getId(), SQueriableLog.STATUS_OK, logBuilder, "disableProcess"); } catch (final SRecorderException | SCacheException e) { log(processDefinitionDeployInfo.getId(), SQueriableLog.STATUS_FAIL, logBuilder, "disableProcess"); throw new SProcessDisablementException(e); } }