Browse Source

added startWithXid

Grega Bremec 3 years ago
parent
commit
9affa004aa
1 changed files with 40 additions and 1 deletions
  1. 40 1
      curl-client.sh

+ 40 - 1
curl-client.sh

@@ -55,7 +55,7 @@ Where:
  -s <sig>   is the name of the signal to work with
  -d <data>  is the request payload, if operation requires some data
 
-Note that ALL command line options override config file values.
+NOTE: command line options override config file values.
 
 And <command> is one of (required parameters in parentheses):
 
@@ -70,10 +70,13 @@ And <command> is one of (required parameters in parentheses):
     getInstanceSignals displays all signals available for a process instance (-k, -i)
     getInstanceVars    displays all variables currently set in an process instance (-k, -i)
     start              starts a process instance from a model (-k, -p, optionally -d)
+    startWithXid       starts a process instance from a model (-k, -p, -x, optionally -d)
     sendSignal         sends a signal (with optional payload) to an instance (-k, -i, -s, optionally -d)
     sendSignalByXid    sends a signal (with optional payload) to an instance matching XID (-k, -x, -s, optionally -d)
     abort              aborts a specified process instance (-k, -i)
 
+NOTE: you must always specify the command LAST on the line.
+
 EOF
 }
 
@@ -152,6 +155,7 @@ if [ -z "$*" ]; then
     echo "FATAL: Missing command." >&2
     echo >&2
     usage >&2
+    exit 1
 fi
 
 # Try loading the config file:
@@ -284,6 +288,26 @@ case ${COMMAND} in
 	    exit 1
 	fi
 	;;
+    startWithXid)
+	ERRORS=0
+	if [ -z "${KIE_CONTAINER}" ]; then
+	    echo "FATAL: ${COMMAND} requires -k option to be set." >&2
+	    ERRORS=1
+	fi
+	if [ -z "${PROCESS_MODEL}" ]; then
+	    echo "FATAL: ${COMMAND} requires -p option to be set." >&2
+	    ERRORS=1
+	fi
+	if [ -z "${CORRELATION_ID}" ]; then
+	    echo "FATAL: ${COMMAND} requires -x option to be set." >&2
+	    ERRORS=1
+	fi
+	if [ ${ERRORS} -gt 0 ]; then
+	    echo >&2
+	    usage >&2
+	    exit 1
+	fi
+	;;
     *)
 	echo "FATAL: Unrecognised command: \"$*\"" >&2
 	echo >&2
@@ -415,6 +439,21 @@ case ${COMMAND} in
 	echo "New instance ID is ${NEW_ID}."
 	echo
 	;;
+    startWithXid)
+	echo "    KIE_CONTAINER  = ${KIE_CONTAINER}"
+	echo "    PROCESS_MODEL  = ${PROCESS_MODEL}"
+	echo "    CORRELATION_ID  = ${CORRELATION_ID}"
+	echo "    REQUEST_DATA   = \"${REQUEST_DATA}\""
+	echo
+	echo -n "Starting a new instance of process model ${PROCESS_MODEL} with XID ${CORRELATION_ID}... "
+	if [ -n "${REQUEST_DATA}" ]; then
+	    CURL_CMD="${CURL_CMD} -d '${REQUEST_DATA}'"
+	fi
+	NEW_ID=$(eval ${CURL_CMD} -XPOST ${API_ENDPOINT}/containers/${KIE_CONTAINER}/processes/${PROCESS_MODEL}/instances/correlation/${CORRELATION_ID})
+	echo "done."
+	echo "New instance ID is ${NEW_ID}."
+	echo
+	;;
     sendSignal)
 	echo "    KIE_CONTAINER  = ${KIE_CONTAINER}"
 	echo "    INSTANCE_ID    = ${INSTANCE_ID}"