use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.
the class JobRestServiceInteractionTest method deleteLockedJob.
@Test
public void deleteLockedJob() {
String jobId = MockProvider.EXAMPLE_JOB_ID;
String expectedMessage = "Cannot delete job when the job is being executed. Try again later.";
doThrow(new ProcessEngineException(expectedMessage)).when(mockManagementService).deleteJob(jobId);
given().pathParam("id", jobId).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).body("type", equalTo(RestException.class.getSimpleName())).body("message", equalTo(expectedMessage)).when().delete(SINGLE_JOB_RESOURCE_URL);
verify(mockManagementService).deleteJob(jobId);
verifyNoMoreInteractions(mockManagementService);
}
use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.
the class PurgeDatabaseAndCacheCmd method purgeDatabase.
private DatabasePurgeReport purgeDatabase(CommandContext commandContext) {
DbEntityManager dbEntityManager = commandContext.getDbEntityManager();
// For MySQL and MariaDB we have to disable foreign key check,
// to delete the table data as bulk operation (execution, incident etc.)
// The flag will be reset by the DBEntityManager after flush.
dbEntityManager.setIgnoreForeignKeysForNextFlush(true);
List<String> tablesNames = dbEntityManager.getTableNamesPresentInDatabase();
String databaseTablePrefix = commandContext.getProcessEngineConfiguration().getDatabaseTablePrefix().trim();
// for each table
DatabasePurgeReport databasePurgeReport = new DatabasePurgeReport();
for (String tableName : tablesNames) {
String tableNameWithoutPrefix = tableName.replace(databaseTablePrefix, EMPTY_STRING);
if (!TABLENAMES_EXCLUDED_FROM_DB_CLEAN_CHECK.contains(tableNameWithoutPrefix)) {
// Check if table contains data
Map<String, String> param = new HashMap<String, String>();
param.put(TABLE_NAME, tableName);
Long count = (Long) dbEntityManager.selectOne(SELECT_TABLE_COUNT, param);
if (count > 0) {
databasePurgeReport.addPurgeInformation(tableName, count);
// Get corresponding entity classes for the table, which contains data
List<Class<? extends DbEntity>> entities = commandContext.getTableDataManager().getEntities(tableName);
if (entities.isEmpty()) {
throw new ProcessEngineException("No mapped implementation of " + DbEntity.class.getName() + " was found for: " + tableName);
}
// Delete the table data as bulk operation with the first entity
Class<? extends DbEntity> entity = entities.get(0);
DbBulkOperation deleteBulkOp = new DbBulkOperation(DbOperationType.DELETE_BULK, entity, DELETE_TABLE_DATA, param);
dbEntityManager.getDbOperationManager().addOperation(deleteBulkOp);
}
}
}
return databasePurgeReport;
}
use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.
the class DeleteJobCmd method execute.
public Object execute(CommandContext commandContext) {
ensureNotNull("jobId", jobId);
JobEntity job = commandContext.getJobManager().findJobById(jobId);
ensureNotNull("No job found with id '" + jobId + "'", "job", job);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkUpdateJob(job);
}
// In that case, we can't allow to delete the job.
if (job.getLockOwner() != null || job.getLockExpirationTime() != null) {
throw new ProcessEngineException("Cannot delete job when the job is being executed. Try again later.");
}
job.delete();
return null;
}
use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.
the class MscManagedProcessEngineController method addProcessEnginePlugins.
protected void addProcessEnginePlugins(JtaProcessEngineConfiguration processEngineConfiguration) {
// add process engine plugins:
List<ProcessEnginePluginXml> pluginConfigurations = processEngineMetadata.getPluginConfigurations();
for (ProcessEnginePluginXml pluginXml : pluginConfigurations) {
// create plugin instance
ProcessEnginePlugin plugin = null;
String pluginClassName = pluginXml.getPluginClass();
try {
plugin = (ProcessEnginePlugin) createInstance(pluginClassName);
} catch (ClassCastException e) {
throw new ProcessEngineException("Process engine plugin '" + pluginClassName + "' does not implement interface " + ProcessEnginePlugin.class.getName() + "'.");
}
// apply configured properties
Map<String, String> properties = pluginXml.getProperties();
PropertyHelper.applyProperties(plugin, properties);
// add to configuration
processEngineConfiguration.getProcessEnginePlugins().add(plugin);
}
}
use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.
the class MscRuntimeContainerDelegate method registerProcessEngine.
// RuntimeContainerDelegate implementation /////////////////////////////
public void registerProcessEngine(ProcessEngine processEngine) {
if (processEngine == null) {
throw new ProcessEngineException("Cannot register process engine with Msc Runtime Container: process engine is 'null'");
}
ServiceName serviceName = ServiceNames.forManagedProcessEngine(processEngine.getName());
if (serviceContainer.getService(serviceName) == null) {
MscManagedProcessEngine processEngineRegistration = new MscManagedProcessEngine(processEngine);
// install the service asynchronously.
childTarget.addService(serviceName, processEngineRegistration).setInitialMode(Mode.ACTIVE).addDependency(ServiceNames.forMscRuntimeContainerDelegate(), MscRuntimeContainerDelegate.class, processEngineRegistration.getRuntimeContainerDelegateInjector()).install();
}
}
Aggregations