Search in sources :

Example 86 with ActivitiException

use of org.activiti.engine.ActivitiException in project Activiti by Activiti.

the class JPAEntityListVariableType method serializeIds.

/**
 * @return a bytearray containing all ID's in the given string serialized as an array.
 */
protected byte[] serializeIds(List<String> ids) {
    try {
        String[] toStore = ids.toArray(new String[] {});
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream out = new ObjectOutputStream(baos);
        out.writeObject(toStore);
        return baos.toByteArray();
    } catch (IOException ioe) {
        throw new ActivitiException("Unexpected exception when serializing JPA id's", ioe);
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream)

Example 87 with ActivitiException

use of org.activiti.engine.ActivitiException in project Activiti by Activiti.

the class SerializableType method serialize.

public byte[] serialize(Object value, ValueFields valueFields) {
    if (value == null) {
        return null;
    }
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = null;
    try {
        oos = createObjectOutputStream(baos);
        oos.writeObject(value);
    } catch (Exception e) {
        throw new ActivitiException("Couldn't serialize value '" + value + "' in variable '" + valueFields.getName() + "'", e);
    } finally {
        IoUtil.closeSilently(oos);
    }
    return baos.toByteArray();
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) ActivitiException(org.activiti.engine.ActivitiException) IOException(java.io.IOException)

Example 88 with ActivitiException

use of org.activiti.engine.ActivitiException in project Activiti by Activiti.

the class ProcessEngineConfigurationImpl method getDefaultBpmnParseHandlers.

public List<BpmnParseHandler> getDefaultBpmnParseHandlers() {
    // Alphabetic list of default parse handler classes
    List<BpmnParseHandler> bpmnParserHandlers = new ArrayList<BpmnParseHandler>();
    bpmnParserHandlers.add(new BoundaryEventParseHandler());
    bpmnParserHandlers.add(new BusinessRuleParseHandler());
    bpmnParserHandlers.add(new CallActivityParseHandler());
    bpmnParserHandlers.add(new CancelEventDefinitionParseHandler());
    bpmnParserHandlers.add(new CompensateEventDefinitionParseHandler());
    bpmnParserHandlers.add(new EndEventParseHandler());
    bpmnParserHandlers.add(new ErrorEventDefinitionParseHandler());
    bpmnParserHandlers.add(new EventBasedGatewayParseHandler());
    bpmnParserHandlers.add(new ExclusiveGatewayParseHandler());
    bpmnParserHandlers.add(new InclusiveGatewayParseHandler());
    bpmnParserHandlers.add(new IntermediateCatchEventParseHandler());
    bpmnParserHandlers.add(new IntermediateThrowEventParseHandler());
    bpmnParserHandlers.add(new ManualTaskParseHandler());
    bpmnParserHandlers.add(new MessageEventDefinitionParseHandler());
    bpmnParserHandlers.add(new ParallelGatewayParseHandler());
    bpmnParserHandlers.add(new ProcessParseHandler());
    bpmnParserHandlers.add(new ReceiveTaskParseHandler());
    bpmnParserHandlers.add(new ScriptTaskParseHandler());
    bpmnParserHandlers.add(new SendTaskParseHandler());
    bpmnParserHandlers.add(new SequenceFlowParseHandler());
    bpmnParserHandlers.add(new ServiceTaskParseHandler());
    bpmnParserHandlers.add(new SignalEventDefinitionParseHandler());
    bpmnParserHandlers.add(new StartEventParseHandler());
    bpmnParserHandlers.add(new SubProcessParseHandler());
    bpmnParserHandlers.add(new EventSubProcessParseHandler());
    bpmnParserHandlers.add(new AdhocSubProcessParseHandler());
    bpmnParserHandlers.add(new TaskParseHandler());
    bpmnParserHandlers.add(new TimerEventDefinitionParseHandler());
    bpmnParserHandlers.add(new TransactionParseHandler());
    bpmnParserHandlers.add(new UserTaskParseHandler());
    // Replace any default handler if the user wants to replace them
    if (customDefaultBpmnParseHandlers != null) {
        Map<Class<?>, BpmnParseHandler> customParseHandlerMap = new HashMap<Class<?>, BpmnParseHandler>();
        for (BpmnParseHandler bpmnParseHandler : customDefaultBpmnParseHandlers) {
            for (Class<?> handledType : bpmnParseHandler.getHandledTypes()) {
                customParseHandlerMap.put(handledType, bpmnParseHandler);
            }
        }
        for (int i = 0; i < bpmnParserHandlers.size(); i++) {
            // All the default handlers support only one type
            BpmnParseHandler defaultBpmnParseHandler = bpmnParserHandlers.get(i);
            if (defaultBpmnParseHandler.getHandledTypes().size() != 1) {
                StringBuilder supportedTypes = new StringBuilder();
                for (Class<?> type : defaultBpmnParseHandler.getHandledTypes()) {
                    supportedTypes.append(" ").append(type.getCanonicalName()).append(" ");
                }
                throw new ActivitiException("The default BPMN parse handlers should only support one type, but " + defaultBpmnParseHandler.getClass() + " supports " + supportedTypes.toString() + ". This is likely a programmatic error");
            } else {
                Class<?> handledType = defaultBpmnParseHandler.getHandledTypes().iterator().next();
                if (customParseHandlerMap.containsKey(handledType)) {
                    BpmnParseHandler newBpmnParseHandler = customParseHandlerMap.get(handledType);
                    log.info("Replacing default BpmnParseHandler " + defaultBpmnParseHandler.getClass().getName() + " with " + newBpmnParseHandler.getClass().getName());
                    bpmnParserHandlers.set(i, newBpmnParseHandler);
                }
            }
        }
    }
    return bpmnParserHandlers;
}
Also used : UserTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.UserTaskParseHandler) ServiceTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ServiceTaskParseHandler) ReceiveTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ReceiveTaskParseHandler) TaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.TaskParseHandler) SendTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.SendTaskParseHandler) ManualTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ManualTaskParseHandler) ScriptTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ScriptTaskParseHandler) ActivitiException(org.activiti.engine.ActivitiException) BusinessRuleParseHandler(org.activiti.engine.impl.bpmn.parser.handler.BusinessRuleParseHandler) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) BoundaryEventParseHandler(org.activiti.engine.impl.bpmn.parser.handler.BoundaryEventParseHandler) InclusiveGatewayParseHandler(org.activiti.engine.impl.bpmn.parser.handler.InclusiveGatewayParseHandler) ArrayList(java.util.ArrayList) AdhocSubProcessParseHandler(org.activiti.engine.impl.bpmn.parser.handler.AdhocSubProcessParseHandler) SubProcessParseHandler(org.activiti.engine.impl.bpmn.parser.handler.SubProcessParseHandler) EventSubProcessParseHandler(org.activiti.engine.impl.bpmn.parser.handler.EventSubProcessParseHandler) AdhocSubProcessParseHandler(org.activiti.engine.impl.bpmn.parser.handler.AdhocSubProcessParseHandler) ProcessParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ProcessParseHandler) BpmnParseHandler(org.activiti.engine.parse.BpmnParseHandler) ServiceTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ServiceTaskParseHandler) EventBasedGatewayParseHandler(org.activiti.engine.impl.bpmn.parser.handler.EventBasedGatewayParseHandler) UserTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.UserTaskParseHandler) MessageEventDefinitionParseHandler(org.activiti.engine.impl.bpmn.parser.handler.MessageEventDefinitionParseHandler) ScriptTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ScriptTaskParseHandler) SequenceFlowParseHandler(org.activiti.engine.impl.bpmn.parser.handler.SequenceFlowParseHandler) TimerEventDefinitionParseHandler(org.activiti.engine.impl.bpmn.parser.handler.TimerEventDefinitionParseHandler) SendTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.SendTaskParseHandler) EventSubProcessParseHandler(org.activiti.engine.impl.bpmn.parser.handler.EventSubProcessParseHandler) EndEventParseHandler(org.activiti.engine.impl.bpmn.parser.handler.EndEventParseHandler) CancelEventDefinitionParseHandler(org.activiti.engine.impl.bpmn.parser.handler.CancelEventDefinitionParseHandler) StartEventParseHandler(org.activiti.engine.impl.bpmn.parser.handler.StartEventParseHandler) ErrorEventDefinitionParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ErrorEventDefinitionParseHandler) SubProcessParseHandler(org.activiti.engine.impl.bpmn.parser.handler.SubProcessParseHandler) EventSubProcessParseHandler(org.activiti.engine.impl.bpmn.parser.handler.EventSubProcessParseHandler) AdhocSubProcessParseHandler(org.activiti.engine.impl.bpmn.parser.handler.AdhocSubProcessParseHandler) ManualTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ManualTaskParseHandler) CallActivityParseHandler(org.activiti.engine.impl.bpmn.parser.handler.CallActivityParseHandler) ParallelGatewayParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ParallelGatewayParseHandler) IntermediateCatchEventParseHandler(org.activiti.engine.impl.bpmn.parser.handler.IntermediateCatchEventParseHandler) TransactionParseHandler(org.activiti.engine.impl.bpmn.parser.handler.TransactionParseHandler) CompensateEventDefinitionParseHandler(org.activiti.engine.impl.bpmn.parser.handler.CompensateEventDefinitionParseHandler) ExclusiveGatewayParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ExclusiveGatewayParseHandler) ReceiveTaskParseHandler(org.activiti.engine.impl.bpmn.parser.handler.ReceiveTaskParseHandler) IntermediateThrowEventParseHandler(org.activiti.engine.impl.bpmn.parser.handler.IntermediateThrowEventParseHandler) SignalEventDefinitionParseHandler(org.activiti.engine.impl.bpmn.parser.handler.SignalEventDefinitionParseHandler)

