use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.
the class AddCommentCmd method execute.
public Comment execute(CommandContext commandContext) {
if (processInstanceId == null && taskId == null) {
throw new ProcessEngineException("Process instance id and task id is null");
}
ensureNotNull("Message", message);
String userId = commandContext.getAuthenticatedUserId();
CommentEntity comment = new CommentEntity();
comment.setUserId(userId);
comment.setType(CommentEntity.TYPE_COMMENT);
comment.setTime(ClockUtil.getCurrentTime());
comment.setTaskId(taskId);
comment.setProcessInstanceId(processInstanceId);
comment.setAction(Event.ACTION_ADD_COMMENT);
String eventMessage = message.replaceAll("\\s+", " ");
if (eventMessage.length() > 163) {
eventMessage = eventMessage.substring(0, 160) + "...";
}
comment.setMessage(eventMessage);
comment.setFullMessage(message);
commandContext.getCommentManager().insert(comment);
return comment;
}
use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.
the class DetermineHistoryLevelCmd method execute.
@Override
public HistoryLevel execute(final CommandContext commandContext) {
final Integer databaseHistoryLevel = HistoryLevelSetupCommand.databaseHistoryLevel(commandContext);
HistoryLevel result = null;
if (databaseHistoryLevel != null) {
for (final HistoryLevel historyLevel : historyLevels) {
if (historyLevel.getId() == databaseHistoryLevel) {
result = historyLevel;
break;
}
}
if (result != null) {
return result;
} else {
// if a custom non-null value is not registered, throw an exception.
throw new ProcessEngineException(String.format("The configured history level with id='%s' is not registered in this config.", databaseHistoryLevel));
}
} else {
return null;
}
}
use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.
the class JavaSerializationTest method testStandaloneTaskVariable.
public void testStandaloneTaskVariable() {
Task task = taskService.newTask();
task.setName("gonzoTask");
taskService.saveTask(task);
String taskId = task.getId();
try {
taskService.setVariable(taskId, "instrument", Variables.serializedObjectValue("trumpet").serializationDataFormat(Variables.SerializationDataFormats.JAVA).create());
fail("Exception is expected.");
} catch (ProcessEngineException ex) {
assertEquals("ENGINE-17007 Cannot set variable with name instrument. Java serialization format is prohibited", ex.getMessage());
} finally {
taskService.deleteTask(taskId, true);
}
}
use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.
the class JavaSerializationTest method testJavaSerializedValuesAreProhibitedForTransient.
@Deployment(resources = ONE_TASK_PROCESS)
public void testJavaSerializedValuesAreProhibitedForTransient() throws JSONException {
ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
try {
// request object to be serialized as Java
runtimeService.setVariable(instance.getId(), "simpleBean", serializedObjectValue("").serializationDataFormat(Variables.SerializationDataFormats.JAVA).create());
fail("Exception is expected.");
} catch (ProcessEngineException ex) {
assertEquals("ENGINE-17007 Cannot set variable with name simpleBean. Java serialization format is prohibited", ex.getMessage());
}
}
use of org.camunda.bpm.engine.ProcessEngineException in project camunda-bpm-platform by camunda.
the class JsonSerializationTest method testFailingSerialization.
@Deployment(resources = ONE_TASK_PROCESS)
public void testFailingSerialization() {
ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
FailingSerializationBean failingBean = new FailingSerializationBean("a String", 42, true);
try {
runtimeService.setVariable(instance.getId(), "simpleBean", objectValue(failingBean).serializationDataFormat(JSON_FORMAT_NAME));
fail("exception expected");
} catch (ProcessEngineException e) {
// happy path
}
}
Aggregations