Search in sources :

Example 1 with JSONException

use of org.activiti.engine.impl.util.json.JSONException in project Activiti by Activiti.

the class TimerEventHandler method setActivityIdToConfiguration.

public String setActivityIdToConfiguration(String jobHandlerConfiguration, String activityId) {
    try {
        JSONObject cfgJson = new JSONObject(jobHandlerConfiguration);
        cfgJson.put(PROPERTYNAME_TIMER_ACTIVITY_ID, activityId);
        return cfgJson.toString();
    } catch (JSONException ex) {
        return jobHandlerConfiguration;
    }
}
Also used : JSONObject(org.activiti.engine.impl.util.json.JSONObject) JSONException(org.activiti.engine.impl.util.json.JSONException)

Example 2 with JSONException

use of org.activiti.engine.impl.util.json.JSONException in project Activiti by Activiti.

the class TimerEventHandler method hasRealActivityId.

/**
   * Before Activiti 5.21, the jobHandlerConfiguration would have as activityId the process definition key
   * (as only one timer start event was supported). In >= 5.21, this changed and in >= 5.21 the activityId 
   * is the REAL activity id. It can be recognized by having the 'processDefinitionKey' in the configuration.
   * A < 5.21 job would not have that.
   */
public static boolean hasRealActivityId(String jobHandlerConfiguration) {
    try {
        JSONObject cfgJson = new JSONObject(jobHandlerConfiguration);
        Object processDefinitionKey = cfgJson.get(PROPERTYNAME_PROCESS_DEFINITION_KEY);
        if (processDefinitionKey != null) {
            return processDefinitionKey.toString().length() > 0;
        }
    } catch (JSONException ex) {
        return false;
    }
    return false;
}
Also used : JSONObject(org.activiti.engine.impl.util.json.JSONObject) JSONException(org.activiti.engine.impl.util.json.JSONException) JSONObject(org.activiti.engine.impl.util.json.JSONObject)

Example 3 with JSONException

use of org.activiti.engine.impl.util.json.JSONException in project Activiti by Activiti.

the class TimerEventHandler method setProcessDefinitionKeyToConfiguration.

public String setProcessDefinitionKeyToConfiguration(String jobHandlerConfiguration, String activityId) {
    try {
        JSONObject cfgJson = new JSONObject(jobHandlerConfiguration);
        cfgJson.put(PROPERTYNAME_PROCESS_DEFINITION_KEY, activityId);
        return cfgJson.toString();
    } catch (JSONException ex) {
        return jobHandlerConfiguration;
    }
}
Also used : JSONObject(org.activiti.engine.impl.util.json.JSONObject) JSONException(org.activiti.engine.impl.util.json.JSONException)

Aggregations

JSONException (org.activiti.engine.impl.util.json.JSONException)3 JSONObject (org.activiti.engine.impl.util.json.JSONObject)3