Example 89 with ActivitiException

use of org.activiti.engine.ActivitiException in project Activiti by Activiti.

the class ProcessEngineConfigurationImpl method initDatabaseType.

public void initDatabaseType() {
    Connection connection = null;
    try {
        connection = dataSource.getConnection();
        DatabaseMetaData databaseMetaData = connection.getMetaData();
        String databaseProductName = databaseMetaData.getDatabaseProductName();
        log.debug("database product name: '{}'", databaseProductName);
        databaseType = databaseTypeMappings.getProperty(databaseProductName);
        if (databaseType == null) {
            throw new ActivitiException("couldn't deduct database type from database product name '" + databaseProductName + "'");
        }
        log.debug("using database type: {}", databaseType);
        // Especially with executions, with 100 as default, this limit is passed.
        if (DATABASE_TYPE_MSSQL.equals(databaseType)) {
            maxNrOfStatementsInBulkInsert = DEFAULT_MAX_NR_OF_STATEMENTS_BULK_INSERT_SQL_SERVER;
        }
    } catch (SQLException e) {
        log.error("Exception while initializing Database connection", e);
    } finally {
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException e) {
            log.error("Exception while closing the Database connection", e);
        }
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) SQLException(java.sql.SQLException) Connection(java.sql.Connection) DatabaseMetaData(java.sql.DatabaseMetaData)

