use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.
the class SubmitStartFormCmd method execute.
@Override
public ProcessInstance execute(CommandContext commandContext) {
ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache();
ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
ensureNotNull("No process definition found for id = '" + processDefinitionId + "'", "processDefinition", processDefinition);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkCreateProcessInstance(processDefinition);
}
ExecutionEntity processInstance = null;
if (businessKey != null) {
processInstance = processDefinition.createProcessInstance(businessKey);
} else {
processInstance = processDefinition.createProcessInstance();
}
// see CAM-2828
if (processDefinition.getInitial().isAsyncBefore()) {
// avoid firing history events
processInstance.setStartContext(new ProcessInstanceStartContext(processInstance.getActivity()));
FormPropertyHelper.initFormPropertiesOnScope(variables, processInstance);
processInstance.start();
} else {
processInstance.startWithFormProperties(variables);
}
return processInstance;
}
use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.
the class DefaultFormHandler method fireFormPropertyHistoryEvents.
protected void fireFormPropertyHistoryEvents(VariableMap properties, VariableScope variableScope) {
final ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
HistoryLevel historyLevel = processEngineConfiguration.getHistoryLevel();
if (historyLevel.isHistoryEventProduced(HistoryEventTypes.FORM_PROPERTY_UPDATE, variableScope)) {
// fire history events
final ExecutionEntity executionEntity;
final String taskId;
if (variableScope instanceof ExecutionEntity) {
executionEntity = (ExecutionEntity) variableScope;
taskId = null;
} else if (variableScope instanceof TaskEntity) {
TaskEntity task = (TaskEntity) variableScope;
executionEntity = task.getExecution();
taskId = task.getId();
} else {
executionEntity = null;
taskId = null;
}
if (executionEntity != null) {
for (final String variableName : properties.keySet()) {
final TypedValue value = properties.getValueTyped(variableName);
// NOTE: SerializableValues are never stored as form properties
if (!(value instanceof SerializableValue) && value.getValue() != null && value.getValue() instanceof String) {
final String stringValue = (String) value.getValue();
HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
@Override
public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
return producer.createFormPropertyUpdateEvt(executionEntity, variableName, stringValue, taskId);
}
});
}
}
}
}
}
use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.
the class DbIdentityServiceProvider method lockUser.
protected void lockUser(UserEntity user) {
ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
int max = processEngineConfiguration.getLoginDelayMaxTime();
int baseTime = processEngineConfiguration.getLoginDelayBase();
int factor = processEngineConfiguration.getLoginDelayFactor();
int attempts = user.getAttempts() + 1;
long delay = (long) (baseTime * Math.pow(factor, attempts - 1));
delay = Math.min(delay, max) * 1000;
long currentTime = ClockUtil.getCurrentTime().getTime();
Date lockExpirationTime = new Date(currentTime + delay);
getIdentityInfoManager().updateUserLock(user, attempts, lockExpirationTime);
}
use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.
the class MigrateProcessInstanceBatchCmd method createBatch.
protected BatchEntity createBatch(CommandContext commandContext, MigrationPlan migrationPlan, Collection<String> processInstanceIds, ProcessDefinitionEntity sourceProcessDefinition) {
ProcessEngineConfigurationImpl processEngineConfiguration = commandContext.getProcessEngineConfiguration();
BatchJobHandler<MigrationBatchConfiguration> batchJobHandler = getBatchJobHandler(processEngineConfiguration);
MigrationBatchConfiguration configuration = new MigrationBatchConfiguration(new ArrayList<String>(processInstanceIds), migrationPlan, executionBuilder.isSkipCustomListeners(), executionBuilder.isSkipIoMappings());
BatchEntity batch = new BatchEntity();
batch.setType(batchJobHandler.getType());
batch.setTotalJobs(calculateSize(processEngineConfiguration, configuration));
batch.setBatchJobsPerSeed(processEngineConfiguration.getBatchJobsPerSeed());
batch.setInvocationsPerBatchJob(processEngineConfiguration.getInvocationsPerBatchJob());
batch.setConfigurationBytes(batchJobHandler.writeConfiguration(configuration));
batch.setTenantId(sourceProcessDefinition.getTenantId());
commandContext.getBatchManager().insert(batch);
return batch;
}
use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.
the class TestHelper method assertAndEnsureCleanDbAndCache.
/**
* Ensures that the deployment cache and database is clean after a test. If not the cache
* and database will be cleared.
*
* @param processEngine the {@link ProcessEngine} to test
* @param fail if true the method will throw an {@link AssertionError} if the deployment cache or database is not clean
* @throws AssertionError if the deployment cache or database was not clean
*/
public static String assertAndEnsureCleanDbAndCache(ProcessEngine processEngine, boolean fail) {
ProcessEngineConfigurationImpl processEngineConfiguration = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration();
// clear user operation log in case some operations are
// executed with an authenticated user
clearUserOperationLog(processEngineConfiguration);
LOG.debug("verifying that db is clean after test");
PurgeReport purgeReport = ((ManagementServiceImpl) processEngine.getManagementService()).purge();
String paRegistrationMessage = assertAndEnsureNoProcessApplicationsRegistered(processEngine);
StringBuilder message = new StringBuilder();
CachePurgeReport cachePurgeReport = purgeReport.getCachePurgeReport();
if (!cachePurgeReport.isEmpty()) {
message.append("Deployment cache is not clean:\n").append(cachePurgeReport.getPurgeReportAsString());
} else {
LOG.debug("Deployment cache was clean.");
}
DatabasePurgeReport databasePurgeReport = purgeReport.getDatabasePurgeReport();
if (!databasePurgeReport.isEmpty()) {
message.append("Database is not clean:\n").append(databasePurgeReport.getPurgeReportAsString());
} else {
LOG.debug("Database was clean.");
}
if (paRegistrationMessage != null) {
message.append(paRegistrationMessage);
}
if (fail && message.length() > 0) {
Assert.fail(message.toString());
}
return message.toString();
}
Aggregations