Search in sources :

Example 96 with ProcessEngineException

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());
    }
}
Also used : ManagementService(org.camunda.bpm.engine.ManagementService) AuthorizationException(org.camunda.bpm.engine.AuthorizationException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 97 with ProcessEngineException

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;
}
Also used : MalformedURLException(java.net.MalformedURLException) URL(java.net.URL) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 98 with ProcessEngineException

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);
    }
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) ArrayList(java.util.ArrayList) FileInputStream(java.io.FileInputStream) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) BuildException(org.apache.tools.ant.BuildException) ProcessEngineInfo(org.camunda.bpm.engine.ProcessEngineInfo) ZipInputStream(java.util.zip.ZipInputStream) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) BuildException(org.apache.tools.ant.BuildException) File(java.io.File) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Example 99 with ProcessEngineException

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);
            }
        }
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) Configuration(org.apache.ibatis.session.Configuration) ProcessEngineConfiguration(org.camunda.bpm.engine.ProcessEngineConfiguration) DmnEngineConfiguration(org.camunda.bpm.dmn.engine.DmnEngineConfiguration) DefaultDmnEngineConfiguration(org.camunda.bpm.dmn.engine.impl.DefaultDmnEngineConfiguration) InputStream(java.io.InputStream) DefaultSqlSessionFactory(org.apache.ibatis.session.defaults.DefaultSqlSessionFactory) Environment(org.apache.ibatis.mapping.Environment) ScriptingEnvironment(org.camunda.bpm.engine.impl.scripting.env.ScriptingEnvironment) InputStreamReader(java.io.InputStreamReader) Reader(java.io.Reader) XMLConfigBuilder(org.apache.ibatis.builder.xml.XMLConfigBuilder) Properties(java.util.Properties) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) SQLException(java.sql.SQLException) ParseException(java.text.ParseException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 100 with ProcessEngineException

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();
}
Also used : ProcessDefinitionImpl(org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) ScopeImpl(org.camunda.bpm.engine.impl.pvm.process.ScopeImpl) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) HashSet(java.util.HashSet)

Aggregations

ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)611 Test (org.junit.Test)185 Deployment (org.camunda.bpm.engine.test.Deployment)138 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)79 HashMap (java.util.HashMap)62 RestException (org.camunda.bpm.engine.rest.exception.RestException)62 Matchers.anyString (org.mockito.Matchers.anyString)60 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)57 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)47 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)41 Task (org.camunda.bpm.engine.task.Task)40 ArrayList (java.util.ArrayList)39 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)36 Matchers.containsString (org.hamcrest.Matchers.containsString)35 CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)24 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)22 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)21 CaseInstanceQuery (org.camunda.bpm.engine.runtime.CaseInstanceQuery)21 NotValidException (org.camunda.bpm.engine.exception.NotValidException)19 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)18