1515/**
1616 * Abstract base class for all CWS built-in (and custom user-added) task
1717 * implementations.
18- *
18+ *
1919 */
2020public abstract class CwsTask implements JavaDelegate {
2121
@@ -55,32 +55,32 @@ public CwsTask() {
5555 * 1) initializes parameters
5656 * 2) runs the task implementation
5757 * 3) throws any qualified exceptions
58- *
58+ *
5959 */
6060 public void execute (final DelegateExecution execution ) {
6161 this .execution = execution ;
62-
62+
6363 // setup tags on logging
6464 log .setProcTags (getProcDefKey (execution ),
65- execution .getProcessInstanceId (),
65+ execution .getProcessInstanceId (),
6666 execution .getActivityInstanceId ());
67-
67+
6868 try {
6969 // setup base params
7070 throwOnTruncatedVariableBoolean = getBooleanParam (
7171 throwOnTruncatedVariable , "throwOnTruncatedVariable" ,
7272 DEFAULT_THROW_ON_TRUNCATED_VARIABLE );
73-
73+
7474 // Evaluate preCondition.
7575 // If preCondition passes, then execute task,
7676 // otherwise skip task execution.
7777 if (evaluateTaskPreCondition ()) {
7878 setOutputVariable ("preConditionPassed" , true );
79-
79+
8080 // get params
8181 log .trace ("INITIALIZING PARAMETERS FOR TASK: " + this );
8282 initParams ();
83-
83+
8484 // execute the task
8585 log .trace ("EXECUTING TASK: " + this );
8686 executeTask ();
@@ -91,25 +91,25 @@ public void execute(final DelegateExecution execution) {
9191 } catch (BpmnError e ) {
9292 log .warn ("Propagating BpmnError(" + e .getErrorCode () + ")..." );
9393 setOutputVariable ("bpmnErrorMessage" , e .getErrorCode ());
94-
94+
9595 // We saw an error, but we want to check with Camunda because this is by-passing our end-event listener
9696 notifyWorkerOfFailedProcess ();
97-
97+
9898 throw e ; // propagate so engine can handle (if boundary catch defined)
9999 } catch (Throwable t ) {
100100 log .error ("Unexpected Throwable while executing " + this , t );
101101 setOutputVariable ("unexpectedErrorMessage" , t .getMessage ());
102-
102+
103103 notifyWorkerOfFailedProcess ();
104-
104+
105105 // wrap and propagate so engine can (if boundary catch defined) handle
106106 throw new BpmnError (UNEXPECTED_ERROR );
107107 } finally {
108108 // cleanup
109109 this .execution = null ;
110110 }
111111 }
112-
112+
113113
114114 private void notifyWorkerOfFailedProcess () {
115115 log .debug ("notifying workers of failed process..." );
@@ -128,8 +128,8 @@ public void run() {
128128 }
129129 }).start ();
130130 }
131-
132-
131+
132+
133133 private String getProcDefKey (final DelegateExecution execution ) {
134134 String procDefKey = "UNKNOWN" ;
135135
@@ -159,34 +159,34 @@ private String getProcDefKey(final DelegateExecution execution) {
159159
160160 /**
161161 * Implementation must be filled out by subclasses.
162- *
162+ *
163163 */
164164 protected abstract void initParams () throws Exception ;
165165
166166 /**
167167 * Implementation must be filled out by subclasses.
168- *
168+ *
169169 */
170170 protected abstract void executeTask () throws Exception ;
171171
172172 /**
173173 * Evaluates the task preCondition.
174- *
174+ *
175175 * @return true if preCondition passes false if preCondition fails
176- *
176+ *
177177 * @throws Exception if unexpected exception occurs
178178 * @throws BpmnError if process is to be determined.
179179 */
180180 private boolean evaluateTaskPreCondition () throws Exception {
181-
181+
182182 if (!getBooleanParam (preCondition , "preCondition" ,
183183 DEFAULT_PRE_CONDITION )) {
184-
184+
185185 // Check special case for preCondition is "none" and pass as true
186186 if (preCondition != null && preCondition .getValue (execution ).equals ("none" )) {
187187 return true ;
188188 }
189-
189+
190190 log .warn ("preCondition was not satisfied" );
191191 PreConditionFailBehavior failBehavior = PreConditionFailBehavior
192192 .valueOf (getStringParam (onPreConditionFail ,
@@ -269,7 +269,7 @@ protected String getStringParam(Expression expression, String paramName)
269269 }
270270
271271 protected String getStringParam (Expression expression , String paramName ,
272- String defaultValue ) throws Exception {
272+ String defaultValue ) throws Exception {
273273 if (expression == null ) {
274274 // return default
275275 return defaultValue ;
@@ -292,7 +292,7 @@ protected Boolean getBooleanParam(Expression expression, String paramName)
292292 }
293293
294294 protected Boolean getBooleanParam (Expression expression , String paramName ,
295- Boolean defaultValue ) throws Exception {
295+ Boolean defaultValue ) throws Exception {
296296 if (expression == null ) {
297297 // return default
298298 return defaultValue ;
@@ -322,7 +322,7 @@ protected Integer getIntegerParam(Expression expression, String paramName)
322322 }
323323
324324 protected Integer getIntegerParam (Expression expression , String paramName ,
325- Integer defaultValue ) throws Exception {
325+ Integer defaultValue ) throws Exception {
326326 if (expression == null ) {
327327 // return default
328328 return defaultValue ;
@@ -352,7 +352,7 @@ protected Long getLongParam(Expression expression, String paramName)
352352 }
353353
354354 protected Long getLongParam (Expression expression , String paramName ,
355- Long defaultValue ) throws Exception {
355+ Long defaultValue ) throws Exception {
356356 if (expression == null ) {
357357 // return default
358358 return defaultValue ;
@@ -384,7 +384,7 @@ protected Float getFloatParam(Expression expression, String paramName)
384384 }
385385
386386 protected Float getFloatParam (Expression expression , String paramName ,
387- Float defaultValue ) throws Exception {
387+ Float defaultValue ) throws Exception {
388388 if (expression == null ) {
389389 // return default
390390 return defaultValue ;
@@ -414,7 +414,7 @@ protected Double getDoubleParam(Expression expression, String paramName)
414414 }
415415
416416 protected Double getDoubleParam (Expression expression , String paramName ,
417- Double defaultValue ) throws Exception {
417+ Double defaultValue ) throws Exception {
418418 if (expression == null ) {
419419 // return default
420420 return defaultValue ;
@@ -437,10 +437,10 @@ private Double getDoubleValue(Object value, String paramName)
437437 /**
438438 * For now only supports Map<String,String> but may want to support
439439 * generics/others in future...
440- *
440+ *
441441 */
442442 protected Map <String , String > getMapParam (Expression expression ,
443- String paramName ) throws Exception {
443+ String paramName ) throws Exception {
444444 if (expression == null ) {
445445 // no default, so throw exception
446446 throw new Exception ("Mandatory parameter '" + paramName + "' not specified" );
@@ -449,7 +449,7 @@ protected Map<String, String> getMapParam(Expression expression,
449449 }
450450
451451 protected Map <String , String > getMapParam (Expression expression ,
452- String paramName , Map <String , String > defaultValue )
452+ String paramName , Map <String , String > defaultValue )
453453 throws Exception {
454454 if (expression == null ) {
455455 // return default
@@ -482,4 +482,4 @@ private Map<String, String> getMapValue(Object value, String paramName)
482482 }
483483 }
484484
485- }
485+ }
0 commit comments