Example 90 with ActivitiException

use of org.activiti.engine.ActivitiException in project Activiti by Activiti.

the class ProcessEngineConfigurationImpl method initSqlSessionFactory.

public void initSqlSessionFactory() {
    if (sqlSessionFactory == null) {
        InputStream inputStream = null;
        try {
            inputStream = getMyBatisXmlConfigurationStream();
            Environment environment = new Environment("default", transactionFactory, dataSource);
            Reader reader = new InputStreamReader(inputStream);
            Properties properties = new Properties();
            properties.put("prefix", databaseTablePrefix);
            String wildcardEscapeClause = "";
            if ((databaseWildcardEscapeCharacter != null) && (databaseWildcardEscapeCharacter.length() != 0)) {
                wildcardEscapeClause = " escape '" + databaseWildcardEscapeCharacter + "'";
            }
            properties.put("wildcardEscapeClause", wildcardEscapeClause);
            // set default properties
            properties.put("limitBefore", "");
            properties.put("limitAfter", "");
            properties.put("limitBetween", "");
            properties.put("limitOuterJoinBetween", "");
            properties.put("limitBeforeNativeQuery", "");
            properties.put("orderBy", "order by ${orderByColumns}");
            properties.put("blobType", "BLOB");
            properties.put("boolValue", "TRUE");
            if (databaseType != null) {
                properties.load(getResourceAsStream("org/activiti/db/properties/" + databaseType + ".properties"));
            }
            Configuration configuration = initMybatisConfiguration(environment, reader, properties);
            sqlSessionFactory = new DefaultSqlSessionFactory(configuration);
        } catch (Exception e) {
            throw new ActivitiException("Error while building ibatis SqlSessionFactory: " + e.getMessage(), e);
        } finally {
            IoUtil.closeSilently(inputStream);
        }
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) InputStreamReader(java.io.InputStreamReader) ProcessEngineConfiguration(org.activiti.engine.ProcessEngineConfiguration) Configuration(org.apache.ibatis.session.Configuration) InputStream(java.io.InputStream) DefaultSqlSessionFactory(org.apache.ibatis.session.defaults.DefaultSqlSessionFactory) Environment(org.apache.ibatis.mapping.Environment) InputStreamReader(java.io.InputStreamReader) Reader(java.io.Reader) Properties(java.util.Properties) ActivitiException(org.activiti.engine.ActivitiException) SQLException(java.sql.SQLException)

Aggregations

ActivitiException (org.activiti.engine.ActivitiException)289 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)45 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)44 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)38 IOException (java.io.IOException)35 ArrayList (java.util.ArrayList)25 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)22 ByteArrayOutputStream (java.io.ByteArrayOutputStream)20 FlowElement (org.activiti.bpmn.model.FlowElement)19 CommandContext (org.activiti.engine.impl.interceptor.CommandContext)18 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)17 Expression (org.activiti.engine.delegate.Expression)17 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)17 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)17 ObjectOutputStream (java.io.ObjectOutputStream)15 WorkflowException (org.alfresco.service.cmr.workflow.WorkflowException)15 HashMap (java.util.HashMap)12 ExecutionEntityManager (org.activiti.engine.impl.persistence.entity.ExecutionEntityManager)11 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)11 InputStream (java.io.InputStream)10