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);
}
}
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();
}
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;
}
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);
}
}
}
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);
}
}
}
Aggregations