use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.
the class JobResourceImpl method setJobRetries.
@Override
public void setJobRetries(RetriesDto dto) {
try {
ManagementService managementService = engine.getManagementService();
managementService.setJobRetries(jobId, dto.getRetries());
} catch (AuthorizationException e) {
throw e;
} catch (ProcessEngineException e) {
throw new InvalidRequestException(Status.INTERNAL_SERVER_ERROR, e.getMessage());
}
}
use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.
the class AbstractParseBpmPlatformXmlStep method checkValidBpmPlatformXmlResourceLocation.
public URL checkValidBpmPlatformXmlResourceLocation(String url) {
url = autoCompleteUrl(url);
URL fileLocation = null;
try {
fileLocation = checkValidUrlLocation(url);
if (fileLocation == null) {
fileLocation = checkValidFileLocation(url);
}
} catch (MalformedURLException e) {
throw new ProcessEngineException("'" + url + "' is not a valid camunda bpm platform configuration resource location.", e);
}
return fileLocation;
}
use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.
the class DeployBarTask method execute.
public void execute() throws BuildException {
List<File> files = new ArrayList<File>();
if (file != null) {
files.add(file);
}
if (fileSets != null) {
for (FileSet fileSet : fileSets) {
DirectoryScanner directoryScanner = fileSet.getDirectoryScanner(getProject());
File baseDir = directoryScanner.getBasedir();
String[] includedFiles = directoryScanner.getIncludedFiles();
String[] excludedFiles = directoryScanner.getExcludedFiles();
List<String> excludedFilesList = Arrays.asList(excludedFiles);
for (String includedFile : includedFiles) {
if (!excludedFilesList.contains(includedFile)) {
files.add(new File(baseDir, includedFile));
}
}
}
}
Thread currentThread = Thread.currentThread();
ClassLoader originalClassLoader = currentThread.getContextClassLoader();
currentThread.setContextClassLoader(DeployBarTask.class.getClassLoader());
LogUtil.readJavaUtilLoggingConfigFromClasspath();
try {
log("Initializing process engine " + processEngineName);
ProcessEngines.init();
ProcessEngine processEngine = ProcessEngines.getProcessEngine(processEngineName);
if (processEngine == null) {
List<ProcessEngineInfo> processEngineInfos = ProcessEngines.getProcessEngineInfos();
if (processEngineInfos != null && processEngineInfos.size() > 0) {
// Since no engine with the given name is found, we can't be 100% sure which ProcessEngineInfo
// is causing the error. We should show ALL errors and process engine names / resource URL's.
String message = getErrorMessage(processEngineInfos, processEngineName);
throw new ProcessEngineException(message);
} else
throw new ProcessEngineException("Could not find a process engine with name '" + processEngineName + "', no engines found. " + "Make sure an engine configuration is present on the classpath");
}
RepositoryService repositoryService = processEngine.getRepositoryService();
log("Starting to deploy " + files.size() + " files");
for (File file : files) {
String path = file.getAbsolutePath();
log("Handling file " + path);
try {
FileInputStream inputStream = new FileInputStream(file);
try {
log("deploying bar " + path);
repositoryService.createDeployment().name(file.getName()).addZipInputStream(new ZipInputStream(inputStream)).deploy();
} finally {
IoUtil.closeSilently(inputStream);
}
} catch (Exception e) {
throw new BuildException("couldn't deploy bar " + path + ": " + e.getMessage(), e);
}
}
} finally {
currentThread.setContextClassLoader(originalClassLoader);
}
}
use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.
the class ProcessEngineConfigurationImpl method initSqlSessionFactory.
protected void initSqlSessionFactory() {
// to protect access to cachedSqlSessionFactory see CAM-6682
synchronized (ProcessEngineConfigurationImpl.class) {
if (isUseSharedSqlSessionFactory) {
sqlSessionFactory = cachedSqlSessionFactory;
}
if (sqlSessionFactory == null) {
InputStream inputStream = null;
try {
inputStream = getMyBatisXmlConfigurationSteam();
// update the jdbc parameters to the configured ones...
Environment environment = new Environment("default", transactionFactory, dataSource);
Reader reader = new InputStreamReader(inputStream);
Properties properties = new Properties();
if (isUseSharedSqlSessionFactory) {
properties.put("prefix", "${@org.camunda.bpm.engine.impl.context.Context@getProcessEngineConfiguration().databaseTablePrefix}");
} else {
properties.put("prefix", databaseTablePrefix);
}
initSqlSessionFactoryProperties(properties, databaseTablePrefix, databaseType);
XMLConfigBuilder parser = new XMLConfigBuilder(reader, "", properties);
Configuration configuration = parser.getConfiguration();
configuration.setEnvironment(environment);
configuration = parser.parse();
configuration.setDefaultStatementTimeout(jdbcStatementTimeout);
if (isJdbcBatchProcessing()) {
configuration.setDefaultExecutorType(ExecutorType.BATCH);
}
sqlSessionFactory = new DefaultSqlSessionFactory(configuration);
if (isUseSharedSqlSessionFactory) {
cachedSqlSessionFactory = sqlSessionFactory;
}
} catch (Exception e) {
throw new ProcessEngineException("Error while building ibatis SqlSessionFactory: " + e.getMessage(), e);
} finally {
IoUtil.closeSilently(inputStream);
}
}
}
}
use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.
the class AbstractProcessInstanceModificationCommand method getScopeExecutionForActivityInstance.
protected ExecutionEntity getScopeExecutionForActivityInstance(ExecutionEntity processInstance, ActivityExecutionTreeMapping mapping, ActivityInstance activityInstance) {
ensureNotNull("activityInstance", activityInstance);
ProcessDefinitionImpl processDefinition = processInstance.getProcessDefinition();
ScopeImpl scope = getScopeForActivityInstance(processDefinition, activityInstance);
Set<ExecutionEntity> executions = mapping.getExecutions(scope);
Set<String> activityInstanceExecutions = new HashSet<String>(Arrays.asList(activityInstance.getExecutionIds()));
// remove with fix of CAM-3574
for (String activityInstanceExecutionId : activityInstance.getExecutionIds()) {
ExecutionEntity execution = Context.getCommandContext().getExecutionManager().findExecutionById(activityInstanceExecutionId);
if (execution.isConcurrent() && execution.hasChildren()) {
// concurrent executions have at most one child
ExecutionEntity child = execution.getExecutions().get(0);
activityInstanceExecutions.add(child.getId());
}
}
// find the scope execution for the given activity instance
Set<ExecutionEntity> retainedExecutionsForInstance = new HashSet<ExecutionEntity>();
for (ExecutionEntity execution : executions) {
if (activityInstanceExecutions.contains(execution.getId())) {
retainedExecutionsForInstance.add(execution);
}
}
if (retainedExecutionsForInstance.size() != 1) {
throw new ProcessEngineException("There are " + retainedExecutionsForInstance.size() + " (!= 1) executions for activity instance " + activityInstance.getId());
}
return retainedExecutionsForInstance.iterator().next();
}
Aggregations